Why did you choose to only do this on the eval_generate method, rather than in the generate_additional_resources method itself? I'd think all generated resources should get these tags.
And if you're going to solve it generally, I'd copy over file, line, and version. I think 'file' copies some of these, but probably not the other generating resources. We actually need a generic "context" concept that manages all of this. If we add 'class' and 'module' to the context, we're going to find a ton of these places where we're copying some of the info over but not all of it. I'm comfortable choosing the simple solution for now, but maybe open a ticket for the general concept? On Nov 11, 2009, at 5:13 AM, Brice Figureau wrote: > > This problem affects all types that generate sub-resources at > evaluation time. > Thus it is fixed in the transaction, where we make sure we assign > all parent tags to the generated child resource. > > Signed-off-by: Brice Figureau <brice-pup...@daysofwonder.com> > --- > lib/puppet/transaction.rb | 2 +- > spec/unit/transaction.rb | 13 +++++++++++++ > 2 files changed, 14 insertions(+), 1 deletions(-) > > diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb > index d04856d..9827f40 100644 > --- a/lib/puppet/transaction.rb > +++ b/lib/puppet/transaction.rb > @@ -188,7 +188,7 @@ class Transaction > > # See if the resource generates new resources at evaluation time. > def eval_generate(resource) > - generate_additional_resources(resource, :eval_generate) > + > generate_additional_resources(resource, :eval_generate).each { |c| > c.tag(*resource.tags) } > end > > # Evaluate a single resource. > diff --git a/spec/unit/transaction.rb b/spec/unit/transaction.rb > index 7966c7a..b6e866c 100755 > --- a/spec/unit/transaction.rb > +++ b/spec/unit/transaction.rb > @@ -51,6 +51,19 @@ describe Puppet::Transaction do > > > @transaction > .generate_additional_resources(generator, :generate).should be_empty > end > + > + it "should copy all tags to the new child resources" do > + child = stub 'child' > + resource = stub 'resource', :tags => ["one", "two"] > + > + @catalog = Puppet::Resource::Catalog.new > + @transaction = Puppet::Transaction.new(@catalog) > + > @transaction > .stubs > (:generate_additional_resources > ).with(resource, :eval_generate).returns([child]) > + > + child.expects(:tag).with("one", "two") > + > + @transaction.eval_generate(resource) > + end > end > > describe "when skipping a resource" do > -- > 1.6.5.2 > > > > -- I worry that the person who thought up Muzak may be thinking up something else. -- Lily Tomlin --------------------------------------------------------------------- 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 puppet-dev@googlegroups.com To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en -~----------~----~----~----~------~----~------~--~---