summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-11-13 06:11:39 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-11-13 06:11:39 +0000
commit1bf97cdf3f9b43ee88bda36d1a05aa3d0011598c (patch)
treeb4d143319682a02eef6a69542e4c838003162126
parent50d28efe13f8ce525b32e16c7c882361a86a9758 (diff)
downloadpuppet-1bf97cdf3f9b43ee88bda36d1a05aa3d0011598c.tar.gz
puppet-1bf97cdf3f9b43ee88bda36d1a05aa3d0011598c.tar.xz
puppet-1bf97cdf3f9b43ee88bda36d1a05aa3d0011598c.zip
Fixing #339, and the bigger problem it concealed. Metaparams are now only added to resources that do not explicitly set them.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1869 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r--lib/puppet/parser/ast/component.rb4
-rw-r--r--lib/puppet/parser/resource.rb4
-rwxr-xr-xtest/language/resource.rb7
-rwxr-xr-xtest/server/runner.rb2
4 files changed, 16 insertions, 1 deletions
diff --git a/lib/puppet/parser/ast/component.rb b/lib/puppet/parser/ast/component.rb
index f67d53b4b..a21a03517 100644
--- a/lib/puppet/parser/ast/component.rb
+++ b/lib/puppet/parser/ast/component.rb
@@ -21,6 +21,10 @@ class Puppet::Parser::AST
# These are retrieved when looking up the superclass
attr_accessor :name
+ def child_of?(klass)
+ false
+ end
+
def evaluate(hash)
origscope = hash[:scope]
objtype = hash[:type]
diff --git a/lib/puppet/parser/resource.rb b/lib/puppet/parser/resource.rb
index d27c8b27e..8c1153929 100644
--- a/lib/puppet/parser/resource.rb
+++ b/lib/puppet/parser/resource.rb
@@ -60,6 +60,7 @@ class Puppet::Parser::Resource
# from any parent scope, and there's currently no way to turn that off.
def addmetaparams
Puppet::Type.eachmetaparam do |name|
+ next if self[name]
if val = scope.lookupvar(name.to_s, false)
unless val == :undefined
set Param.new(:name => name, :value => val, :source => scope.source)
@@ -236,6 +237,9 @@ class Puppet::Parser::Resource
# Replace it, keeping all of its info.
@params[param.name] = param
else
+ if Puppet[:trace]
+ puts caller
+ end
fail Puppet::ParseError, "Parameter %s is already set on %s by %s" %
[param.name, self.to_s, param.source]
end
diff --git a/test/language/resource.rb b/test/language/resource.rb
index a9a0a7ef6..f7786a774 100755
--- a/test/language/resource.rb
+++ b/test/language/resource.rb
@@ -296,7 +296,8 @@ class TestResource < Test::Unit::TestCase
def test_addmetaparams
mkevaltest @interp
res = Parser::Resource.new :type => "evaltest", :title => "yay",
- :source => @source, :scope => @scope
+ :source => @source, :scope => @scope,
+ :params => paramify(@source, :tag => "yay")
assert_nil(res[:schedule], "Got schedule already")
assert_nothing_raised do
@@ -304,11 +305,15 @@ class TestResource < Test::Unit::TestCase
end
@scope.setvar("schedule", "daily")
+ # This is so we can test that it won't override already-set metaparams
+ @scope.setvar("tag", "funtest")
+
assert_nothing_raised do
res.addmetaparams
end
assert_equal("daily", res[:schedule], "Did not get metaparam")
+ assert_equal("yay", res[:tag], "Overrode explicitly-set metaparam")
assert_nil(res[:noop], "Got invalid metaparam")
end
diff --git a/test/server/runner.rb b/test/server/runner.rb
index daec78c4d..2d904f504 100755
--- a/test/server/runner.rb
+++ b/test/server/runner.rb
@@ -72,6 +72,8 @@ class TestServerRunner < Test::Unit::TestCase
["yayness"], true, false, true],
["with a third good tag",
"yayness", true, false, true],
+ ["with no tags",
+ "", true, false, true],
["not ignoring schedules",
nil, false, false, false],
["ignoring schedules",