puppetlabs/puppetdb — pull request #200 by cprice-puppet (2012-07-05 21:06:02+00:00)
Title: (#15321) Add aliases for namevars that are munged via title_pattern

When we are creating aliases for resources (in order to ensure
dependency resolution in the catalog), we need to take into account
the case where the resource type defines one or more title_patterns,
which, when used to set the value of the namevar, may munge the value
via regex awesomeness. 'File' is an example of such a resource, as
it will strip trailing slashes from the title to set the :path
parameter if :path is not specified.

Because this title_pattern munging happens as a side effect of the
Puppet::Resource#to_hash method, it is important that our namevar
alias code search that hash for necessary aliases rather than
searching the Puppet::Resource instance directly.

This commit changes add_namevar_aliases to do that. I plan to
file a ticket for puppet core about the fact that the to_hash
method probably should not need to be relied upon to trigger
this side effect.