puppetlabs / puppet-specifications

Specification of the Puppet Language, Catalog, Extension points
Other
99 stars 66 forks source link

document that all class and definition parameters are available as local variables (including meta parameters) #88

Open ody opened 8 years ago

ody commented 8 years ago

Adam Vinsh from the Puppet OpenStack module community brought up in IRC this morning that they discovered that they could use $require in the local scope of a defined type[1].

This got me wondering how local variables are generated from parameters and specifically how this intertwines with meta parameters. I was able to follow a path in the Puppet source that seemed to validate that all parameters of a resource are added to parameter scope[2] and that parameter scope will eventually make it into local scope by virtual of traveling through ephemeral scope[3]. Combine this with the specification that meta parameters are available in parameter scope[4] and it seems that you have an implicit behavior that one should expect that all meta parameters and their values are available in local scope.

[1] https://review.openstack.org/#/c/378950/10/manifests/service.pp [2] https://github.com/puppetlabs/puppet/blob/master/lib/puppet/resource/type.rb#L347-L387 [3] https://github.com/puppetlabs/puppet/blob/master/lib/puppet/parser/scope.rb#L928 [4] https://github.com/puppetlabs/puppet-specifications/blob/master/language/parameter_scope.md#meta-parameters-are-available-in-parameter-scope

ody commented 8 years ago

Make a PUP ticket in Jira per the request of @hlindberg: https://tickets.puppetlabs.com/browse/PUP-6776