[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 2.6.5-303-gfcfa26a

Jesse Wolfe jes5199 at gmail.com
Thu Mar 17 10:49:45 UTC 2011


The following commit has been merged in the upstream branch:
commit 9781032736a34f577241828bcf812a648b4f42e9
Author: Jesse Wolfe <jes5199 at gmail.com>
Date:   Tue Mar 15 17:28:52 2011 -0700

    Revert "Merge branch 'ticket/2.6.x/5605' of git://github.com/stschulte/puppet into 2.6.next"
    
    This reverts commit 658bdb72bee3ad664627a71793213e6540afd5cb, reversing
    changes made to 4c9bd43bc2f5fde9d86196e8689dced929d39aad.
    
    See comment at http://projects.puppetlabs.com/issues/5605#note-9

diff --git a/lib/puppet/resource.rb b/lib/puppet/resource.rb
index 0f4e24c..2145169 100644
--- a/lib/puppet/resource.rb
+++ b/lib/puppet/resource.rb
@@ -243,16 +243,11 @@ class Puppet::Resource
     h = self.to_hash
     h[namevar] ||= h[:name]
     h[:name]   ||= h[namevar]
-    # Simulate the same behaviour like Type#uniqueness_key
-    if key_attributes.size == 1
-      h[namevar]
-    else
-      h.values_at(*key_attributes)
-    end
+    h.values_at(*key_attributes.sort_by { |k| k.to_s })
   end
 
   def key_attributes
-    resource_type.respond_to?(:key_attributes) ? resource_type.key_attributes : [:name]
+    return(resource_type.respond_to? :key_attributes) ? resource_type.key_attributes : [:name]
   end
 
   # Convert our resource to Puppet code.
diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb
index 6c816f1..aa650ee 100644
--- a/lib/puppet/transaction.rb
+++ b/lib/puppet/transaction.rb
@@ -245,7 +245,7 @@ class Puppet::Transaction
     @catalog.vertices.each do |resource|
       if provider = resource.provider and provider.class.respond_to?(:prefetch)
         prefetchers[provider.class] ||= {}
-        prefetchers[provider.class][resource.uniqueness_key] = resource
+        prefetchers[provider.class][resource.name] = resource
       end
     end
 
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index c8d8688..205d809 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -200,13 +200,7 @@ class Type
   end
 
   def uniqueness_key
-    # If we have only one namevar use that one (res.uniqueness_key behaves
-    # like res[:name] in that case). Otherwise use an array of all keyattributes
-    if name_var
-      self[:name]
-    else
-      @parameters.values_at(*self.class.key_attributes).collect {|p| p.value }
-    end
+    to_resource.uniqueness_key
   end
 
   # Create a new parameter.  Requires a block and a name, stores it in the
diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb
index 6f94409..345ccd0 100755
--- a/spec/unit/resource_spec.rb
+++ b/spec/unit/resource_spec.rb
@@ -276,7 +276,7 @@ describe Puppet::Resource do
   describe "when referring to a resource with name canonicalization" do
     it "should canonicalize its own name" do
       res = Puppet::Resource.new("file", "/path/")
-      res.uniqueness_key.should == "/path"
+      res.uniqueness_key.should == ["/path"]
       res.ref.should == "File[/path/]"
     end
   end
@@ -800,14 +800,7 @@ type: File
   end
 
   describe "when generating the uniqueness key" do
-
-    it "should use namevar if there is only one key_attribute" do
-      Puppet::Type.type(:file).stubs(:key_attributes).returns [:path]
-      res = Puppet::Resource.new("file", "/my/file", :parameters => {:owner => 'root', :content => 'hello'})
-      res.uniqueness_key.should == '/my/file'
-    end
-
-    it "should include all of the key_attributes" do
+    it "should include all of the key_attributes in alphabetical order by attribute name" do
       Puppet::Type.type(:file).stubs(:key_attributes).returns [:myvar, :owner, :path]
       Puppet::Type.type(:file).stubs(:title_patterns).returns(
         [ [ /(.*)/, [ [:path, lambda{|x| x} ] ] ] ]

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list