If there are accessories defined in the configuration, we'll not require servers to be defined as well. This allows for accessory-only configurations which allows you to run external images with kamal-proxy for zero-downtime deployments. We don't manage image cleanup for accessories though so the user will need to deal with that themselves.
26 lines
596 B
Ruby
26 lines
596 B
Ruby
class Kamal::Configuration::Servers
|
|
include Kamal::Configuration::Validation
|
|
|
|
attr_reader :config, :servers_config, :roles
|
|
|
|
def initialize(config:)
|
|
@config = config
|
|
@servers_config = config.raw_config.servers
|
|
validate! servers_config, with: Kamal::Configuration::Validator::Servers
|
|
|
|
@roles = role_names.map { |role_name| Kamal::Configuration::Role.new role_name, config: config }
|
|
end
|
|
|
|
private
|
|
def role_names
|
|
case servers_config
|
|
when Array
|
|
[ "web" ]
|
|
when NilClass
|
|
[]
|
|
else
|
|
servers_config.keys.sort
|
|
end
|
|
end
|
|
end
|