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

Make $title and $name Reserved Words

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: PUP 3.7.0
    • Component/s: Compiler, Docs
    • Labels:
      None
    • Template:
    • Story Points:
      1
    • Sprint:
      2014-07-23

      Description

      If one creates a class with $name or $title in it and assigns them default values, if a user later tries to instantiate this class using the default values, Puppet will generate an error.

      Consider the following:
      The setup:

      # manifests/init.pp
      class pup514 {
        define bark(String $name = 'No Name', Integer $phone = 0) {
          notice "Name: '$name', Number: '$phone'"
        }
      }  
       
      # tests/init.pp
      pup514::bark { 'obj1': name => 'Jenny', phone => 8675309, }
      pup514::bark { 'obj2': name => 'Pennsylvania', phone => 65000, }
      pup514::bark { 'obj3': name => 'Rhonda', }
      pup514::bark { 'obj4': phone => 42, }
      pup514::bark { 'obj5': }
      

      The output from this manifest is not quite what I expected. Specifically, for obj4 and obj5, I was expecting the default values to be used where the parameters are missing.

      $ be puppet apply krw-pup514/tests/init.pp
      Notice: Name: 'Jenny', Number: '8675309'
      Notice: Name: 'Pennsylvania', Number: '65000'
      Notice: Name: 'Rhonda', Number: '0'
      Error: Cannot reassign variable name on node ubuntu.localdomain
      Error: Cannot reassign variable name on node ubuntu.localdomain
      

      I expected:

      Notice: Name: 'Jenny', Number: '8675309'
      Notice: Name: 'Pennsylvania', Number: '65000'
      Notice: Name: 'Rhonda', Number: '0'
      Notice: Name: 'No Name', Number: '42'
      Notice: Name: 'No Name', Number: '0'
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              kurt.wall Kurt Wall
              QA Contact:
              Kurt Wall Kurt Wall
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Zendesk Support