[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.5-639-g8f94f35

test branch puppet-dev at googlegroups.com
Wed Jul 14 10:33:38 UTC 2010


The following commit has been merged in the upstream branch:
commit 89e8745e8c5c69775f8e1f680dceb39ba7a985ee
Author: Luke Kanies <luke at puppetlabs.com>
Date:   Mon May 17 12:22:31 2010 -0700

    Fixing #2655 - Adding default parameter values to resources
    
    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 <luke at puppetlabs.com>

diff --git a/lib/puppet/resource/type.rb b/lib/puppet/resource/type.rb
index 3657f89..627a1d5 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 27c5393..cd1881f 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({})

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list