[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, master, updated. puppet-0.24.5-rc3-1466-g1c0ac6a

Nigel Kersten nigelk at google.com
Wed Dec 16 18:50:28 UTC 2009


The following commit has been merged in the master branch:
commit 1c0ac6aa9be7edde8c7235ee7f1eceda6fd73d23
Author: Jesse Wolfe <jes5199 at gmail.com>
Date:   Tue Nov 10 02:58:02 2009 -0800

    Fixing #2789 puppetrun fails without --tag
    
    Puppet::Transaction was handling "tags" strings differently depending on
    whether they came in from Puppet[:tags] or another source.
    This was causing puppetrun's tags to be misparsed if there was not
    exactly one --tag parameter.
    
    I've moved the code to Util::Tagging.

diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb
index d04856d..893f773 100644
--- a/lib/puppet/transaction.rb
+++ b/lib/puppet/transaction.rb
@@ -2,6 +2,7 @@
 # and performs them
 
 require 'puppet'
+require 'puppet/util/tagging'
 
 module Puppet
 class Transaction
@@ -18,6 +19,7 @@ class Transaction
     attr_reader :events
 
     include Puppet::Util
+    include Puppet::Util::Tagging
 
     # Add some additional times for reporting
     def addtimes(hash)
@@ -601,20 +603,17 @@ class Transaction
     # The tags we should be checking.
     def tags
         unless defined? @tags
-            tags = Puppet[:tags]
-            if tags.nil? or tags == ""
-                @tags = []
-            else
-                @tags = tags.split(/\s*,\s*/)
-            end
+            self.tags = Puppet[:tags]
         end
 
-        @tags
+        super
     end
 
-    def tags=(tags)
-        tags = [tags] unless tags.is_a?(Array)
-        @tags = tags
+    def handle_qualified_tags( qualified )
+        # The default behavior of Puppet::Util::Tagging is
+        # to split qualified tags into parts. That would cause
+        # qualified tags to match too broadly here.
+        return
     end
 
     # Is this resource tagged appropriately?
diff --git a/lib/puppet/util/tagging.rb b/lib/puppet/util/tagging.rb
index f421d18..b244a7a 100644
--- a/lib/puppet/util/tagging.rb
+++ b/lib/puppet/util/tagging.rb
@@ -16,8 +16,7 @@ module Puppet::Util::Tagging
             @tags << tag unless @tags.include?(tag)
         end
 
-        # LAK:NOTE See http://snurl.com/21zf8  [groups_google_com]
-        qualified.collect { |name| x = name.split("::") }.flatten.each { |tag| @tags << tag unless @tags.include?(tag) }
+        handle_qualified_tags( qualified )
     end
 
     # Are we tagged with the provided tag?
@@ -32,8 +31,27 @@ module Puppet::Util::Tagging
         @tags.dup
     end
 
+    def tags=(tags)
+        @tags = []
+
+        return if tags.nil? or tags == ""
+
+        if tags.is_a?(String)
+            tags = tags.strip.split(/\s*,\s*/)
+        end
+
+        tags.each do |t|
+            tag(t)
+        end
+    end
+
     private
 
+    def handle_qualified_tags( qualified )
+        # LAK:NOTE See http://snurl.com/21zf8  [groups_google_com]
+        qualified.collect { |name| x = name.split("::") }.flatten.each { |tag| @tags << tag unless @tags.include?(tag) }
+    end
+
     def valid_tag?(tag)
         tag =~ /^\w[-\w:.]*$/
     end
diff --git a/spec/unit/transaction.rb b/spec/unit/transaction.rb
index 7966c7a..5474c38 100755
--- a/spec/unit/transaction.rb
+++ b/spec/unit/transaction.rb
@@ -108,4 +108,14 @@ describe Puppet::Transaction, " when determining tags" do
         @transaction.tags = "one::two"
         @transaction.tags.should == %w{one::two}
     end
+
+    it "should accept a comma-delimited string" do
+        @transaction.tags = "one, two"
+        @transaction.tags.should == %w{one two}
+    end
+
+    it "should accept an empty string" do
+        @transaction.tags = ""
+        @transaction.tags.should == []
+    end
 end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list