summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/resource
diff options
context:
space:
mode:
authorLuke Kanies <luke@reductivelabs.com>2010-01-06 17:42:42 -0800
committertest branch <puppet-dev@googlegroups.com>2010-02-17 06:50:53 -0800
commitb82b4ef04282ca0006931562f60459a1591b6268 (patch)
tree31b77674c07a382a46af8773a81826a6e52c20b3 /lib/puppet/parser/resource
parent644ad7e41880fe8c9e73a099e9d6644e19828f46 (diff)
downloadpuppet-b82b4ef04282ca0006931562f60459a1591b6268.tar.gz
puppet-b82b4ef04282ca0006931562f60459a1591b6268.tar.xz
puppet-b82b4ef04282ca0006931562f60459a1591b6268.zip
All non-transient parser references are gone
We now use references to the ResourceTypeCollection instances through the environment, which is much cleaner. The next step is to remove the Interpreter class. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
Diffstat (limited to 'lib/puppet/parser/resource')
-rw-r--r--lib/puppet/parser/resource/reference.rb20
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/puppet/parser/resource/reference.rb b/lib/puppet/parser/resource/reference.rb
index 3ef981258..bb50efdce 100644
--- a/lib/puppet/parser/resource/reference.rb
+++ b/lib/puppet/parser/resource/reference.rb
@@ -3,12 +3,15 @@ require 'puppet/resource/reference'
require 'puppet/file_collection/lookup'
require 'puppet/parser/yaml_trimmer'
+require 'puppet/parser/resource_type_collection_helper'
+
# A reference to a resource. Mostly just the type and title.
class Puppet::Parser::Resource::Reference < Puppet::Resource::Reference
include Puppet::Parser::YamlTrimmer
include Puppet::FileCollection::Lookup
include Puppet::Util::MethodHelper
include Puppet::Util::Errors
+ include Puppet::Parser::ResourceTypeCollectionHelper
attr_accessor :builtin, :file, :line, :scope
@@ -39,21 +42,18 @@ class Puppet::Parser::Resource::Reference < Puppet::Resource::Reference
unless defined? @definedtype
case self.type
when "Class" # look for host classes
- if self.title == :main
- tmp = @scope.find_hostclass("")
- else
- unless tmp = @scope.parser.hostclass(self.title)
- fail Puppet::ParseError, "Could not find class '%s'" % self.title
- end
+ name = self.title == :main ? "" : self.title
+ unless tmp = known_resource_types.find_hostclass("", name)
+ fail Puppet::ParseError, "Could not find '#{title}' class"
end
when "Node" # look for node definitions
- unless tmp = @scope.parser.node(self.title)
+ unless tmp = known_resource_types.node(self.title)
fail Puppet::ParseError, "Could not find node '%s'" % self.title
end
else # normal definitions
# The resource type is capitalized, so we have to downcase. Really,
# we should have a better interface for finding these, but eh.
- tmp = @scope.parser.definition(self.type.downcase)
+ tmp = known_resource_types.definition(self.type.downcase)
end
if tmp
@@ -66,6 +66,10 @@ class Puppet::Parser::Resource::Reference < Puppet::Resource::Reference
@definedtype
end
+ def environment
+ scope.environment
+ end
+
def initialize(hash)
set_options(hash)
requiredopts(:type, :title)