From ac48d270eb184060a35713e934f4153fa33ed2aa Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 19 Jan 2012 19:48:57 -0800 Subject: [PATCH] Error if :vagrant is used as chef JSON key. [GH-661] --- CHANGELOG.md | 2 ++ lib/vagrant/provisioners/chef.rb | 6 ++++++ templates/locales/en.yml | 4 +++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4579b2b1..fd7adaf04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ determining VirtualBox version. [GH-658] - Debian/Ubuntu uses `ifdown` again, instead of `ifconfig xxx down`, since the behavior seems different/wrong. + - Give a nice error if `:vagrant` is used as a JSON key, since Vagrant + uses this. [GH-661] ## 0.9.1 (January 18, 2012) diff --git a/lib/vagrant/provisioners/chef.rb b/lib/vagrant/provisioners/chef.rb index 933505cf1..2df2d4f09 100644 --- a/lib/vagrant/provisioners/chef.rb +++ b/lib/vagrant/provisioners/chef.rb @@ -147,6 +147,12 @@ module Vagrant run_list << name end + def validate(env, errors) + super + + errors.add(I18n.t("vagrant.config.chef.vagrant_as_json_key")) if @json.has_key?(:vagrant) + end + def instance_variables_hash # Overridden so that the 'json' key could be removed, since its just # merged into the config anyways diff --git a/templates/locales/en.yml b/templates/locales/en.yml index cac2cb01c..331493914 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -188,9 +188,11 @@ en: common: error_empty: "`%{field}` must be filled in." chef: - run_list_empty: "Run list must not be empty." cookbooks_path_empty: "Must specify a cookbooks path for chef solo." + run_list_empty: "Run list must not be empty." server_url_empty: "Chef server URL must be populated." + vagrant_as_json_key: |- + `vagrant` cannot be a JSON key, because it is used by Vagrant already. validation_key_path: "Validation key path must be valid path to your chef server validation key." ssh: private_key_missing: "`private_key_path` file must exist: %{path}"