summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-04-26 17:01:46 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-04-26 17:01:46 +0000
commitbda8e52a02d77c39cd96ea02352c0067a57135e7 (patch)
tree0df220bd8c0d3cb6af86ba328eff14507ffffe38
parentbff94634075617339f65be15dc7eb3261db48f85 (diff)
downloadpuppet-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
-rw-r--r--conf/redhat/puppet.spec2
-rw-r--r--examples/code/snippets/tagged.pp10
-rw-r--r--lib/puppet.rb2
-rw-r--r--lib/puppet/parser/ast/hostclass.rb8
-rw-r--r--lib/puppet/parser/ast/node.rb9
-rw-r--r--lib/puppet/parser/functions.rb12
-rwxr-xr-xtest/language/snippets.rb2
7 files changed, 30 insertions, 15 deletions
diff --git a/conf/redhat/puppet.spec b/conf/redhat/puppet.spec
index f8baff62f..74955b79e 100644
--- a/conf/redhat/puppet.spec
+++ b/conf/redhat/puppet.spec
@@ -4,7 +4,7 @@
Summary: A network tool for managing many disparate systems
Name: puppet
-Version: 0.16.0
+Version: 0.16.1
Release: 1%{?dist}
License: GPL
Group: System Environment/Base
diff --git a/examples/code/snippets/tagged.pp b/examples/code/snippets/tagged.pp
index f4d6ff7ca..7d382d01c 100644
--- a/examples/code/snippets/tagged.pp
+++ b/examples/code/snippets/tagged.pp
@@ -3,6 +3,16 @@
tag testing
tag(funtest)
+define tagdefine {
+ $path = tagged(tagdefine) ? {
+ true => "true", false => "false"
+ }
+
+ file { "/tmp/taggeddefine$path": ensure => file }
+}
+
+tagdefine {}
+
$yayness = tagged(yayness) ? {
true => "true", false => "false"
}
diff --git a/lib/puppet.rb b/lib/puppet.rb
index 7965dc9dc..213eb088e 100644
--- a/lib/puppet.rb
+++ b/lib/puppet.rb
@@ -14,7 +14,7 @@ require 'puppet/util'
#
# it's also a place to find top-level commands like 'debug'
module Puppet
- PUPPETVERSION = '0.16.0'
+ PUPPETVERSION = '0.16.1'
def Puppet.version
return PUPPETVERSION
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
diff --git a/test/language/snippets.rb b/test/language/snippets.rb
index f541b4eeb..3b1fddd4e 100755
--- a/test/language/snippets.rb
+++ b/test/language/snippets.rb
@@ -436,7 +436,7 @@ class TestSnippets < Test::Unit::TestCase
# Make sure that set tags are correctly in place, yo.
def snippet_tagged(trans)
tags = {"testing" => true, "yayness" => false,
- "both" => false, "bothtrue" => true}
+ "both" => false, "bothtrue" => true, "define" => true}
tags.each do |tag, retval|
@@tmpfiles << "/tmp/tagged#{tag}true"