From b021587e309f237bd16bd4f5cc51e79266cbd222 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Mon, 3 Sep 2007 18:01:00 -0500 Subject: Doing a small amount of refactoring, toward being able to use Parser resources to evaluate classes and nodes, not just definitions. This will hopefully simplify some of the parsing work, and it will enable the use of a Configuration object that more completely models a configuration. --- lib/puppet/parser/resource/reference.rb | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'lib/puppet/parser/resource') diff --git a/lib/puppet/parser/resource/reference.rb b/lib/puppet/parser/resource/reference.rb index b19dd2258..0c3b61930 100644 --- a/lib/puppet/parser/resource/reference.rb +++ b/lib/puppet/parser/resource/reference.rb @@ -15,7 +15,7 @@ class Puppet::Parser::Resource::Reference end end - self.builtin + @builtin end def builtintype @@ -26,13 +26,28 @@ class Puppet::Parser::Resource::Reference end end - # Return the defined type for our obj. + # Return the defined type for our obj. This can return classes, + # definitions or nodes. def definedtype unless defined? @definedtype - if tmp = @scope.finddefine(self.type) + type = self.type.to_s.downcase + name = self.title + case type + when "class": # look for host classes + tmp = @scope.findclass(self.title) + 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 type '%s'" % self.type + fail Puppet::ParseError, "Could not find resource %s '%s'" % [type, name] end end -- cgit