Disambiguate
This commit is contained in:
@@ -6,9 +6,11 @@ require "erb"
|
|||||||
require "mrsk/utils"
|
require "mrsk/utils"
|
||||||
|
|
||||||
class Mrsk::Configuration
|
class Mrsk::Configuration
|
||||||
delegate :service, :image, :servers, :env, :labels, :registry, :builder, to: :config, allow_nil: true
|
delegate :service, :image, :servers, :env, :labels, :registry, :builder, to: :raw_config, allow_nil: true
|
||||||
delegate :argumentize_env_with_secrets, to: Mrsk::Utils
|
delegate :argumentize_env_with_secrets, to: Mrsk::Utils
|
||||||
|
|
||||||
|
attr_accessor :raw_config
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def create_from(base_config_file, destination: nil, version: "missing")
|
def create_from(base_config_file, destination: nil, version: "missing")
|
||||||
new(load_config_file(base_config_file).tap do |config|
|
new(load_config_file(base_config_file).tap do |config|
|
||||||
@@ -34,8 +36,8 @@ class Mrsk::Configuration
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(config, version: "missing", validate: true)
|
def initialize(raw_config, version: "missing", validate: true)
|
||||||
@config = ActiveSupport::InheritableOptions.new(config)
|
@raw_config = ActiveSupport::InheritableOptions.new(raw_config)
|
||||||
@version = version
|
@version = version
|
||||||
ensure_required_keys_present if validate
|
ensure_required_keys_present if validate
|
||||||
end
|
end
|
||||||
@@ -67,7 +69,7 @@ class Mrsk::Configuration
|
|||||||
end
|
end
|
||||||
|
|
||||||
def repository
|
def repository
|
||||||
[ config.registry["server"], image ].compact.join("/")
|
[ raw_config.registry["server"], image ].compact.join("/")
|
||||||
end
|
end
|
||||||
|
|
||||||
def absolute_image
|
def absolute_image
|
||||||
@@ -80,15 +82,15 @@ class Mrsk::Configuration
|
|||||||
|
|
||||||
|
|
||||||
def env_args
|
def env_args
|
||||||
if config.env.present?
|
if raw_config.env.present?
|
||||||
argumentize_env_with_secrets(config.env)
|
argumentize_env_with_secrets(raw_config.env)
|
||||||
else
|
else
|
||||||
[]
|
[]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def ssh_user
|
def ssh_user
|
||||||
config.ssh_user || "root"
|
raw_config.ssh_user || "root"
|
||||||
end
|
end
|
||||||
|
|
||||||
def ssh_options
|
def ssh_options
|
||||||
@@ -110,30 +112,28 @@ class Mrsk::Configuration
|
|||||||
service_with_version: service_with_version,
|
service_with_version: service_with_version,
|
||||||
env_args: env_args,
|
env_args: env_args,
|
||||||
ssh_options: ssh_options,
|
ssh_options: ssh_options,
|
||||||
builder: config.builder
|
builder: raw_config.builder
|
||||||
}.compact
|
}.compact
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
private
|
private
|
||||||
attr_accessor :config
|
|
||||||
|
|
||||||
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 config[key].present?
|
raise ArgumentError, "Missing required configuration for #{key}" unless raw_config[key].present?
|
||||||
end
|
end
|
||||||
|
|
||||||
if config.registry["username"].blank?
|
if raw_config.registry["username"].blank?
|
||||||
raise ArgumentError, "You must specify a username for the registry in config/deploy.yml"
|
raise ArgumentError, "You must specify a username for the registry in config/deploy.yml"
|
||||||
end
|
end
|
||||||
|
|
||||||
if config.registry["password"].blank?
|
if raw_config.registry["password"].blank?
|
||||||
raise ArgumentError, "You must specify a password for the registry in config/deploy.yml (or set the ENV variable if that's used)"
|
raise ArgumentError, "You must specify a password for the registry in config/deploy.yml (or set the ENV variable if that's used)"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def role_names
|
def role_names
|
||||||
config.servers.is_a?(Array) ? [ "web" ] : config.servers.keys.sort
|
raw_config.servers.is_a?(Array) ? [ "web" ] : raw_config.servers.keys.sort
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user