Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/kamal/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ def load_config_file(file)
end

def destination_config_file(base_config_file, destination)
base_config_file.sub_ext(".#{destination}.yml") if destination
if destination
base_extension = base_config_file.extname
base_config_file.sub_ext(".#{destination}#{base_extension}")
end
end
end

Expand Down
19 changes: 19 additions & 0 deletions test/configuration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,25 @@ class ConfigurationTest < ActiveSupport::TestCase
end
end

test "destination yaml config preserves extension" do
dest_config_file = Pathname.new(File.expand_path("fixtures/deploy_for_dest.yaml", __dir__))

config = Kamal::Configuration.create_from config_file: dest_config_file, destination: "world"
assert_equal "2.1.1.1", config.all_hosts.first
end

test "destination file preserves base file extension" do
# Test with .yml extension (existing behavior should still work)
yml_config_file = Pathname.new(File.expand_path("fixtures/deploy_for_dest.yml", __dir__))
config = Kamal::Configuration.create_from config_file: yml_config_file, destination: "world"
assert_equal "1.1.1.1", config.all_hosts.first

# Test with .yaml extension (new behavior)
yaml_config_file = Pathname.new(File.expand_path("fixtures/deploy_for_dest.yaml", __dir__))
config = Kamal::Configuration.create_from config_file: yaml_config_file, destination: "world"
assert_equal "2.1.1.1", config.all_hosts.first
end

test "destination required" do
dest_config_file = Pathname.new(File.expand_path("fixtures/deploy_for_required_dest.yml", __dir__))

Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/deploy_for_dest.world.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
servers:
- 2.1.1.1
- 2.1.1.2
env:
REDIS_URL: redis://x/y
8 changes: 8 additions & 0 deletions test/fixtures/deploy_for_dest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
service: app
image: dhh/app
registry:
server: registry.digitalocean.com
username: <%= "my-user" %>
password: <%= "my-password" %>
builder:
arch: amd64