core: allow custom callables in hooks
This commit is contained in:
parent
ec5727dfe0
commit
8d99382993
|
@ -62,10 +62,11 @@ module Vagrant
|
|||
if enabled
|
||||
type_map = provisioner_type_map(env)
|
||||
provisioner_instances(env).each do |p|
|
||||
type_name = type_map[p]
|
||||
next if env[:provision_types] && \
|
||||
!env[:provision_types].include?(type_map[p])
|
||||
!env[:provision_types].include?(type_name)
|
||||
|
||||
run_provisioner(env, type_map[p].to_s, p)
|
||||
run_provisioner(env, type_name.to_s, p)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -275,12 +275,12 @@ module Vagrant
|
|||
# @param [Action::Runner] action_runner A custom action runner for running hooks.
|
||||
def hook(name, opts=nil)
|
||||
@logger.info("Running hook: #{name}")
|
||||
callable = Action::Builder.new
|
||||
opts ||= {}
|
||||
opts[:callable] ||= Action::Builder.new
|
||||
opts[:runner] ||= action_runner
|
||||
opts[:action_name] = name
|
||||
opts[:env] = self
|
||||
opts.delete(:runner).run(callable, opts)
|
||||
opts.delete(:runner).run(opts.delete(:callable), opts)
|
||||
end
|
||||
|
||||
# This returns a machine with the proper provider for this environment.
|
||||
|
|
|
@ -324,6 +324,14 @@ describe Vagrant::Environment do
|
|||
|
||||
instance.hook(:foo, foo: :bar)
|
||||
end
|
||||
|
||||
it "should allow passing a custom callable" do
|
||||
instance.action_runner.should_receive(:run).with do |callable, env|
|
||||
callable.should == :what
|
||||
end
|
||||
|
||||
instance.hook(:foo, callable: :what)
|
||||
end
|
||||
end
|
||||
|
||||
describe "primary machine name" do
|
||||
|
|
Loading…
Reference in New Issue