From c3d643415b659612e7bbfca3b8b90f0be8a28170 Mon Sep 17 00:00:00 2001 From: Nick Hammond Date: Thu, 1 Feb 2024 09:35:42 -0700 Subject: [PATCH] Set KAMAL_DESTINATION for envify command --- lib/kamal/cli/main.rb | 1 + test/cli/main_test.rb | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/kamal/cli/main.rb b/lib/kamal/cli/main.rb index 6adc36fe..42f69076 100644 --- a/lib/kamal/cli/main.rb +++ b/lib/kamal/cli/main.rb @@ -175,6 +175,7 @@ def init option :skip_push, aliases: "-P", type: :boolean, default: false, desc: "Skip .env file push" def envify if destination = options[:destination] + ENV['KAMAL_DESTINATION'] = destination env_template_path = ".env.#{destination}.erb" env_path = ".env.#{destination}" else diff --git a/test/cli/main_test.rb b/test/cli/main_test.rb index 8b152d52..ea0d19bc 100644 --- a/test/cli/main_test.rb +++ b/test/cli/main_test.rb @@ -122,12 +122,12 @@ class CliMainTest < CliTestCase refute_match /Running the post-deploy hook.../, output end end - + test "deploy without healthcheck if primary host doesn't have traefik" do invoke_options = { "config_file" => "test/fixtures/deploy_workers_only.yml", "version" => "999", "skip_hooks" => false } Kamal::Cli::Main.any_instance.expects(:invoke).with("kamal:cli:healthcheck:perform", [], invoke_options).never - + Kamal::Cli::Main.any_instance.expects(:invoke).with("kamal:cli:registry:login", [], invoke_options) Kamal::Cli::Main.any_instance.expects(:invoke).with("kamal:cli:build:deliver", [], invoke_options) Kamal::Cli::Main.any_instance.expects(:invoke).with("kamal:cli:traefik:boot", [], invoke_options) @@ -407,8 +407,8 @@ class CliMainTest < CliTestCase end test "envify with destination" do - File.expects(:read).with(".env.world.erb").returns("HELLO=<%= 'world' %>") - File.expects(:write).with(".env.world", "HELLO=world", perm: 0600) + File.expects(:read).with(".env.world.erb").returns("DESTINATION=<%= ENV['KAMAL_DESTINATION'] %>\nHELLO=<%= 'world' %>") + File.expects(:write).with(".env.world", "DESTINATION=world\nHELLO=world", perm: 0600) run_command("envify", "-d", "world", config_file: "deploy_for_dest") end