From 57c4de49f2f328fb3f23d197ffc4ef3297f59214 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Mon, 13 May 2019 13:26:47 -0700 Subject: [PATCH 1/2] Remove "command" string from logger Since not all triggers are commands, removing the word `command` from the logger so it is not confused with other types of triggers. --- plugins/kernel_v2/config/vm_trigger.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/kernel_v2/config/vm_trigger.rb b/plugins/kernel_v2/config/vm_trigger.rb index 644eabe8a..2595eea49 100644 --- a/plugins/kernel_v2/config/vm_trigger.rb +++ b/plugins/kernel_v2/config/vm_trigger.rb @@ -117,7 +117,7 @@ module VagrantPlugins @command = command.to_sym @ruby_block = UNSET_VALUE - @logger.debug("Trigger defined for command: #{command}") + @logger.debug("Trigger defined for: #{command}") end # Config option `ruby` for a trigger which reads in a ruby block and sets From eb3e309f8904d472aafdc592fe0f253fd3fa3438 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Mon, 13 May 2019 14:07:22 -0700 Subject: [PATCH 2/2] Ensure guest names are string when filtering Prior to this commit, if a guest name was given as a symbol, the filter_triggers method would fail to properly match it with the only_on option, as it is not a valid type to the #String.match method. This commit fixes that by converting the parameter to a string so that it can be properly matched on the guest. --- lib/vagrant/plugin/v2/trigger.rb | 2 +- test/unit/vagrant/plugin/v2/trigger_test.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/vagrant/plugin/v2/trigger.rb b/lib/vagrant/plugin/v2/trigger.rb index ac2fb289d..ca6ea5a34 100644 --- a/lib/vagrant/plugin/v2/trigger.rb +++ b/lib/vagrant/plugin/v2/trigger.rb @@ -110,7 +110,7 @@ module Vagrant match = false if trigger.only_on trigger.only_on.each do |o| - if o.match(guest_name) + if o.match(guest_name.to_s) # trigger matches on current guest, so we're fine to use it match = true break diff --git a/test/unit/vagrant/plugin/v2/trigger_test.rb b/test/unit/vagrant/plugin/v2/trigger_test.rb index f4e0cac41..b39f7e30e 100644 --- a/test/unit/vagrant/plugin/v2/trigger_test.rb +++ b/test/unit/vagrant/plugin/v2/trigger_test.rb @@ -74,7 +74,7 @@ describe Vagrant::Plugin::V2::Trigger do after_triggers = triggers.after_triggers expect(after_triggers.size).to eq(3) - subject.send(:filter_triggers, after_triggers, "ubuntu", :action) + subject.send(:filter_triggers, after_triggers, :ubuntu, :action) expect(after_triggers.size).to eq(2) end