summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/functions
diff options
context:
space:
mode:
authorLuke Kanies <luke@reductivelabs.com>2010-01-29 20:57:21 -0600
committertest branch <puppet-dev@googlegroups.com>2010-02-17 06:50:53 -0800
commit7089446697ad550c22012bc2b5572030727d67e1 (patch)
tree40d160f11839fe6e20311186ded4e621d23e1242 /lib/puppet/parser/functions
parent4871c909cd28c82b64d0b62d8a27e62737d8733d (diff)
downloadpuppet-7089446697ad550c22012bc2b5572030727d67e1.tar.gz
puppet-7089446697ad550c22012bc2b5572030727d67e1.tar.xz
puppet-7089446697ad550c22012bc2b5572030727d67e1.zip
Removing Resource::Reference classes
This commit is hopefully less messy than it first appears, but it's certainly cross-cutting. The reason for all of this is that we previously only looked up builtin resource types from outside the parser, but now that the defined resource types are available globally via environments, we can push that lookup code to Resource. Once we do that, however, we have to have environment and namespace information in every resource. Here I remove the Resource::Reference classes (except the AST class), and use Resource instances instead. I did this because the shared code between the two classes got incredibly complicated, such that they should have had a hierarchical relationship disallowed by their constants. This complexity convinced me just to get rid of References entirely. I also make Puppet::Parser::Resource a subclass of Puppet::Resource. There are still broken tests in test/, but this was a big enough commit I wanted to get it in. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
Diffstat (limited to 'lib/puppet/parser/functions')
-rw-r--r--lib/puppet/parser/functions/defined.rb6
-rw-r--r--lib/puppet/parser/functions/require.rb2
2 files changed, 4 insertions, 4 deletions
diff --git a/lib/puppet/parser/functions/defined.rb b/lib/puppet/parser/functions/defined.rb
index 5ad74a79e..4d1d8c6fd 100644
--- a/lib/puppet/parser/functions/defined.rb
+++ b/lib/puppet/parser/functions/defined.rb
@@ -6,21 +6,21 @@ Puppet::Parser::Functions::newfunction(:defined, :type => :rvalue, :doc => "Dete
(e.g., ``if defined(File['/tmp/myfile']) { ... }``). This function is unfortunately
dependent on the parse order of the configuration when testing whether a resource is defined.") do |vals|
result = false
+ vals = [vals] unless vals.is_a?(Array)
vals.each do |val|
case val
when String
- # For some reason, it doesn't want me to return from here.
if Puppet::Type.type(val) or find_definition(val) or find_hostclass(val)
result = true
break
end
- when Puppet::Parser::Resource::Reference
+ when Puppet::Resource
if findresource(val.to_s)
result = true
break
end
else
- raise ArgumentError, "Invalid argument of type %s to 'defined'" % val.class
+ raise ArgumentError, "Invalid argument of type '#{val.class}' to 'defined'"
end
end
result
diff --git a/lib/puppet/parser/functions/require.rb b/lib/puppet/parser/functions/require.rb
index 66d60b9ce..294484a2b 100644
--- a/lib/puppet/parser/functions/require.rb
+++ b/lib/puppet/parser/functions/require.rb
@@ -49,7 +49,7 @@ fail if used with earlier clients.
# The 'obvious' way is just to add an edge in the catalog,
# but that is considered a containment edge, not a dependency
# edge, so it usually gets lost on the client.
- ref = Puppet::Parser::Resource::Reference.new(:type => :class, :title => klass)
+ ref = Puppet::Resource.new(:class, klass)
resource.set_parameter(:require, [resource[:require]].flatten.compact << ref)
end
end