Skip to content

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

@ody

Description

@ody

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions