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

Markus Roberts Markus at reality.com
Wed Jul 14 10:37:50 UTC 2010


The following commit has been merged in the upstream branch:
commit 2edf7fe968ac3d8af9865f65100940747c1fa894
Author: Jesse Wolfe <jes5199 at gmail.com>
Date:   Tue Jul 13 14:01:24 2010 -0700

    [#3656] Serializing arrays of references
    
    My previous fix for #3656 missed the case where a "require" attribute
    (or other graph-ish attribute) had multiple values. This patch
    generalizes that fix to the multiple-value case.

diff --git a/lib/puppet/resource.rb b/lib/puppet/resource.rb
index 9894f2f..31237e3 100644
--- a/lib/puppet/resource.rb
+++ b/lib/puppet/resource.rb
@@ -60,11 +60,8 @@ class Puppet::Resource
 
       # Don't duplicate the title as the namevar
       next hash if param == namevar and value == title
-      if value.is_a? Puppet::Resource
-        hash[param] = value.to_s
-      else
-        hash[param] = value
-      end
+
+      hash[param] = Puppet::Resource.value_to_pson_data(value)
       hash
     end
 
@@ -73,6 +70,16 @@ class Puppet::Resource
     data
   end
 
+  def self.value_to_pson_data(value)
+    if value.is_a? Array
+      value.map{|v| value_to_pson_data(v) }
+    elsif value.is_a? Puppet::Resource
+      value.to_s
+    else
+      value
+    end
+  end
+
   def to_pson(*args)
     to_pson_data_hash.to_pson(*args)
   end
diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb
index aff3816..95f0dd0 100755
--- a/spec/unit/resource_spec.rb
+++ b/spec/unit/resource_spec.rb
@@ -687,6 +687,13 @@ describe Puppet::Resource do
       result = Puppet::Resource.from_pson(PSON.parse(resource.to_pson))
       result[:requires].should == "File[/bar]"
     end
+
+    it "should serialize multiple relationships as arrays of reference strings" do
+      resource = Puppet::Resource.new("File", "/foo")
+      resource[:requires] = [Puppet::Resource.new("File", "/bar"), Puppet::Resource.new("File", "/baz")]
+      result = Puppet::Resource.from_pson(PSON.parse(resource.to_pson))
+      result[:requires].should == [ "File[/bar]",  "File[/baz]" ]
+    end
   end
 
   describe "when converting from pson" do

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list