Action runner supports global parameters

This commit is contained in:
Mitchell Hashimoto 2011-12-09 14:44:43 -08:00
parent bbb8f0ac2c
commit b31c3d458c
2 changed files with 14 additions and 1 deletions

View File

@ -11,8 +11,9 @@ module Vagrant
class Runner
@@reported_interrupt = false
def initialize(registry)
def initialize(registry, globals=nil)
@registry = registry
@globals = globals || {}
@logger = Log4r::Logger.new("vagrant::action::runner")
end
@ -24,6 +25,7 @@ module Vagrant
# Create the initial environment with the options given
environment = Environment.new
environment.merge!(@globals)
environment.merge!(options || {})
# Run the action chain in a busy block, marking the environment as

View File

@ -40,4 +40,15 @@ describe Vagrant::Action::Runner do
instance.run(callable, "data" => "foo")
result.should == "foo"
end
it "should pass global options into the hash" do
result = nil
callable = lambda do |env|
result = env["data"]
end
instance = described_class.new(registry, "data" => "bar")
instance.run(callable)
result.should == "bar"
end
end