Update shell provisioner to latest validation api

This commit is contained in:
Mitchell Hashimoto 2013-01-18 13:06:29 -08:00
parent e651eb3aa1
commit 5e42a99ab6
1 changed files with 12 additions and 8 deletions

View File

@ -10,32 +10,36 @@ module VagrantPlugins
@upload_path = "/tmp/vagrant-shell" @upload_path = "/tmp/vagrant-shell"
end end
def validate(env, errors) def validate(machine)
errors = []
# Validate that the parameters are properly set # Validate that the parameters are properly set
if path && inline 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 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 end
# Validate the existence of a script to upload # Validate the existence of a script to upload
if path 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? if !expanded_path.file?
errors.add(I18n.t("vagrant.provisioners.shell.path_invalid", errors << I18n.t("vagrant.provisioners.shell.path_invalid",
:path => expanded_path)) :path => expanded_path)
end end
end end
# There needs to be a path to upload the script to # There needs to be a path to upload the script to
if !upload_path 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 end
# If there are args and its not a string, that is a problem # If there are args and its not a string, that is a problem
if args && !args.is_a?(String) 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 end
{ "shell provisioner" => errors }
end end
end end
end end