Add a require_destination setting
If you always want to use a destination, and have a base deploy.yml file that doesn't specify any hosts, then if you forget to specific the destination you will get a cryptic error. Add a "require_destination" setting you can use to avoid this.
This commit is contained in:
@@ -9,8 +9,7 @@ class Kamal::Configuration
|
||||
delegate :service, :image, :servers, :env, :labels, :registry, :stop_wait_time, :hooks_path, to: :raw_config, allow_nil: true
|
||||
delegate :argumentize, :optionize, to: Kamal::Utils
|
||||
|
||||
attr_accessor :destination
|
||||
attr_accessor :raw_config
|
||||
attr_reader :destination, :raw_config
|
||||
|
||||
class << self
|
||||
def create_from(config_file:, destination: nil, version: nil)
|
||||
@@ -120,6 +119,10 @@ class Kamal::Configuration
|
||||
"#{service}-#{version}"
|
||||
end
|
||||
|
||||
def require_destination?
|
||||
raw_config.require_destination
|
||||
end
|
||||
|
||||
|
||||
def volume_args
|
||||
if raw_config.volumes.present?
|
||||
@@ -161,7 +164,7 @@ class Kamal::Configuration
|
||||
end
|
||||
|
||||
def valid?
|
||||
ensure_required_keys_present && ensure_valid_kamal_version
|
||||
ensure_destination_if_required && ensure_required_keys_present && ensure_valid_kamal_version
|
||||
end
|
||||
|
||||
|
||||
@@ -243,6 +246,14 @@ class Kamal::Configuration
|
||||
true
|
||||
end
|
||||
|
||||
def ensure_destination_if_required
|
||||
if require_destination? && destination.nil?
|
||||
raise ArgumentError, "You must specify a destination"
|
||||
end
|
||||
|
||||
true
|
||||
end
|
||||
|
||||
|
||||
def role_names
|
||||
raw_config.servers.is_a?(Array) ? [ "web" ] : raw_config.servers.keys.sort
|
||||
|
||||
Reference in New Issue
Block a user