Properly set and validate before/after keys for base provisioner class
This commit is contained in:
parent
28c0f6085c
commit
66aac23470
|
@ -331,7 +331,14 @@ module VagrantPlugins
|
|||
end
|
||||
|
||||
if !prov
|
||||
prov = VagrantConfigProvisioner.new(name, type.to_sym)
|
||||
if options.key?(:before)
|
||||
before = options.delete(:before)
|
||||
end
|
||||
if options.key?(:after)
|
||||
after = options.delete(:after)
|
||||
end
|
||||
|
||||
prov = VagrantConfigProvisioner.new(name, type.to_sym, before, after)
|
||||
@provisioners << prov
|
||||
end
|
||||
|
||||
|
@ -760,12 +767,10 @@ module VagrantPlugins
|
|||
next
|
||||
end
|
||||
|
||||
require 'pry'
|
||||
binding.pry
|
||||
#provisioner_errors = vm_provisioner.validate(machine)
|
||||
#if provisioner_errors
|
||||
# errors = Vagrant::Config::V2::Util.merge_errors(errors, provisioner_errors)
|
||||
#end
|
||||
provisioner_errors = vm_provisioner.validate(machine)
|
||||
if provisioner_errors
|
||||
errors = Vagrant::Config::V2::Util.merge_errors(errors, provisioner_errors)
|
||||
end
|
||||
|
||||
if vm_provisioner.config
|
||||
provisioner_errors = vm_provisioner.config.validate(machine)
|
||||
|
|
|
@ -105,23 +105,27 @@ module VagrantPlugins
|
|||
@config.finalize!
|
||||
end
|
||||
|
||||
# TODO: This isn't being called
|
||||
#
|
||||
# @return [Array] array of strings of error messages from config option validation
|
||||
def validate(machine)
|
||||
errors = _detected_errors
|
||||
|
||||
if @before
|
||||
if @before.is_a?(Symbol) && !VALID_BEFORE_AFTER_TYPES.include?(@before)
|
||||
errors << "Before symbol is not a valid symbol"
|
||||
errors << I18n.t("vagrant.provisioners.base.invalid_alias_value", opt: "before", alias: VALID_BEFORE_AFTER_TYPES.join(", "))
|
||||
elsif !@before.is_a?(String) && !VALID_BEFORE_AFTER_TYPES.include?(@before)
|
||||
errors << I18n.t("vagrant.provisioners.base.wrong_type", opt: "before")
|
||||
end
|
||||
end
|
||||
|
||||
if @after
|
||||
if @after.is_a?(Symbol) && !VALID_BEFORE_AFTER_TYPES.include?(@after)
|
||||
errors << "After symbol is not a valid symbol"
|
||||
errors << I18n.t("vagrant.provisioners.base.invalid_alias_value", opt: "after", alias: VALID_BEFORE_AFTER_TYPES.join(", "))
|
||||
elsif !@after.is_a?(String) && !VALID_BEFORE_AFTER_TYPES.include?(@after)
|
||||
errors << I18n.t("vagrant.provisioners.base.wrong_type", opt: "after")
|
||||
end
|
||||
end
|
||||
|
||||
{"provisioner" => errors}
|
||||
end
|
||||
|
||||
# Returns whether the provisioner used was invalid or not. A provisioner
|
||||
|
|
|
@ -2486,6 +2486,11 @@ en:
|
|||
VirtualBox has successfully been installed!
|
||||
|
||||
provisioners:
|
||||
base:
|
||||
invalid_alias_value: |-
|
||||
Provisioner option `%{opt}` is not set as a valid type. Must be a string, or one of the alias shortcuts: %{alias}
|
||||
wrong_type: |-
|
||||
Provisioner option `%{opt}` is not set as a valid type. Must be a string.
|
||||
chef:
|
||||
chef_not_detected: |-
|
||||
The chef binary (either `chef-solo` or `chef-client`) was not found on
|
||||
|
|
Loading…
Reference in New Issue