diff --git a/lib/kamal/configuration.rb b/lib/kamal/configuration.rb index 608e9f8ee..441ee1f5c 100644 --- a/lib/kamal/configuration.rb +++ b/lib/kamal/configuration.rb @@ -18,14 +18,14 @@ class Kamal::Configuration class << self def create_from(config_file:, destination: nil, version: nil) - ENV["KAMAL_DESTINATION"] = destination - raw_config = load_raw_config(config_file: config_file, destination: destination) new raw_config, destination: destination, version: version end def load_raw_config(config_file:, destination: nil) + ENV["KAMAL_DESTINATION"] = destination + load_config_files(config_file, *destination_config_file(config_file, destination)) end diff --git a/test/cli/main_test.rb b/test/cli/main_test.rb index 16b2807e2..efae07288 100644 --- a/test/cli/main_test.rb +++ b/test/cli/main_test.rb @@ -808,6 +808,14 @@ class CliMainTest < CliTestCase end end + test "render an alias with the destination" do + ENV.delete("KAMAL_DESTINATION") + + run_command("console", "-d", "world", config_file: "deploy_with_destination_aliases").tap do |output| + assert_match "bin/console world", output + end + end + test "upgrade" do invoke_options = base_invoke_options(config_file: "deploy_with_accessories.yml", version: nil, confirmed: true, rolling: false) Kamal::Cli::Main.any_instance.expects(:invoke).with("kamal:cli:proxy:upgrade", [], invoke_options) diff --git a/test/fixtures/deploy_with_destination_aliases.world.yml b/test/fixtures/deploy_with_destination_aliases.world.yml new file mode 100644 index 000000000..13cb31404 --- /dev/null +++ b/test/fixtures/deploy_with_destination_aliases.world.yml @@ -0,0 +1,2 @@ +servers: + - 1.1.1.1 diff --git a/test/fixtures/deploy_with_destination_aliases.yml b/test/fixtures/deploy_with_destination_aliases.yml new file mode 100644 index 000000000..0a38733ae --- /dev/null +++ b/test/fixtures/deploy_with_destination_aliases.yml @@ -0,0 +1,9 @@ +service: app +image: dhh/app +registry: + username: user + password: pw +builder: + arch: amd64 +aliases: + console: app exec --reuse "bin/console <%= ENV["KAMAL_DESTINATION"] %>"