summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2010-11-04 22:26:28 -0700
committerJames Turnbull <james@lovedthanlost.net>2010-11-10 05:31:33 +1100
commitec667fd53f9f611641755d086f09cbc61b1ca203 (patch)
tree75ff50b5439a70b81633fe59574566556c07d0a7 /lib/puppet
parent9a3b5849c54c3f354670b5a912fd393f7010977e (diff)
downloadpuppet-ec667fd53f9f611641755d086f09cbc61b1ca203.tar.gz
puppet-ec667fd53f9f611641755d086f09cbc61b1ca203.tar.xz
puppet-ec667fd53f9f611641755d086f09cbc61b1ca203.zip
Kludge for #5206 -- port of fix for #3536 to yaml
The internal format of parameters was changed between 0.25.x and 2.6.x, making them incompatible when serialized. This was fixed for PSON under ticket #3656 (by modifying the data as it was serialized) in: commit f66095d35bc5f9645eb19bbb8cefa342c0181d2d and commit 2edf7fe968ac3d8af9865f65100940747c1fa894 but nothing was done about the other serialization formats. This commit adds a callback to zaml property serialization and uses it to route data through the fixup method added in the commits above, thus fixing the problem "the same way" as it was fixed for PSON under #3656. It does nothing about marshal, mostly because I have not totaly gone over to the dark side (yet).
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/resource.rb12
-rw-r--r--lib/puppet/util/zaml.rb5
2 files changed, 16 insertions, 1 deletions
diff --git a/lib/puppet/resource.rb b/lib/puppet/resource.rb
index 7dea270e8..4f0d50750 100644
--- a/lib/puppet/resource.rb
+++ b/lib/puppet/resource.rb
@@ -80,6 +80,18 @@ class Puppet::Resource
end
end
+ def yaml_property_munge(x)
+ case x
+ when Hash
+ x.inject({}) { |h,kv|
+ k,v = kv
+ h[k] = self.class.value_to_pson_data(v)
+ h
+ }
+ else self.class.value_to_pson_data(x)
+ end
+ end
+
def to_pson(*args)
to_pson_data_hash.to_pson(*args)
end
diff --git a/lib/puppet/util/zaml.rb b/lib/puppet/util/zaml.rb
index 64c58f9a3..9fda5ae3b 100644
--- a/lib/puppet/util/zaml.rb
+++ b/lib/puppet/util/zaml.rb
@@ -120,6 +120,9 @@ class Object
def to_yaml_properties
instance_variables.sort # Default YAML behavior
end
+ def yaml_property_munge(x)
+ x
+ end
def zamlized_class_name(root)
cls = self.class
"!ruby/#{root.name.downcase}#{cls == root ? '' : ":#{cls.respond_to?(:name) ? cls.name : cls}"}"
@@ -136,7 +139,7 @@ class Object
z.nl
v[1..-1].to_zaml(z) # Remove leading '@'
z.emit(': ')
- instance_variable_get(v).to_zaml(z)
+ yaml_property_munge(instance_variable_get(v)).to_zaml(z)
}
end
}