Properly handle empty/nil values in Chef Solo config
This commit is contained in:
parent
9c56061fa9
commit
af9177550a
|
@ -65,10 +65,14 @@ module VagrantPlugins
|
||||||
def validate(machine)
|
def validate(machine)
|
||||||
errors = _detected_errors
|
errors = _detected_errors
|
||||||
errors.concat(validate_base(machine))
|
errors.concat(validate_base(machine))
|
||||||
errors << I18n.t("vagrant.config.chef.cookbooks_path_empty") if \
|
|
||||||
!cookbooks_path || [cookbooks_path].flatten.empty?
|
if [cookbooks_path].flatten.compact.empty?
|
||||||
errors << I18n.t("vagrant.config.chef.environment_path_required") if \
|
errors << I18n.t("vagrant.config.chef.cookbooks_path_empty")
|
||||||
environment && environments_path.empty?
|
end
|
||||||
|
|
||||||
|
if environment && environments_path.empty?
|
||||||
|
errors << I18n.t("vagrant.config.chef.environment_path_required")
|
||||||
|
end
|
||||||
|
|
||||||
environments_path.each do |type, raw_path|
|
environments_path.each do |type, raw_path|
|
||||||
next if type != :host
|
next if type != :host
|
||||||
|
@ -76,7 +80,8 @@ module VagrantPlugins
|
||||||
path = Pathname.new(raw_path).expand_path(machine.env.root_path)
|
path = Pathname.new(raw_path).expand_path(machine.env.root_path)
|
||||||
if !path.directory?
|
if !path.directory?
|
||||||
errors << I18n.t("vagrant.config.chef.environment_path_missing",
|
errors << I18n.t("vagrant.config.chef.environment_path_missing",
|
||||||
path: raw_path.to_s)
|
path: raw_path.to_s
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -93,6 +98,8 @@ module VagrantPlugins
|
||||||
# Make sure the path is an array
|
# Make sure the path is an array
|
||||||
config = [config] if !config.is_a?(Array) || config.first.is_a?(Symbol)
|
config = [config] if !config.is_a?(Array) || config.first.is_a?(Symbol)
|
||||||
|
|
||||||
|
return [] if config.flatten.compact.empty?
|
||||||
|
|
||||||
# Make sure all the paths are in the proper format
|
# Make sure all the paths are in the proper format
|
||||||
config.map do |path|
|
config.map do |path|
|
||||||
path = [:host, path] if !path.is_a?(Array)
|
path = [:host, path] if !path.is_a?(Array)
|
||||||
|
|
Loading…
Reference in New Issue