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

Overriding a default argument with undef has no effect

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Normal
    • Resolution: Unresolved
    • Affects Version/s: PUP 5.5.10
    • Fix Version/s: None
    • Component/s: Language
    • Labels:
      None
    • Template:
      PUP Bug Template
    • Sub-team:
    • Team:
      Froyo
    • Method Found:
      Needs Assessment
    • QA Risk Assessment:
      Needs Assessment

      Description

      Puppet Version: 5.5.10
      Puppet Server Version: N/A
      OS Name/Version: Debian 10.3

      $ cat testcase.pp
      define resource($key = $name) {
        if($key == undef ){
          warning("Case 1")
        } else {
          warning("Case 2")
        }
      }
      resource{'blub':
        key => undef
      }
      $ puppet apply testcase.pp
      

      Desired Behavior:

      Warning: Scope(Resource[blub]): Case 1
      

      Actual Behavior:

      Warning: Scope(Resource[blub]): Case 2
      

      The behavior seems to be kind-of intended:

      From the docs:

      The undef value is useful for testing whether a variable has been set. Also, you can use it to un-set resource attributes that have inherited values from a resource default, causing the attribute to be unmanaged.

      So do I see this correctly that there is no way to pass "undef" to a resource which has a default assigned to the specific parameter?

      Because it would seem natural to me, to have a resource, with an optional parameter, that has some default value, with the option to un-set this default value on a per-instance basis.

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            duWKy1 Felix
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:

                Zendesk Support