Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add kamal secrets print for secret debugging #1009

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/kamal/cli/secrets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ def extract(name, secrets)
return_or_puts value, inline: options[:inline]
end

desc "print", "Print the secrets (for debugging)"
def print
KAMAL.config.secrets.to_h.each do |key, value|
puts "#{key}=#{value}"
end
end

private
def adapter(adapter)
Kamal::Secrets::Adapters.lookup(adapter)
Expand Down
6 changes: 6 additions & 0 deletions test/cli/secrets_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ class CliSecretsTest < CliTestCase
assert_equal "oof", run_command("extract", "foo", "{\"abc/foo\":\"oof\", \"bar\":\"rab\", \"baz\":\"zab\"}")
end

test "print" do
with_test_secrets("secrets" => "SECRET1=ABC\nSECRET2=${SECRET1}DEF\n") do
assert_equal "SECRET1=ABC\nSECRET2=ABCDEF", run_command("print")
end
end

private
def run_command(*command)
stdouted { Kamal::Cli::Secrets.start([ *command, "-c", "test/fixtures/deploy_with_accessories.yml" ]) }
Expand Down