diff --git a/lib/vagrant/action/builtin/after_trigger.rb b/lib/vagrant/action/builtin/after_trigger.rb index 1cf499335..106d10df1 100644 --- a/lib/vagrant/action/builtin/after_trigger.rb +++ b/lib/vagrant/action/builtin/after_trigger.rb @@ -17,7 +17,10 @@ module Vagrant end def call(env) - @triggers.fire_triggers(@action_name, :after, nil, :action) if Vagrant::Util::Experimental.feature_enabled?("typed_triggers"); + machine = env[:machine] + machine_name = machine.name if machine + + @triggers.fire_triggers(@action_name, :after, machine_name, :action) if Vagrant::Util::Experimental.feature_enabled?("typed_triggers"); # Carry on @app.call(env) diff --git a/lib/vagrant/action/builtin/before_trigger.rb b/lib/vagrant/action/builtin/before_trigger.rb index 0f52f8616..fad2e5799 100644 --- a/lib/vagrant/action/builtin/before_trigger.rb +++ b/lib/vagrant/action/builtin/before_trigger.rb @@ -14,7 +14,10 @@ module Vagrant end def call(env) - @triggers.fire_triggers(@action_name, :before, nil, :action) if Vagrant::Util::Experimental.feature_enabled?("typed_triggers"); + machine = env[:machine] + machine_name = machine.name if machine + + @triggers.fire_triggers(@action_name, :before, machine_name, :action) if Vagrant::Util::Experimental.feature_enabled?("typed_triggers"); # Carry on @app.call(env) diff --git a/lib/vagrant/action/runner.rb b/lib/vagrant/action/runner.rb index 6698cd702..fb70fa317 100644 --- a/lib/vagrant/action/runner.rb +++ b/lib/vagrant/action/runner.rb @@ -40,8 +40,11 @@ module Vagrant # the `env` is coming from, we can wait until they're merged into a single # hash above. env = environment[:env] + machine = environment[:machine] + machine_name = machine.name if machine + ui = Vagrant::UI::Prefixed.new(env.ui, "vargant") - triggers = Vagrant::Plugin::V2::Trigger.new(env, env.vagrantfile.config.trigger, nil, ui) + triggers = Vagrant::Plugin::V2::Trigger.new(env, env.vagrantfile.config.trigger, machine, ui) end # Setup the action hooks @@ -73,13 +76,14 @@ module Vagrant end action_name = environment[:action_name] - triggers.fire_triggers(action_name, :before, nil, :action) if Vagrant::Util::Experimental.feature_enabled?("typed_triggers") + + triggers.fire_triggers(action_name, :before, machine_name, :hook) if Vagrant::Util::Experimental.feature_enabled?("typed_triggers") # We place a process lock around every action that is called @logger.info("Running action: #{environment[:action_name]} #{callable_id}") Util::Busy.busy(int_callback) { callable.call(environment) } - triggers.fire_triggers(action_name, :after, nil, :action) if Vagrant::Util::Experimental.feature_enabled?("typed_triggers") + triggers.fire_triggers(action_name, :after, machine_name, :hook) if Vagrant::Util::Experimental.feature_enabled?("typed_triggers") # Return the environment in case there are things in there that # the caller wants to use. diff --git a/lib/vagrant/action/warden.rb b/lib/vagrant/action/warden.rb index 06be1a027..6b7370cc1 100644 --- a/lib/vagrant/action/warden.rb +++ b/lib/vagrant/action/warden.rb @@ -26,8 +26,10 @@ module Vagrant @env = env[:env] end + machine = env[:machine] + machine_name = machine.name if machine ui = Vagrant::UI::Prefixed.new(@env.ui, "vargant") - @triggers = Vagrant::Plugin::V2::Trigger.new(@env, @env.vagrantfile.config.trigger, nil, ui) + @triggers = Vagrant::Plugin::V2::Trigger.new(@env, @env.vagrantfile.config.trigger, machine, ui) end @stack = [] diff --git a/plugins/kernel_v2/config/vm_trigger.rb b/plugins/kernel_v2/config/vm_trigger.rb index d3d237622..32273f2ac 100644 --- a/plugins/kernel_v2/config/vm_trigger.rb +++ b/plugins/kernel_v2/config/vm_trigger.rb @@ -9,7 +9,7 @@ module VagrantPlugins # Defaults DEFAULT_ON_ERROR = :halt DEFAULT_EXIT_CODE = 0 - VALID_TRIGGER_TYPES = [:command, :action].freeze + VALID_TRIGGER_TYPES = [:command, :action, :hook].freeze #------------------------------------------------------------------- # Config class for a given Trigger @@ -227,7 +227,12 @@ module VagrantPlugins if @type == :action actions = [] - # Get every registered action hook and check if it includes the command defined + # TODO: Get every registered action and check if it includes the command defined + end + + if @type == :hook + actions = [] + # TODO: Get every registered hook and check if it includes the command defined end if @run