From 8ca04032a1bc7f4940728714a3d805f9606a22bb Mon Sep 17 00:00:00 2001 From: Krzysztof Adamski Date: Mon, 23 Oct 2023 14:49:39 +0200 Subject: [PATCH] Optionally Skip Push for "envify" --- lib/kamal/cli/main.rb | 3 ++- test/cli/main_test.rb | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/kamal/cli/main.rb b/lib/kamal/cli/main.rb index 36fe1b751..4a81c8ce8 100644 --- a/lib/kamal/cli/main.rb +++ b/lib/kamal/cli/main.rb @@ -170,6 +170,7 @@ def init end desc "envify", "Create .env by evaluating .env.erb (or .env.staging.erb -> .env.staging when using -d staging)" + option :skip_push, aliases: "-P", type: :boolean, default: false, desc: "Skip .env file push" def envify if destination = options[:destination] env_template_path = ".env.#{destination}.erb" @@ -182,7 +183,7 @@ def envify File.write(env_path, ERB.new(File.read(env_template_path)).result, perm: 0600) load_envs # reload new file - invoke "kamal:cli:env:push", options + invoke "kamal:cli:env:push", options unless options[:skip_push] end desc "remove", "Remove Traefik, app, accessories, and registry session from servers" diff --git a/test/cli/main_test.rb b/test/cli/main_test.rb index fe174653c..0027cbb82 100644 --- a/test/cli/main_test.rb +++ b/test/cli/main_test.rb @@ -353,6 +353,14 @@ class CliMainTest < CliTestCase run_command("envify", "-d", "world", config_file: "deploy_for_dest") end + test "envify with skip_push" do + File.expects(:read).with(".env.erb").returns("HELLO=<%= 'world' %>") + File.expects(:write).with(".env", "HELLO=world", perm: 0600) + + Kamal::Cli::Main.any_instance.expects(:invoke).with("kamal:cli:env:push").never + run_command("envify", "--skip-push") + end + test "remove with confirmation" do run_command("remove", "-y", config_file: "deploy_with_accessories").tap do |output| assert_match /docker container stop traefik/, output