Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-1985

Allow function & class & define parameters to reference earlier parameters

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: PUP 4.4.0
    • Component/s: Compiler
    • Labels:
    • Template:
    • Epic Link:
    • Story Points:
      2
    • Sprint:
      Language 2016-01-13, Language 2016-01-27, Language 2016-02-10, Language 2016-02-24
    • CS Priority:
      Normal
    • Release Notes:
      New Feature
    • Release Notes Summary:
      It is now allowed to reference earlier parameters in a default expression in a class, define or puppet language function. This used to be unspecified behavior and did only work by chance under certain circumstances.

      Description

      It would be good if code like this was possible:

      class postgresql (
        $version = '9.0',
        $datadir = "/var/lib/postgresql/${version}/main",
      ) { ... }
      

      or used in expressions:

      class foo (
        $concurrent_reads = 20,
        $concurrent_writes = $concurrent_reads/2,
      ) { ... }
      

      Some of this can be possible to workaround using class inheritance, but for each reference you need another layer of inheritance and it also results in weird parameter naming for the data bindings. Like having to specify postgresql::params::version but then postgresql::datadir.

      UPDATE
      The full specification of how a default value expression may reference other parameters is found in the puppet specification repository https://github.com/puppetlabs/puppet-specifications/blob/master/language/parameter_scope.md, and in the details describing the catalog types (class and define), and details for puppet function.

        Attachments

          Issue Links

            Activity

              jsd-sla-details-panel

                People

                • Assignee:
                  Unassigned
                  Reporter:
                  redmine.exporter redmine.exporter
                  QA Contact:
                  Kurt Wall
                • Votes:
                  4 Vote for this issue
                  Watchers:
                  13 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:

                    Zendesk Support