summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/resource
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-09-03 18:01:00 -0500
committerLuke Kanies <luke@madstop.com>2007-09-03 18:01:00 -0500
commitb021587e309f237bd16bd4f5cc51e79266cbd222 (patch)
treeb46de15108c7f1fcf50b67a54bcb8f528854e566 /lib/puppet/parser/resource
parent25f6d7c521cb0189cf691fb1c4bce4b675568300 (diff)
downloadpuppet-b021587e309f237bd16bd4f5cc51e79266cbd222.tar.gz
puppet-b021587e309f237bd16bd4f5cc51e79266cbd222.tar.xz
puppet-b021587e309f237bd16bd4f5cc51e79266cbd222.zip
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.
Diffstat (limited to 'lib/puppet/parser/resource')
-rw-r--r--lib/puppet/parser/resource/reference.rb23
1 files changed, 19 insertions, 4 deletions
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