From 60c4ffa8a618f200a7ce93529a7aafb52df49320 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Fri, 16 Mar 2018 14:38:11 -0700 Subject: [PATCH] Ensure run & run_remote are Hashes before updating to shell config --- plugins/kernel_v2/config/vm_trigger.rb | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/plugins/kernel_v2/config/vm_trigger.rb b/plugins/kernel_v2/config/vm_trigger.rb index 9c45fbf8a..2e95c496a 100644 --- a/plugins/kernel_v2/config/vm_trigger.rb +++ b/plugins/kernel_v2/config/vm_trigger.rb @@ -111,14 +111,14 @@ module VagrantPlugins end # 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.set_options(@run) new_run.finalize! @run = new_run end - if @run_remote + if @run_remote && @run_remote.is_a?(Hash) new_run = VagrantPlugins::Shell::Config.new() new_run.set_options(@run_remote) new_run.finalize! @@ -135,6 +135,18 @@ module VagrantPlugins commands.push(key) 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) machine.ui.warn(I18n.t("vagrant.config.triggers.bad_command_warning", cmd: @command))