produce error when node_path is defined but the directory does not exist on disk locally

This commit is contained in:
Eugenio Marzo 2017-07-22 11:00:05 +02:00
parent 94a94648dd
commit c9b65bd129
3 changed files with 20 additions and 0 deletions

View File

@ -79,6 +79,13 @@ module VagrantPlugins
if !present?(Array(nodes_path))
errors << I18n.t("vagrant.config.chef.nodes_path_empty")
else
missing_paths = Array.new
nodes_path.each { |dir| missing_paths << dir[1] if !File.exists? dir[1] }
# If it exists at least one path on disk it's ok for Chef provisioning
if missing_paths.size == nodes_path.size
errors << I18n.t("vagrant.config.chef.nodes_path_missing", path: missing_paths.to_s)
end
end
if environment && environments_path.empty?

View File

@ -1579,6 +1579,8 @@ en:
Missing required value for `chef.nodes_path'.
environment_path_missing: |-
Environment path not found: %{path}
nodes_path_missing: |-
Path specified for `nodes_path` does not exist: %{path}
environment_path_required: |-
When 'environment' is specified, you must provide 'environments_path'.
cookbooks_path_missing: |-

View File

@ -110,6 +110,17 @@ describe VagrantPlugins::Chef::Config::ChefZero do
end
end
context "when an element of nodes_path does not exist on disk" do
it "returns an error" do
nodes_path = ["/path/to/nodes/that/will/never/exist"]
subject.nodes_path = nodes_path
subject.finalize!
expect(errors).to include(I18n.t("vagrant.config.chef.nodes_path_missing",
path: nodes_path
))
end
end
context "when the nodes_path is an empty array" do
it "returns an error" do
subject.nodes_path = []