diff options
author | Markus Roberts <Markus@reality.com> | 2010-10-23 08:26:24 -0700 |
---|---|---|
committer | Markus Roberts <Markus@reality.com> | 2010-10-27 14:26:55 -0700 |
commit | 31118fe85aca4ee46903b17a3eb7aee07b8c0d69 (patch) | |
tree | d696d843d4e77bbe6f01189c1c6d59ca2b8f2ef5 /lib/puppet/resource.rb | |
parent | 65ef24e5c1c33b7d42012891d368917fd6aaf68c (diff) | |
download | puppet-31118fe85aca4ee46903b17a3eb7aee07b8c0d69.tar.gz puppet-31118fe85aca4ee46903b17a3eb7aee07b8c0d69.tar.xz puppet-31118fe85aca4ee46903b17a3eb7aee07b8c0d69.zip |
Kludge for #5048 -- serialization compatibility with 0.25.x
In 0.25.x the type & title of a resource were wrapped in a Puppet::Resource::Reference
object whereas in 2.6.x they are attributes of the resource itself without the
additional indirection (see 7089446697ad550c22012bc2b5572030727d67e1).
When pson serialization is used this isn’t a problem but with formats in which
we just blindly emit the structure either because we have no choice (marshal)
or because we just use the default (yaml) it is a compatibility-breaking change.
This patch resoloves the problem by adding a dummy reference object to cause
the "correct" serialization; it is intended as a stop-gap for 2.6.x and should
NOT be merged into next.
Diffstat (limited to 'lib/puppet/resource.rb')
-rw-r--r-- | lib/puppet/resource.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/puppet/resource.rb b/lib/puppet/resource.rb index 39803b077..7dea270e8 100644 --- a/lib/puppet/resource.rb +++ b/lib/puppet/resource.rb @@ -154,6 +154,14 @@ class Puppet::Resource end end + # This stub class is only needed for serialization compatibility with 0.25.x + class Reference + attr_accessor :type,:title + def initialize(type,title) + @type,@title = type,title + end + end + # Create our resource. def initialize(type, title = nil, attributes = {}) @parameters = {} @@ -180,6 +188,8 @@ class Puppet::Resource tag(self.type) tag(self.title) if valid_tag?(self.title) + @reference = Reference.new(@type,@title) # for serialization compatibility with 0.25.x + raise ArgumentError, "Invalid resource type #{type}" if strict? and ! resource_type end |