diff options
-rw-r--r-- | lib/puppet/parser/resource.rb | 8 | ||||
-rwxr-xr-x | spec/unit/parser/resource.rb | 35 |
2 files changed, 10 insertions, 33 deletions
diff --git a/lib/puppet/parser/resource.rb b/lib/puppet/parser/resource.rb index e016a3047..8d29ea346 100644 --- a/lib/puppet/parser/resource.rb +++ b/lib/puppet/parser/resource.rb @@ -357,20 +357,16 @@ class Puppet::Parser::Resource # from any parent scope, and there's currently no way to turn that off. def add_metaparams Puppet::Type.eachmetaparam do |name| + next if self.class.relationship_parameter?(name) # Skip metaparams that we already have defined, unless they're relationship metaparams. # LAK:NOTE Relationship metaparams get treated specially -- we stack them, instead of # overriding. - next if @params[name] and not self.class.relationship_parameter?(name) - next if @params[name] and @params[name].value == :undef + next if @params[name] # Skip metaparams for which we get no value. next unless val = scope.lookupvar(name.to_s, false) and val != :undefined - # The default case: just set the value set_parameter(name, val) and next unless @params[name] - - # For relationship params, though, join the values (a la #446). - @params[name].value = [@params[name].value, val].flatten end end diff --git a/spec/unit/parser/resource.rb b/spec/unit/parser/resource.rb index a042b4e72..926f613bb 100755 --- a/spec/unit/parser/resource.rb +++ b/spec/unit/parser/resource.rb @@ -180,41 +180,22 @@ describe Puppet::Parser::Resource do @resource["noop"].should == "false" end - it "should copy all metaparams that it finds" do - @scope.setvar("require", "container") - @scope.setvar("notify", "container") - - @resource.class.publicize_methods(:add_metaparams) { @resource.add_metaparams } - - @resource["require"].should == "container" - @resource["notify"].should == "container" - end - - it "should stack relationship metaparams from its container if it already has them" do - @resource.set_parameter("require", "resource") - @scope.setvar("require", "container") + it "should not copy relationship metaparams" do + @scope.setvar("require", "bar") @resource.class.publicize_methods(:add_metaparams) { @resource.add_metaparams } - @resource["require"].sort.should == %w{container resource} + @resource["require"].should be_nil end - it "should not stack relationship metaparams that are set to 'undef'" do - @resource.set_parameter("require", :undef) - @scope.setvar("require", "container") - - @resource.class.publicize_methods(:add_metaparams) { @resource.add_metaparams } - - @resource["require"].should == :undef - end - - it "should flatten the array resulting from stacking relationship metaparams" do - @resource.set_parameter("require", ["resource1", "resource2"]) - @scope.setvar("require", %w{container1 container2}) + it "should copy all metaparams that it finds" do + @scope.setvar("noop", "foo") + @scope.setvar("schedule", "bar") @resource.class.publicize_methods(:add_metaparams) { @resource.add_metaparams } - @resource["require"].sort.should == %w{container1 container2 resource1 resource2} + @resource["noop"].should == "foo" + @resource["schedule"].should == "bar" end it "should add any tags from the scope resource" do |