diff --git a/lib/kamal/cli/secrets.rb b/lib/kamal/cli/secrets.rb index 8b919f9a3..b094be466 100644 --- a/lib/kamal/cli/secrets.rb +++ b/lib/kamal/cli/secrets.rb @@ -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) diff --git a/test/cli/secrets_test.rb b/test/cli/secrets_test.rb index 35d205004..6014a7e72 100644 --- a/test/cli/secrets_test.rb +++ b/test/cli/secrets_test.rb @@ -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" ]) }