summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/parser')
-rw-r--r--lib/puppet/parser/ast/resource_defaults.rb5
-rw-r--r--lib/puppet/parser/collector.rb7
-rw-r--r--lib/puppet/parser/resource.rb10
-rw-r--r--lib/puppet/parser/resource/reference.rb27
4 files changed, 22 insertions, 27 deletions
diff --git a/lib/puppet/parser/ast/resource_defaults.rb b/lib/puppet/parser/ast/resource_defaults.rb
index 44ec146b0..8f9c1b8df 100644
--- a/lib/puppet/parser/ast/resource_defaults.rb
+++ b/lib/puppet/parser/ast/resource_defaults.rb
@@ -10,7 +10,10 @@ class Puppet::Parser::AST
# object type.
def evaluate(hash)
scope = hash[:scope]
- type = @type.downcase
+
+ # Use a resource reference to canonize the type
+ ref = Puppet::ResourceReference.new(@type, "whatever")
+ type = ref.type
params = @params.safeevaluate(:scope => scope)
parsewrap do
diff --git a/lib/puppet/parser/collector.rb b/lib/puppet/parser/collector.rb
index cdde51bee..9dd07f31a 100644
--- a/lib/puppet/parser/collector.rb
+++ b/lib/puppet/parser/collector.rb
@@ -28,7 +28,9 @@ class Puppet::Parser::Collector
def initialize(scope, type, equery, vquery, form)
@scope = scope
- @type = type
+
+ # Canonize the type
+ @type = Puppet::ResourceReference.new(type, "whatever").type
@equery = equery
@vquery = vquery
@@ -98,8 +100,7 @@ class Puppet::Parser::Collector
end
def collect_exported_resources
- raise Puppet::ParseError,
- "realize() is not yet implemented for exported resources"
+ raise Puppet::ParseError, "realize() is not yet implemented for exported resources"
end
# Collect resources directly; this is the result of using 'realize',
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
diff --git a/lib/puppet/parser/resource/reference.rb b/lib/puppet/parser/resource/reference.rb
index 543ee7195..1dd816093 100644
--- a/lib/puppet/parser/resource/reference.rb
+++ b/lib/puppet/parser/resource/reference.rb
@@ -1,9 +1,11 @@
+require 'puppet/resource_reference'
+
# A reference to a resource. Mostly just the type and title.
-class Puppet::Parser::Resource::Reference
+class Puppet::Parser::Resource::Reference < Puppet::ResourceReference
include Puppet::Util::MethodHelper
include Puppet::Util::Errors
- attr_accessor :type, :title, :builtin, :file, :line, :scope
+ attr_accessor :builtin, :file, :line, :scope
# Are we a builtin type?
def builtin?
@@ -19,7 +21,7 @@ class Puppet::Parser::Resource::Reference
end
def builtintype
- if t = Puppet::Type.type(self.type) and t.name != :component
+ if t = Puppet::Type.type(self.type.downcase) and t.name != :component
t
else
nil
@@ -30,28 +32,24 @@ class Puppet::Parser::Resource::Reference
# definitions or nodes.
def definedtype
unless defined? @definedtype
- type = self.type.to_s.downcase
- name = self.title
- case type
- when "class": # look for host classes
+ case self.type
+ when "Class": # look for host classes
if self.title == :main
tmp = @scope.findclass("")
else
tmp = @scope.findclass(self.title)
end
- when "node": # look for node definitions
+ when "Node": # look for node definitions
tmp = @scope.parser.nodes[self.title]
else # normal definitions
# We have to swap these variables around so the errors are right.
- name = type
- type = "type"
tmp = @scope.finddefine(self.type)
end
if tmp
@definedtype = tmp
else
- fail Puppet::ParseError, "Could not find resource %s '%s'" % [type, name]
+ fail Puppet::ParseError, "Could not find resource '%s'" % self
end
end
@@ -67,13 +65,6 @@ class Puppet::Parser::Resource::Reference
return [type.to_s,title.to_s]
end
- def to_s
- unless defined? @namestring
- @namestring = "%s[%s]" % [type.split("::").collect { |s| s.capitalize }.join("::"), title]
- end
- @namestring
- end
-
def typeclass
unless defined? @typeclass
if tmp = builtintype || definedtype