[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:03 UTC 2010
The following commit has been merged in the upstream branch:
commit f66095d35bc5f9645eb19bbb8cefa342c0181d2d
Author: Jesse Wolfe <jes5199 at gmail.com>
Date: Mon Apr 26 18:14:51 2010 -0700
Fix #3656 JSON serialization of dependencies
The pson serialization of resources was behaving incorrectly on
parameters that are references to other resources:
1. Dependency parameters (require, subscribe, notify) were getting
serialized as anonymous objects that looked like partially constructed
resources
2. During de-serialization the pson parser would inflate them
into hashes (rather than into resources)
3. The outer resource would try to coerce the hash into a resource by
passing it to Resource.new
4. Resource.new would fail with a cryptic message, since it does not
accept a hash as its first parameter (but the error is obfuscated by
Resource.new's complicated argument handler)
This patch solves the problem by explicitly converting dependency
parameters into strings in the pson serialization.
Signed-off-by: Jesse Wolfe <jes5199 at gmail.com>
diff --git a/lib/puppet/resource.rb b/lib/puppet/resource.rb
index f991f53..d2979f9 100644
--- a/lib/puppet/resource.rb
+++ b/lib/puppet/resource.rb
@@ -60,7 +60,11 @@ class Puppet::Resource
# Don't duplicate the title as the namevar
next hash if param == namevar and value == title
- hash[param] = value
+ if value.is_a? Puppet::Resource
+ hash[param] = value.to_s
+ else
+ hash[param] = value
+ end
hash
end
diff --git a/spec/unit/resource.rb b/spec/unit/resource.rb
index 0eacd0b..3840db5 100755
--- a/spec/unit/resource.rb
+++ b/spec/unit/resource.rb
@@ -664,6 +664,13 @@ describe Puppet::Resource do
result["foo"].should == %w{bar eh}
result["fee"].should == %w{baz}
end
+
+ it "should serialize relationships as reference strings" do
+ resource = Puppet::Resource.new("File", "/foo")
+ resource[:requires] = Puppet::Resource.new("File", "/bar")
+ result = Puppet::Resource.from_pson(PSON.parse(resource.to_pson))
+ result[:requires].should == "File[/bar]"
+ end
end
describe "when converting from pson" do
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list