Disambiguate
This commit is contained in:
@@ -6,9 +6,11 @@ require "erb"
|
||||
require "mrsk/utils"
|
||||
|
||||
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
|
||||
|
||||
attr_accessor :raw_config
|
||||
|
||||
class << self
|
||||
def create_from(base_config_file, destination: nil, version: "missing")
|
||||
new(load_config_file(base_config_file).tap do |config|
|
||||
@@ -34,8 +36,8 @@ class Mrsk::Configuration
|
||||
end
|
||||
end
|
||||
|
||||
def initialize(config, version: "missing", validate: true)
|
||||
@config = ActiveSupport::InheritableOptions.new(config)
|
||||
def initialize(raw_config, version: "missing", validate: true)
|
||||
@raw_config = ActiveSupport::InheritableOptions.new(raw_config)
|
||||
@version = version
|
||||
ensure_required_keys_present if validate
|
||||
end
|
||||
@@ -67,7 +69,7 @@ class Mrsk::Configuration
|
||||
end
|
||||
|
||||
def repository
|
||||
[ config.registry["server"], image ].compact.join("/")
|
||||
[ raw_config.registry["server"], image ].compact.join("/")
|
||||
end
|
||||
|
||||
def absolute_image
|
||||
@@ -80,15 +82,15 @@ class Mrsk::Configuration
|
||||
|
||||
|
||||
def env_args
|
||||
if config.env.present?
|
||||
argumentize_env_with_secrets(config.env)
|
||||
if raw_config.env.present?
|
||||
argumentize_env_with_secrets(raw_config.env)
|
||||
else
|
||||
[]
|
||||
end
|
||||
end
|
||||
|
||||
def ssh_user
|
||||
config.ssh_user || "root"
|
||||
raw_config.ssh_user || "root"
|
||||
end
|
||||
|
||||
def ssh_options
|
||||
@@ -110,30 +112,28 @@ class Mrsk::Configuration
|
||||
service_with_version: service_with_version,
|
||||
env_args: env_args,
|
||||
ssh_options: ssh_options,
|
||||
builder: config.builder
|
||||
builder: raw_config.builder
|
||||
}.compact
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
attr_accessor :config
|
||||
|
||||
def ensure_required_keys_present
|
||||
%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
|
||||
|
||||
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"
|
||||
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)"
|
||||
end
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user