summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorJesse Wolfe <jes5199@gmail.com>2009-11-10 02:58:02 -0800
committerJames Turnbull <james@lovedthanlost.net>2009-11-19 03:35:31 +1100
commitc1e47a43df40abd5da04bf147df17f0b53bf0868 (patch)
tree75424d94dfeb10d5e70ffe7b9ec9a5b6ce4eaced /lib/puppet
parent106c9a91929f00a852f7027088cee6684f83ab63 (diff)
downloadpuppet-c1e47a43df40abd5da04bf147df17f0b53bf0868.tar.gz
puppet-c1e47a43df40abd5da04bf147df17f0b53bf0868.tar.xz
puppet-c1e47a43df40abd5da04bf147df17f0b53bf0868.zip
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.
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/transaction.rb19
-rw-r--r--lib/puppet/util/tagging.rb22
2 files changed, 29 insertions, 12 deletions
diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb
index a0d5b16a9..e132b7238 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)
@@ -602,20 +604,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 03a8b8a9a..9ee90799f 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