Deep merge configuration settings and set any extra options
This commit is contained in:
parent
ed8378bcf5
commit
42c9042221
|
@ -1,3 +1,5 @@
|
||||||
|
# NOTE: DETACHED
|
||||||
|
|
||||||
require "json"
|
require "json"
|
||||||
require "log4r"
|
require "log4r"
|
||||||
|
|
||||||
|
@ -84,13 +86,22 @@ module VagrantPlugins
|
||||||
ports = Array(params[:ports])
|
ports = Array(params[:ports])
|
||||||
volumes = Array(params[:volumes])
|
volumes = Array(params[:volumes])
|
||||||
cmd = Array(params.fetch(:cmd))
|
cmd = Array(params.fetch(:cmd))
|
||||||
env = params.fetch(:env)
|
env = Hash[*params.fetch(:env).flatten.map(&:to_s)]
|
||||||
expose = Array(params[:expose])
|
expose = Array(params[:expose])
|
||||||
@logger.debug("Creating container `#{name}`")
|
@logger.debug("Creating container `#{name}`")
|
||||||
begin
|
begin
|
||||||
update_composition(:apply) do |composition|
|
update_composition(:apply) do |composition|
|
||||||
services = composition["services"] ||= {}
|
services = composition["services"] ||= {}
|
||||||
services[name] ||= {}
|
services[name] ||= {}
|
||||||
|
if params[:extra_args].is_a?(Hash)
|
||||||
|
services[name].merge!(
|
||||||
|
Hash[
|
||||||
|
params[:extra_args].map{ |k, v|
|
||||||
|
[k.to_s, v]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
)
|
||||||
|
end
|
||||||
services[name].merge!(
|
services[name].merge!(
|
||||||
"image" => image,
|
"image" => image,
|
||||||
"environment" => env,
|
"environment" => env,
|
||||||
|
@ -100,6 +111,9 @@ module VagrantPlugins
|
||||||
"links" => links,
|
"links" => links,
|
||||||
"command" => cmd
|
"command" => cmd
|
||||||
)
|
)
|
||||||
|
services[name]["hostname"] = params[:hostname] if params[:hostname]
|
||||||
|
services[name]["privileged"] = true if params[:privileged]
|
||||||
|
services[name]["pty"] = true if params[:pty]
|
||||||
end
|
end
|
||||||
rescue => error
|
rescue => error
|
||||||
@logger.error("Failed to create container `#{name}`: #{error.class} - #{error}")
|
@logger.error("Failed to create container `#{name}`: #{error.class} - #{error}")
|
||||||
|
@ -196,11 +210,9 @@ module VagrantPlugins
|
||||||
def get_composition
|
def get_composition
|
||||||
composition = {"version" => COMPOSE_VERSION.dup}
|
composition = {"version" => COMPOSE_VERSION.dup}
|
||||||
if composition_path.exist?
|
if composition_path.exist?
|
||||||
composition.merge!(
|
composition = Vagrant::Util::DeepMerge.deep_merge(composition, YAML.load(composition_path.read))
|
||||||
YAML.load(composition_path.read)
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
composition.merge!(machine.provider_config.compose_configuration.dup)
|
composition = Vagrant::Util::DeepMerge.deep_merge(composition, machine.provider_config.compose_configuration.dup)
|
||||||
@logger.debug("Fetched composition with provider configuration applied: #{composition}")
|
@logger.debug("Fetched composition with provider configuration applied: #{composition}")
|
||||||
composition
|
composition
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue