+1, nice catch on the other places where set_parameter should be used. On Jun 6, 2009, at 7:18 AM, Brice Figureau wrote:
> > This is so that overriding the "tag" metaparameter ends-up in the > resource tags on the server. > > Signed-off-by: Brice Figureau <[email protected]> > --- > lib/puppet/parser/resource.rb | 9 ++++++--- > spec/unit/parser/resource.rb | 10 ++++++++++ > 2 files changed, 16 insertions(+), 3 deletions(-) > > diff --git a/lib/puppet/parser/resource.rb b/lib/puppet/parser/ > resource.rb > index e7932de..6632d2b 100644 > --- a/lib/puppet/parser/resource.rb > +++ b/lib/puppet/parser/resource.rb > @@ -139,7 +139,6 @@ class Puppet::Parser::Resource > if params = options[:params] > options.delete(:params) > params.each do |param| > - tag(*param.value) if param.name == :tag > set_parameter(param) > end > end > @@ -204,6 +203,8 @@ class Puppet::Parser::Resource > end > > # Define a parameter in our resource. > + # if we ever receive a parameter named 'tag', set > + # the resource tags with its value. > def set_parameter(param, value = nil) > if value > param = Puppet::Parser::Resource::Param.new( > @@ -213,6 +214,8 @@ class Puppet::Parser::Resource > raise ArgumentError, "Must pass a parameter or all > necessary values" > end > > + tag(*param.value) if param.name == :tag > + > # And store it in our parameter hash. > @params[param.name] = param > end > @@ -327,7 +330,7 @@ class Puppet::Parser::Resource > def override_parameter(param) > # This can happen if the override is defining a new > parameter, rather > # than replacing an existing one. > - (@params[param.name] = param and return) unless current = > @params[param.name] > + (set_parameter(param) and return) unless current = > @params[param.name] > > # The parameter is already set. Fail if they're not allowed > to override it. > unless param.source.child_of?(current.source) > @@ -353,7 +356,7 @@ class Puppet::Parser::Resource > # so that the source is registered correctly for later > overrides. > param.value = [current.value, param.value].flatten if > param.add > > - @params[param.name] = param > + set_parameter(param) > end > > # Verify that all passed parameters are valid. This throws an > error if > diff --git a/spec/unit/parser/resource.rb b/spec/unit/parser/ > resource.rb > index bdaa05b..8005e20 100755 > --- a/spec/unit/parser/resource.rb > +++ b/spec/unit/parser/resource.rb > @@ -332,6 +332,16 @@ describe Puppet::Parser::Resource do > @resource[:testing].should == %w{other testing} > end > > + it "should promote tag overrides to real tags" do > + @source.stubs(:child_of?).returns true > + param = Puppet::Parser::Resource::Param.new(:name > => :tag, :value => "testing", :source => @resource.source) > + > + @override.set_parameter(param) > + > + @resource.merge(@override) > + > + @resource.tagged?("testing").should be_true > + end > > end > > -- > 1.6.0.2 > > > > -- I have an answering machine in my car. It says, "I'm home now. But leave a message and I'll call when I'm out. -- Stephen Wright --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en -~----------~----~----~----~------~----~------~--~---
