Issue #21567 has been reported by Adrien Thebo.

----------------------------------------
Bug #21567: Canonized type names and resource titles can only be looked up by 
creating a Puppet::Resource
https://projects.puppetlabs.com/issues/21567

* Author: Adrien Thebo
* Status: Unreviewed
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* Affected Puppet version: 
* Keywords: 
* Branch: 
----------------------------------------
When creating a new `Puppet::Resource` instance, the new object canonizes a 
number of values like the type and title for a given resource. Moreover the 
`Puppet::Resource` is the only class that can create these canonized values. 
This means that in a number of places we are forced to create a new Puppet 
resource with all the work that entails just to grab a single value and throw 
away everything else for the garbage collector.

- - -

In order to get a canonized type name, a new `Puppet::Resource` has to be 
created just to extract the canonized type, and that `Puppet::Resource` is then 
thrown away:

  * 
https://github.com/puppetlabs/puppet/blob/3.2.2/lib/puppet/parser/ast/resource_defaults.rb#L15
  * 
https://github.com/puppetlabs/puppet/blob/3.2.2/lib/puppet/parser/collector.rb#L77
  * 
https://github.com/puppetlabs/puppet/blob/3.2.2/lib/puppet/transaction/report.rb#L339

- - -

The same problem occurs when trying to generate a resource reference.

When the catalog needs to look up a resource by title, it has to create a [new 
resource](https://github.com/puppetlabs/puppet/blob/3.2.2/lib/puppet/resource/catalog.rb#L367)
 to determine the resource reference that's being used to index the actual 
resource. The Puppet::Resource itself has a method to [look 
up](https://github.com/puppetlabs/puppet/blob/3.2.2/lib/puppet/resource.rb#L226)
 an identical resource in the catalog.

This is tangentially related to #15106 because 
`Puppet::Resource::Catalog#resource` generates a new resource every time that 
method is invoked, and inspecting the resource triggers #15106 in certain 
conditions.


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-bugs.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to