diff options
author | Jesse Wolfe <jes5199@gmail.com> | 2010-07-07 09:36:27 -0700 |
---|---|---|
committer | Markus Roberts <Markus@reality.com> | 2010-07-07 11:14:51 -0700 |
commit | 4b00c6af911b447265fc3e7ab19bb076840bfef1 (patch) | |
tree | 08453970292d9c6e4ddd67d3ac31562d236ce3e9 /lib/puppet | |
parent | 5f8a2424bcd4f78e71963060b375e12167c7bbef (diff) | |
download | puppet-4b00c6af911b447265fc3e7ab19bb076840bfef1.tar.gz puppet-4b00c6af911b447265fc3e7ab19bb076840bfef1.tar.xz puppet-4b00c6af911b447265fc3e7ab19bb076840bfef1.zip |
[#4110] Wrap Type#retrieve calls for backwards compatibility
This patch introduces Type#retrieve_resource as a wrapper for
Type#resource, to coerce the return value from legacy types from Hash to
Resource.
Signed-off-by: Jesse Wolfe <jes5199@gmail.com>
Diffstat (limited to 'lib/puppet')
-rw-r--r-- | lib/puppet/transaction/resource_harness.rb | 2 | ||||
-rw-r--r-- | lib/puppet/type.rb | 12 | ||||
-rwxr-xr-x | lib/puppet/type/mount.rb | 2 | ||||
-rw-r--r-- | lib/puppet/type/resources.rb | 2 |
4 files changed, 12 insertions, 6 deletions
diff --git a/lib/puppet/transaction/resource_harness.rb b/lib/puppet/transaction/resource_harness.rb index ae38bcb66..848ba7b9a 100644 --- a/lib/puppet/transaction/resource_harness.rb +++ b/lib/puppet/transaction/resource_harness.rb @@ -38,7 +38,7 @@ class Puppet::Transaction::ResourceHarness end def changes_to_perform(status, resource) - current = resource.retrieve + current = resource.retrieve_resource cache resource, :checked, Time.now diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb index 6e553d463..57caf1d4f 100644 --- a/lib/puppet/type.rb +++ b/lib/puppet/type.rb @@ -743,6 +743,14 @@ class Type result end + def retrieve_resource + resource = retrieve + if resource.is_a? Hash + resource = Resource.new(type, title, :parameters => resource) + end + resource + end + # Get a hash of the current properties. Returns a hash with # the actual property instance as the key and the current value # as the, um, value. @@ -1924,10 +1932,8 @@ class Type def to_trans(ret = true) trans = TransObject.new(self.title, self.class.name) - values = retrieve() + values = retrieve_resource values.each do |name, value| - # sometimes we get symbols and sometimes we get Properties - # I think it's a bug, but I can't find it. ~JW name = name.name if name.respond_to? :name trans[name] = value end diff --git a/lib/puppet/type/mount.rb b/lib/puppet/type/mount.rb index e79bc0a4a..b2185b608 100755 --- a/lib/puppet/type/mount.rb +++ b/lib/puppet/type/mount.rb @@ -67,7 +67,7 @@ module Puppet def syncothers # We have to flush any changes to disk. - currentvalues = @resource.retrieve + currentvalues = @resource.retrieve_resource # Determine if there are any out-of-sync properties. oos = @resource.send(:properties).find_all do |prop| diff --git a/lib/puppet/type/resources.rb b/lib/puppet/type/resources.rb index 136b691c3..00808461b 100644 --- a/lib/puppet/type/resources.rb +++ b/lib/puppet/type/resources.rb @@ -131,7 +131,7 @@ Puppet::Type.newtype(:resources) do return true unless self[:unless_system_user] resource[:audit] = :uid - current_values = resource.retrieve + current_values = resource.retrieve_resource if system_users().include?(resource[:name]) return false |