diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-04-26 17:01:46 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-04-26 17:01:46 +0000 |
commit | bda8e52a02d77c39cd96ea02352c0067a57135e7 (patch) | |
tree | 0df220bd8c0d3cb6af86ba328eff14507ffffe38 /lib/puppet/parser | |
parent | bff94634075617339f65be15dc7eb3261db48f85 (diff) | |
download | puppet-bda8e52a02d77c39cd96ea02352c0067a57135e7.tar.gz puppet-bda8e52a02d77c39cd96ea02352c0067a57135e7.tar.xz puppet-bda8e52a02d77c39cd96ea02352c0067a57135e7.zip |
This should have been in 0.16.1. Moving the "setclass" statements around so that classes are set before a given class's code is evaluated, so it can be tested within the code, within node defs, components, or classes.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1139 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/parser')
-rw-r--r-- | lib/puppet/parser/ast/hostclass.rb | 8 | ||||
-rw-r--r-- | lib/puppet/parser/ast/node.rb | 9 | ||||
-rw-r--r-- | lib/puppet/parser/functions.rb | 12 |
3 files changed, 17 insertions, 12 deletions
diff --git a/lib/puppet/parser/ast/hostclass.rb b/lib/puppet/parser/ast/hostclass.rb index 503802b93..8290f4ef0 100644 --- a/lib/puppet/parser/ast/hostclass.rb +++ b/lib/puppet/parser/ast/hostclass.rb @@ -20,6 +20,10 @@ class Puppet::Parser::AST return nil end + # Set the class before we do anything else, so that it's set + # during the evaluation and can be inspected. + scope.setclass(self.object_id, @type) + # Default to creating a new context newcontext = true if parentscope = self.evalparent( @@ -45,10 +49,6 @@ class Puppet::Parser::AST :name => objname, :newcontext => newcontext ) - - # Set the mark after we evaluate, so we don't record it but - # then encounter an error - scope.setclass(self.object_id, @type) return retval end diff --git a/lib/puppet/parser/ast/node.rb b/lib/puppet/parser/ast/node.rb index 2a8e6a85b..f1b128ccf 100644 --- a/lib/puppet/parser/ast/node.rb +++ b/lib/puppet/parser/ast/node.rb @@ -36,13 +36,14 @@ class Puppet::Parser::AST # already been defined at this top-level scope. #super(scope, facts, @name, @name) - # And then evaluate our code. - @code.safeevaluate(:scope => scope) - # Mark our node name as a class, too, but strip it of the domain - # name. + # name. Make the mark before we evaluate the code, so that it is + # marked within the code itself. scope.setclass(self.object_id, @type.sub(/\..+/, '')) + # And then evaluate our code. + @code.safeevaluate(:scope => scope) + return scope end diff --git a/lib/puppet/parser/functions.rb b/lib/puppet/parser/functions.rb index 61070627f..63201924b 100644 --- a/lib/puppet/parser/functions.rb +++ b/lib/puppet/parser/functions.rb @@ -91,11 +91,15 @@ module Functions newfunction(:tagged, :rvalue) do |vals| classlist = self.classlist - if vals.find do |val| ! classlist.include?(val) end - return false - else - return true + retval = true + vals.each do |val| + unless classlist.include?(val) or self.tags.include?(val) + retval = false + break + end end + + return retval end # Test whether a given class or definition is defined |