From 5e42a99ab6cd1f98dd88f625354b309d81a083ec Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 18 Jan 2013 13:06:29 -0800 Subject: [PATCH] Update shell provisioner to latest validation api --- plugins/provisioners/shell/config.rb | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/plugins/provisioners/shell/config.rb b/plugins/provisioners/shell/config.rb index ef5d10a3e..6c9e4d223 100644 --- a/plugins/provisioners/shell/config.rb +++ b/plugins/provisioners/shell/config.rb @@ -10,32 +10,36 @@ module VagrantPlugins @upload_path = "/tmp/vagrant-shell" end - def validate(env, errors) + def validate(machine) + errors = [] + # Validate that the parameters are properly set if path && inline - errors.add(I18n.t("vagrant.provisioners.shell.path_and_inline_set")) + errors << I18n.t("vagrant.provisioners.shell.path_and_inline_set") elsif !path && !inline - errors.add(I18n.t("vagrant.provisioners.shell.no_path_or_inline")) + errors << I18n.t("vagrant.provisioners.shell.no_path_or_inline") end # Validate the existence of a script to upload if path - expanded_path = Pathname.new(path).expand_path(env.root_path) + expanded_path = Pathname.new(path).expand_path(machine.env.root_path) if !expanded_path.file? - errors.add(I18n.t("vagrant.provisioners.shell.path_invalid", - :path => expanded_path)) + errors << I18n.t("vagrant.provisioners.shell.path_invalid", + :path => expanded_path) end end # There needs to be a path to upload the script to if !upload_path - errors.add(I18n.t("vagrant.provisioners.shell.upload_path_not_set")) + errors << I18n.t("vagrant.provisioners.shell.upload_path_not_set") end # If there are args and its not a string, that is a problem if args && !args.is_a?(String) - errors.add(I18n.t("vagrant.provisioners.shell.args_not_string")) + errors << I18n.t("vagrant.provisioners.shell.args_not_string") end + + { "shell provisioner" => errors } end end end