Machine#action supports passing in extra env vars for action runner
This commit is contained in:
parent
984c4f4025
commit
a1145615d0
|
@ -70,7 +70,7 @@ module Vagrant
|
|||
# actually implement the action.
|
||||
#
|
||||
# @param [Symbol] name Name of the action to run.
|
||||
def action(name)
|
||||
def action(name, extra_env=nil)
|
||||
@logger.debug("Calling action: #{name} on provider #{@provider}")
|
||||
|
||||
# Get the callable from the provider.
|
||||
|
@ -85,7 +85,8 @@ module Vagrant
|
|||
end
|
||||
|
||||
# Run the action with the action runner on the environment
|
||||
@env.action_runner.run(callable, :machine => self)
|
||||
env = { :machine => self }.merge(extra_env || {})
|
||||
@env.action_runner.run(callable, env)
|
||||
end
|
||||
|
||||
# This sets the unique ID associated with this machine. This will
|
||||
|
|
|
@ -149,6 +149,17 @@ describe Vagrant::Machine do
|
|||
machine.should eql(instance)
|
||||
end
|
||||
|
||||
it "should pass any extra options to the environment" do
|
||||
action_name = :up
|
||||
foo = nil
|
||||
callable = lambda { |env| foo = env[:foo] }
|
||||
|
||||
provider.stub(:action).with(action_name).and_return(callable)
|
||||
instance.action(:up, :foo => :bar)
|
||||
|
||||
foo.should == :bar
|
||||
end
|
||||
|
||||
it "should raise an exception if the action is not implemented" do
|
||||
action_name = :up
|
||||
|
||||
|
|
Loading…
Reference in New Issue