From 11ae473e3852adcc382a3efea2329586d2e4bcb3 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Wed, 28 Nov 2007 15:20:52 -0600 Subject: Theoretically, this patch is to fix #917 (which it does), but there were enough problems fixing it that I decided something more drastic needed to be done. This uses the new Puppet::ResourceReference class to canonize what a resource reference looks like and how to retrieve resources via their references. Specifically, it guarantees that resource types are always capitalized, even when they include '::' in them. While many files are modified in this commit, the majority of changes are quite small, and most of the changes are fixing the tests to use capitalized types. As we look at consolidating some of our resource types, we could consolidate the ResourceReference stuff at the same time, but at least the Puppet::Parser::ResourceReference class subclasses the main Puppet::ResourceReference class. --- lib/puppet/parser/resource.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib/puppet/parser/resource.rb') diff --git a/lib/puppet/parser/resource.rb b/lib/puppet/parser/resource.rb index 2f7fff13f..3f346166e 100644 --- a/lib/puppet/parser/resource.rb +++ b/lib/puppet/parser/resource.rb @@ -131,8 +131,9 @@ class Puppet::Parser::Resource end @tags = [] - @tags << @ref.type.to_s - @tags << @ref.title.to_s if @ref.title.to_s =~ /^[-\w]+$/ + tag(@ref.type) + tag(@ref.title) if @ref.title.to_s =~ /^[-\w]+$/ + if scope.resource @tags += scope.resource.tags end @@ -225,15 +226,14 @@ class Puppet::Parser::Resource # Add a tag to our current list. These tags will be added to all # of the objects contained in this scope. def tag(*ary) - ary.each { |tag| - tag = tag.to_s + ary.collect { |tag| tag.to_s.downcase }.collect { |tag| tag.split("::") }.flatten.each do |tag| unless tag =~ /^\w[-\w]*$/ fail Puppet::ParseError, "Invalid tag %s" % tag.inspect end unless @tags.include?(tag) @tags << tag end - } + end end def tags -- cgit