summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-02-29 12:04:42 -0600
committerLuke Kanies <luke@madstop.com>2008-02-29 12:04:42 -0600
commit65b72676aef2d58314f546eb31780d1b9925b9b3 (patch)
tree6d09647c1b566063e660e639e4c401b39137ceff
parent4c3fa7806d12f86fce01030aa5e3745e698cb3c0 (diff)
downloadpuppet-65b72676aef2d58314f546eb31780d1b9925b9b3.tar.gz
puppet-65b72676aef2d58314f546eb31780d1b9925b9b3.tar.xz
puppet-65b72676aef2d58314f546eb31780d1b9925b9b3.zip
Fixing the fact that resources that model defined resources
were getting finished multiple times, which meant they got multiple copies of metaparams.
-rw-r--r--lib/puppet/parser/resource.rb7
-rwxr-xr-xspec/unit/parser/resource.rb6
2 files changed, 13 insertions, 0 deletions
diff --git a/lib/puppet/parser/resource.rb b/lib/puppet/parser/resource.rb
index 46be89ca2..b001e165b 100644
--- a/lib/puppet/parser/resource.rb
+++ b/lib/puppet/parser/resource.rb
@@ -82,12 +82,19 @@ class Puppet::Parser::Resource
# Do any finishing work on this object, called before evaluation or
# before storage/translation.
def finish
+ return if finished?
+ @finished = true
add_defaults()
add_metaparams()
add_scope_tags()
validate()
end
+ # Has this resource already been finished?
+ def finished?
+ defined?(@finished) and @finished
+ end
+
def initialize(options)
# Set all of the options we can.
options.each do |option, value|
diff --git a/spec/unit/parser/resource.rb b/spec/unit/parser/resource.rb
index 035590341..9ce7b391b 100755
--- a/spec/unit/parser/resource.rb
+++ b/spec/unit/parser/resource.rb
@@ -67,6 +67,12 @@ describe Puppet::Parser::Resource do
@resource = Puppet::Parser::Resource.new(:type => "mydefine", :title => "whatever", :scope => @scope, :source => @source)
end
+ it "should do nothing if it has already been finished" do
+ @resource.finish
+ @resource.expects(:add_metaparams).never
+ @resource.finish
+ end
+
it "should copy metaparams from its scope" do
@scope.setvar("noop", "true")