We were previously just adding these values as variables in the local scope, but we now add them to the resources so they get passed to the client in the catalog and are thus inspectable.
Signed-off-by: Luke Kanies <[email protected]> --- lib/puppet/resource/type.rb | 6 +++++- 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 402df06..296dc05 100644 --- a/lib/puppet/resource/type.rb +++ b/lib/puppet/resource/type.rb @@ -171,7 +171,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 094d80b..4f42908 100755 --- a/spec/unit/resource/type.rb +++ b/spec/unit/resource/type.rb @@ -249,6 +249,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({}) -- 1.6.1 -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
