kernel/v2: allow provisioner plugins to register without config

This commit is contained in:
Paulo Bittencourt 2014-03-18 14:36:40 -04:00
parent 8770f9d060
commit 1f694d4978
2 changed files with 21 additions and 0 deletions

View File

@ -49,6 +49,7 @@ module VagrantPlugins
if !@config_class if !@config_class
@logger.info( @logger.info(
"Provisioner config for '#{@name}' not found. Ignoring config.") "Provisioner config for '#{@name}' not found. Ignoring config.")
@config_class = Vagrant::Config::V2::DummyConfig
end end
end end

View File

@ -3,6 +3,8 @@ require File.expand_path("../../../../base", __FILE__)
require Vagrant.source_root.join("plugins/kernel_v2/config/vm") require Vagrant.source_root.join("plugins/kernel_v2/config/vm")
describe VagrantPlugins::Kernel_V2::VMConfig do describe VagrantPlugins::Kernel_V2::VMConfig do
include_context "unit"
subject { described_class.new } subject { described_class.new }
let(:machine) { double("machine") } let(:machine) { double("machine") }
@ -210,6 +212,24 @@ describe VagrantPlugins::Kernel_V2::VMConfig do
expect(r[0]).to be_invalid expect(r[0]).to be_invalid
end end
it "allows provisioners that don't define any config" do
register_plugin("2") do |p|
p.name "foo"
# This plugin registers a dummy provisioner
# without registering a provisioner config
p.provisioner(:foo) do
Class.new Vagrant::plugin("2", :provisioner)
end
end
subject.provision("foo") do |c|
c.bar = "baz"
end
# This should succeed without errors
expect{ subject.finalize! }.to_not raise_error
end
describe "merging" do describe "merging" do
it "copies the configs" do it "copies the configs" do
subject.provision("shell", inline: "foo") subject.provision("shell", inline: "foo")