Add machine for hook and action triggers
This commit is contained in:
parent
37d71898a3
commit
071d8b09cd
|
@ -17,7 +17,10 @@ module Vagrant
|
||||||
end
|
end
|
||||||
|
|
||||||
def call(env)
|
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
|
# Carry on
|
||||||
@app.call(env)
|
@app.call(env)
|
||||||
|
|
|
@ -14,7 +14,10 @@ module Vagrant
|
||||||
end
|
end
|
||||||
|
|
||||||
def call(env)
|
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
|
# Carry on
|
||||||
@app.call(env)
|
@app.call(env)
|
||||||
|
|
|
@ -40,8 +40,11 @@ module Vagrant
|
||||||
# the `env` is coming from, we can wait until they're merged into a single
|
# the `env` is coming from, we can wait until they're merged into a single
|
||||||
# hash above.
|
# hash above.
|
||||||
env = environment[:env]
|
env = environment[:env]
|
||||||
|
machine = environment[:machine]
|
||||||
|
machine_name = machine.name if machine
|
||||||
|
|
||||||
ui = Vagrant::UI::Prefixed.new(env.ui, "vargant")
|
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
|
end
|
||||||
|
|
||||||
# Setup the action hooks
|
# Setup the action hooks
|
||||||
|
@ -73,13 +76,14 @@ module Vagrant
|
||||||
end
|
end
|
||||||
|
|
||||||
action_name = environment[:action_name]
|
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
|
# We place a process lock around every action that is called
|
||||||
@logger.info("Running action: #{environment[:action_name]} #{callable_id}")
|
@logger.info("Running action: #{environment[:action_name]} #{callable_id}")
|
||||||
Util::Busy.busy(int_callback) { callable.call(environment) }
|
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
|
# Return the environment in case there are things in there that
|
||||||
# the caller wants to use.
|
# the caller wants to use.
|
||||||
|
|
|
@ -26,8 +26,10 @@ module Vagrant
|
||||||
@env = env[:env]
|
@env = env[:env]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
machine = env[:machine]
|
||||||
|
machine_name = machine.name if machine
|
||||||
ui = Vagrant::UI::Prefixed.new(@env.ui, "vargant")
|
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
|
end
|
||||||
|
|
||||||
@stack = []
|
@stack = []
|
||||||
|
|
|
@ -9,7 +9,7 @@ module VagrantPlugins
|
||||||
# Defaults
|
# Defaults
|
||||||
DEFAULT_ON_ERROR = :halt
|
DEFAULT_ON_ERROR = :halt
|
||||||
DEFAULT_EXIT_CODE = 0
|
DEFAULT_EXIT_CODE = 0
|
||||||
VALID_TRIGGER_TYPES = [:command, :action].freeze
|
VALID_TRIGGER_TYPES = [:command, :action, :hook].freeze
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
# Config class for a given Trigger
|
# Config class for a given Trigger
|
||||||
|
@ -227,7 +227,12 @@ module VagrantPlugins
|
||||||
|
|
||||||
if @type == :action
|
if @type == :action
|
||||||
actions = []
|
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
|
end
|
||||||
|
|
||||||
if @run
|
if @run
|
||||||
|
|
Loading…
Reference in New Issue