Skip to content

Commit

Permalink
Merge pull request #1009 from basecamp/secrets-print
Browse files Browse the repository at this point in the history
Add `kamal secrets print` for secret debugging
  • Loading branch information
djmb authored Sep 30, 2024
2 parents ef1271d + e441399 commit 7f6095c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
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

0 comments on commit 7f6095c

Please sign in to comment.