[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:36:40 UTC 2010
The following commit has been merged in the upstream branch:
commit 4b00c6af911b447265fc3e7ab19bb076840bfef1
Author: Jesse Wolfe <jes5199 at gmail.com>
Date: Wed Jul 7 09:36:27 2010 -0700
[#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 at gmail.com>
diff --git a/lib/puppet/transaction/resource_harness.rb b/lib/puppet/transaction/resource_harness.rb
index ae38bcb..848ba7b 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 6e553d4..57caf1d 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 e79bc0a..b2185b6 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 136b691..0080846 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
diff --git a/spec/unit/type_spec.rb b/spec/unit/type_spec.rb
index 54fb297..70597f7 100755
--- a/spec/unit/type_spec.rb
+++ b/spec/unit/type_spec.rb
@@ -368,11 +368,11 @@ describe Puppet::Type do
it "should fail if its provider is unsuitable" do
@resource = Puppet::Type.type(:mount).new(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present)
@resource.provider.class.expects(:suitable?).returns false
- lambda { @resource.retrieve }.should raise_error(Puppet::Error)
+ lambda { @resource.retrieve_resource }.should raise_error(Puppet::Error)
end
it "should return a Puppet::Resource instance with its type and title set appropriately" do
- result = @resource.retrieve
+ result = @resource.retrieve_resource
result.should be_instance_of(Puppet::Resource)
result.type.should == "Mount"
result.title.should == "foo"
@@ -381,11 +381,11 @@ describe Puppet::Type do
it "should set the name of the returned resource if its own name and title differ" do
@resource[:name] = "my name"
@resource.title = "other name"
- @resource.retrieve[:name].should == "my name"
+ @resource.retrieve_resource[:name].should == "my name"
end
it "should provide a value for all set properties" do
- values = @resource.retrieve
+ values = @resource.retrieve_resource
[:ensure, :fstype, :pass].each { |property| values[property].should_not be_nil }
end
@@ -396,13 +396,13 @@ describe Puppet::Type do
it "should not call retrieve on non-ensure properties if the resource is absent and should consider the property absent" do
@resource.property(:ensure).expects(:retrieve).returns :absent
@resource.property(:fstype).expects(:retrieve).never
- @resource.retrieve[:fstype].should == :absent
+ @resource.retrieve_resource[:fstype].should == :absent
end
it "should include the result of retrieving each property's current value if the resource is present" do
@resource.property(:ensure).expects(:retrieve).returns :present
@resource.property(:fstype).expects(:retrieve).returns 15
- @resource.retrieve[:fstype] == 15
+ @resource.retrieve_resource[:fstype] == 15
end
end
diff --git a/test/ral/type/mailalias.rb b/test/ral/type/mailalias.rb
index 5d5023a..ff0e62e 100755
--- a/test/ral/type/mailalias.rb
+++ b/test/ral/type/mailalias.rb
@@ -34,7 +34,7 @@ class TestMailAlias < Test::Unit::TestCase
# This isn't much of a test, but then, it's not much of a type.
def test_recipient_arrays
resource = @type.new(:name => "luke", :recipient => "yay", :target => tempfile)
- values = resource.retrieve
+ values = resource.retrieve_resource
assert_equal(:absent, values[:recipient])
resource.property(:recipient).expects(:set).with(%w{yay})
assert_nothing_raised("Could not sync mailalias") do
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list