Support hash based options for provisioners
This commit is contained in:
parent
4e5a7aa6bf
commit
047f9970fe
|
@ -32,6 +32,15 @@ module Vagrant
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Allows setting options from a hash. By default this simply calls
|
||||||
|
# the `#{key}=` method on the config class with the value, which is
|
||||||
|
# the expected behavior most of the time.
|
||||||
|
def set_options(options)
|
||||||
|
options.each do |key, value|
|
||||||
|
send("#{key}=", value)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Called by {Top} after the configuration is loaded to validate
|
# Called by {Top} after the configuration is loaded to validate
|
||||||
# the configuaration objects. Subclasses should implement this
|
# the configuaration objects. Subclasses should implement this
|
||||||
# method and add any errors to the `errors` object given.
|
# method and add any errors to the `errors` object given.
|
||||||
|
|
|
@ -29,9 +29,8 @@ module Vagrant
|
||||||
|
|
||||||
# Instantiate the config class and configure it
|
# Instantiate the config class and configure it
|
||||||
@config = @provisioner.const_get(*const_args).new
|
@config = @provisioner.const_get(*const_args).new
|
||||||
|
@config.set_options(options) if options
|
||||||
block.call(@config) if block
|
block.call(@config) if block
|
||||||
|
|
||||||
# TODO: Deal with the options hash
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate(errors)
|
def validate(errors)
|
||||||
|
|
|
@ -38,6 +38,11 @@ class ConfigVMProvisionerTest < Test::Unit::TestCase
|
||||||
|
|
||||||
assert_equal "foo", instance.config.cookbooks_path
|
assert_equal "foo", instance.config.cookbooks_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "configure the provisioner with a hash if valid" do
|
||||||
|
instance = @klass.new(:chef_solo, :cookbooks_path => "foo")
|
||||||
|
assert_equal "foo", instance.config.cookbooks_path
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "validation" do
|
context "validation" do
|
||||||
|
|
Loading…
Reference in New Issue