0001-Fixing-2789-puppetrun-fails-without-tag.patch

Jesse Wolfe, 11/11/2009 12:53 pm

Download (3.8 kB)

b/lib/puppet/transaction.rb
2 2
# and performs them
3 3

  
4 4
require 'puppet'
5
require 'puppet/util/tagging'
5 6

  
6 7
module Puppet
7 8
class Transaction
......
18 19
    attr_reader :events
19 20

  
20 21
    include Puppet::Util
22
    include Puppet::Util::Tagging
21 23

  
22 24
    # Add some additional times for reporting
23 25
    def addtimes(hash)
......
601 603
    # The tags we should be checking.
602 604
    def tags
603 605
        unless defined? @tags
604
            tags = Puppet[:tags]
605
            if tags.nil? or tags == ""
606
                @tags = []
607
            else
608
                @tags = tags.split(/\s*,\s*/)
609
            end
606
            self.tags = Puppet[:tags]
610 607
        end
611 608

  
612
        @tags
609
        super
613 610
    end
614 611

  
615
    def tags=(tags)
616
        tags = [tags] unless tags.is_a?(Array)
617
        @tags = tags
612
    def handle_qualified_tags( qualified )
613
        # The default behavior of Puppet::Util::Tagging is
614
        # to split qualified tags into parts. That would cause
615
        # qualified tags to match too broadly here.
616
        return
618 617
    end
619 618

  
620 619
    # Is this resource tagged appropriately?
b/lib/puppet/util/tagging.rb
16 16
            @tags << tag unless @tags.include?(tag)
17 17
        end
18 18

  
19
        # LAK:NOTE See http://snurl.com/21zf8  [groups_google_com]
20
        qualified.collect { |name| x = name.split("::") }.flatten.each { |tag| @tags << tag unless @tags.include?(tag) }
19
        handle_qualified_tags( qualified )
21 20
    end
22 21

  
23 22
    # Are we tagged with the provided tag?
......
32 31
        @tags.dup
33 32
    end
34 33

  
34
    def tags=(tags)
35
        @tags = []
36

  
37
        return if tags.nil? or tags == ""
38

  
39
        if tags.is_a?(String)
40
            tags = tags.strip.split(/\s*,\s*/)
41
        end
42

  
43
        tags.each do |t|
44
            tag(t)
45
        end
46
    end
47

  
35 48
    private
36 49

  
50
    def handle_qualified_tags( qualified )
51
        # LAK:NOTE See http://snurl.com/21zf8  [groups_google_com]
52
        qualified.collect { |name| x = name.split("::") }.flatten.each { |tag| @tags << tag unless @tags.include?(tag) }
53
    end
54

  
37 55
    def valid_tag?(tag)
38 56
        tag =~ /^\w[-\w:.]*$/
39 57
    end
b/spec/unit/transaction.rb
108 108
        @transaction.tags = "one::two"
109 109
        @transaction.tags.should == %w{one::two}
110 110
    end
111

  
112
    it "should accept a comma-delimited string" do
113
        @transaction.tags = "one, two"
114
        @transaction.tags.should == %w{one two}
115
    end
116

  
117
    it "should accept an empty string" do
118
        @transaction.tags = ""
119
        @transaction.tags.should == []
120
    end
111 121
end
112
-