Ensure run & run_remote are Hashes before updating to shell config

This commit is contained in:
Brian Cain 2018-03-16 14:38:11 -07:00
parent e752878de9
commit 60c4ffa8a6
No known key found for this signature in database
GPG Key ID: 43D51080D357A001
1 changed files with 14 additions and 2 deletions

View File

@ -111,14 +111,14 @@ module VagrantPlugins
end end
# Convert @run and @run_remote to be a "Shell provisioner" config # Convert @run and @run_remote to be a "Shell provisioner" config
if @run if @run && @run.is_a?(Hash)
new_run = VagrantPlugins::Shell::Config.new() new_run = VagrantPlugins::Shell::Config.new()
new_run.set_options(@run) new_run.set_options(@run)
new_run.finalize! new_run.finalize!
@run = new_run @run = new_run
end end
if @run_remote if @run_remote && @run_remote.is_a?(Hash)
new_run = VagrantPlugins::Shell::Config.new() new_run = VagrantPlugins::Shell::Config.new()
new_run.set_options(@run_remote) new_run.set_options(@run_remote)
new_run.finalize! new_run.finalize!
@ -135,6 +135,18 @@ module VagrantPlugins
commands.push(key) commands.push(key)
end end
# TODO: Does it make sense to strip out the "shell provisioner" error key here?
# We could add more context around triggers?
if @run
errorz = @run.validate(machine)
errors.concat errorz["shell provisioner"] if !errorz.empty?
end
if @run_remote
errorz = @run_remote.validate(machine)
errors.concat errorz["shell provisioner"] if !errorz.empty?
end
if !commands.include?(@command) if !commands.include?(@command)
machine.ui.warn(I18n.t("vagrant.config.triggers.bad_command_warning", machine.ui.warn(I18n.t("vagrant.config.triggers.bad_command_warning",
cmd: @command)) cmd: @command))