diff options
-rw-r--r-- | lib/puppet/resource/type.rb | 6 | ||||
-rwxr-xr-x | spec/unit/resource/type.rb | 8 |
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/puppet/resource/type.rb b/lib/puppet/resource/type.rb index 3657f89b5..627a1d5a2 100644 --- a/lib/puppet/resource/type.rb +++ b/lib/puppet/resource/type.rb @@ -204,7 +204,11 @@ class Puppet::Resource::Type # Even if 'default' is a false value, it's an AST value, so this works fine fail Puppet::ParseError, "Must pass #{param} to #{resource.ref}" unless default - scope.setvar(param.to_s, default.safeevaluate(scope)) + value = default.safeevaluate(scope) + scope.setvar(param.to_s, value) + + # Set it in the resource, too, so the value makes it to the client. + resource[param] = value end scope.setvar("title", resource.title) unless set.include? :title diff --git a/spec/unit/resource/type.rb b/spec/unit/resource/type.rb index 27c53936d..cd1881f8c 100755 --- a/spec/unit/resource/type.rb +++ b/spec/unit/resource/type.rb @@ -290,6 +290,14 @@ describe Puppet::Resource::Type do @scope.lookupvar("foo").should == "something" end + it "should set all default values as parameters in the resource" do + @type.set_arguments :foo => stub("value", :safeevaluate => "something") + + @type.set_resource_parameters(@resource, @scope) + + @resource[:foo].should == "something" + end + it "should fail if the resource does not provide a value for a required argument" do @type.set_arguments :foo => nil @resource.expects(:to_hash).returns({}) |