Group configuration methods in logical sections
This commit is contained in:
@@ -56,16 +56,8 @@ class Kamal::Configuration
|
|||||||
Kamal::Utils.abbreviate_version(version)
|
Kamal::Utils.abbreviate_version(version)
|
||||||
end
|
end
|
||||||
|
|
||||||
def run_directory
|
def minimum_version
|
||||||
raw_config.run_directory || ".kamal"
|
raw_config.minimum_version
|
||||||
end
|
|
||||||
|
|
||||||
def run_directory_as_docker_volume
|
|
||||||
if Pathname.new(run_directory).absolute?
|
|
||||||
run_directory
|
|
||||||
else
|
|
||||||
File.join "$(pwd)", run_directory
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -98,10 +90,6 @@ class Kamal::Configuration
|
|||||||
roles.select(&:running_traefik?).flat_map(&:hosts).uniq
|
roles.select(&:running_traefik?).flat_map(&:hosts).uniq
|
||||||
end
|
end
|
||||||
|
|
||||||
def boot
|
|
||||||
Kamal::Configuration::Boot.new(config: self)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
def repository
|
def repository
|
||||||
[ raw_config.registry["server"], image ].compact.join("/")
|
[ raw_config.registry["server"], image ].compact.join("/")
|
||||||
@@ -142,6 +130,18 @@ class Kamal::Configuration
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def boot
|
||||||
|
Kamal::Configuration::Boot.new(config: self)
|
||||||
|
end
|
||||||
|
|
||||||
|
def builder
|
||||||
|
Kamal::Configuration::Builder.new(config: self)
|
||||||
|
end
|
||||||
|
|
||||||
|
def traefik
|
||||||
|
raw_config.traefik || {}
|
||||||
|
end
|
||||||
|
|
||||||
def ssh
|
def ssh
|
||||||
Kamal::Configuration::Ssh.new(config: self)
|
Kamal::Configuration::Ssh.new(config: self)
|
||||||
end
|
end
|
||||||
@@ -163,14 +163,46 @@ class Kamal::Configuration
|
|||||||
raw_config.readiness_delay || 7
|
raw_config.readiness_delay || 7
|
||||||
end
|
end
|
||||||
|
|
||||||
def minimum_version
|
def run_id
|
||||||
raw_config.minimum_version
|
@run_id ||= SecureRandom.hex(16)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def run_directory
|
||||||
|
raw_config.run_directory || ".kamal"
|
||||||
|
end
|
||||||
|
|
||||||
|
def run_directory_as_docker_volume
|
||||||
|
if Pathname.new(run_directory).absolute?
|
||||||
|
run_directory
|
||||||
|
else
|
||||||
|
File.join "$(pwd)", run_directory
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def hooks_path
|
||||||
|
raw_config.hooks_path || ".kamal/hooks"
|
||||||
|
end
|
||||||
|
|
||||||
|
def host_env_directory
|
||||||
|
"#{run_directory}/env"
|
||||||
|
end
|
||||||
|
|
||||||
|
def asset_path
|
||||||
|
raw_config.asset_path
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
def valid?
|
def valid?
|
||||||
ensure_destination_if_required && ensure_required_keys_present && ensure_valid_kamal_version
|
ensure_destination_if_required && ensure_required_keys_present && ensure_valid_kamal_version
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Will raise KeyError if any secret ENVs are missing
|
||||||
|
def ensure_env_available
|
||||||
|
roles.each(&:env_file)
|
||||||
|
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
def to_h
|
def to_h
|
||||||
{
|
{
|
||||||
@@ -191,39 +223,17 @@ class Kamal::Configuration
|
|||||||
}.compact
|
}.compact
|
||||||
end
|
end
|
||||||
|
|
||||||
def traefik
|
|
||||||
raw_config.traefik || {}
|
|
||||||
end
|
|
||||||
|
|
||||||
def hooks_path
|
|
||||||
raw_config.hooks_path || ".kamal/hooks"
|
|
||||||
end
|
|
||||||
|
|
||||||
def builder
|
|
||||||
Kamal::Configuration::Builder.new(config: self)
|
|
||||||
end
|
|
||||||
|
|
||||||
# Will raise KeyError if any secret ENVs are missing
|
|
||||||
def ensure_env_available
|
|
||||||
roles.each(&:env_file)
|
|
||||||
|
|
||||||
true
|
|
||||||
end
|
|
||||||
|
|
||||||
def host_env_directory
|
|
||||||
"#{run_directory}/env"
|
|
||||||
end
|
|
||||||
|
|
||||||
def run_id
|
|
||||||
@run_id ||= SecureRandom.hex(16)
|
|
||||||
end
|
|
||||||
|
|
||||||
def asset_path
|
|
||||||
raw_config.asset_path
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
# Will raise ArgumentError if any required config keys are missing
|
# Will raise ArgumentError if any required config keys are missing
|
||||||
|
def ensure_destination_if_required
|
||||||
|
if require_destination? && destination.nil?
|
||||||
|
raise ArgumentError, "You must specify a destination"
|
||||||
|
end
|
||||||
|
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
def ensure_required_keys_present
|
def ensure_required_keys_present
|
||||||
%i[ service image registry servers ].each do |key|
|
%i[ service image registry servers ].each do |key|
|
||||||
raise ArgumentError, "Missing required configuration for #{key}" unless raw_config[key].present?
|
raise ArgumentError, "Missing required configuration for #{key}" unless raw_config[key].present?
|
||||||
@@ -254,14 +264,6 @@ class Kamal::Configuration
|
|||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def ensure_destination_if_required
|
|
||||||
if require_destination? && destination.nil?
|
|
||||||
raise ArgumentError, "You must specify a destination"
|
|
||||||
end
|
|
||||||
|
|
||||||
true
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
def role_names
|
def role_names
|
||||||
raw_config.servers.is_a?(Array) ? [ "web" ] : raw_config.servers.keys.sort
|
raw_config.servers.is_a?(Array) ? [ "web" ] : raw_config.servers.keys.sort
|
||||||
|
|||||||
Reference in New Issue
Block a user