Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion lib/kamal/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ def initialize(raw_config, destination: nil, version: nil, validate: true)

validate! raw_config, example: validation_yml.symbolize_keys, context: "", with: Kamal::Configuration::Validator::Configuration

ensure_destination_if_required

@secrets = Kamal::Secrets.new(destination: destination, secrets_path: secrets_path)

# Eager load config to validate it, these are first as they have dependencies later on
Expand All @@ -77,7 +79,6 @@ def initialize(raw_config, destination: nil, version: nil, validate: true)
@ssh = Ssh.new(config: self)
@sshkit = Sshkit.new(config: self)

ensure_destination_if_required
ensure_required_keys_present
ensure_valid_kamal_version
ensure_retain_containers_valid
Expand Down
14 changes: 14 additions & 0 deletions test/configuration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,20 @@ class ConfigurationTest < ActiveSupport::TestCase
end
end

test "destination check precedes sub-config validation" do
# A destination-only key (builder.arch) lives only in the destination file, so
# the base config is incomplete. The missing-destination guard must run before
# the sub-configs validate themselves, otherwise "Builder arch not set" masks
# the real cause.
@deploy.delete(:builder)
@deploy[:require_destination] = true

error = assert_raises(ArgumentError) do
Kamal::Configuration.new(@deploy)
end
assert_equal "You must specify a destination", error.message
Comment thread
ThomasSevestre marked this conversation as resolved.
end

test "to_h" do
expected_config = \
{ roles: [ "web" ],
Expand Down