Allow direct set of composition and ensure basic types are used

This commit is contained in:
Chris Roberts 2017-05-11 14:25:57 -07:00
parent 4673bbb907
commit 9242a69545
2 changed files with 11 additions and 2 deletions

View File

@ -29,7 +29,7 @@ module VagrantPlugins
# file. This can be used for adding networks or volumes.
#
# @return [Hash]
attr_reader :compose_configuration
attr_accessor :compose_configuration
# An optional file name of a Dockerfile to be used when building
# the image. This requires Docker >1.5.0.
@ -252,6 +252,11 @@ module VagrantPlugins
@vagrant_machine = @vagrant_machine.to_sym if @vagrant_machine
@expose.uniq!
if @compose_configuration.is_a?(Hash)
# Ensures configuration is using basic types
@compose_configuration = JSON.parse(@compose_configuration.to_json)
end
end
def validate(machine)
@ -272,6 +277,10 @@ module VagrantPlugins
end
end
if !@compose_configuration.is_a?(Hash)
errors << I18n.t("docker_provider.errors.config.compose_configuration_hash")
end
if !@create_args.is_a?(Array)
errors << I18n.t("docker_provider.errors.config.create_args_array")
end

View File

@ -91,7 +91,7 @@ module VagrantPlugins
update_composition(:apply) do |composition|
services = composition["services"] ||= {}
services[name] ||= {}
services[name].merge(
services[name].merge!(
"image" => image,
"environment" => env,
"expose" => expose,