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

Mixed invocation of parameterized classes leads to order dependencies, should be disallowed


    • Type: Improvement
    • Status: Closed
    • Priority: Normal
    • Resolution: Won't Fix
    • Affects Version/s: PUP 2.7.23
    • Fix Version/s: None
    • Component/s: None
    • Labels:
    • Template:


      When a parameterized class has default values for all of its parameters, it may be invoked using either "include" or class { ... } notation. The "include" notation is idempotent; the class { ... } notation isn't. As a result, there is an order dependency. This works:

      class foo($param = defaultvalue) {
        notify { $param: }
      class { foo: param => value }
      include foo

      But this produces an error:

      class foo($param = defaultvalue) {
        notify { $param: }
      include foo
      class { foo: param => value }

      In large manifests, it is not always obvious (or even well-defined) what order statements will be executed in. To avoid user confusion, I think it would be preferable if both these examples produced an error message saying something like "class foo already invoked using 'class { ... }' syntax, cannot also invoke using 'include'".

      NF: Note that the "inherits" keyword declares the base class in a manner similar to "include," which means that if you declare a subclass of class foo (`class baz inherits foo {...} ... include baz`) and then declare class foo with the resource-like syntax (`class {'foo':}`), it'll blow up in the same way as described above.




            • Assignee:
              redmine.exporter redmine.exporter
            • Votes:
              1 Vote for this issue
              9 Start watching this issue


              • Created:

                Zendesk Support