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

Pcore ResourceType cannot handle title pattern with multiple entries

    XMLWordPrintable

Details

    • Puppet Developer Experience
    • 1
    • PDE 2017-04-19, PDE 2017-05-03, PDE 2017-05-31
    • Bug Fix
    • When using "puppet generate types" for environment isolation a type with a multipart namevar title would lead to an error of "Error: undefined method `call' for :top_level:Symbol". This is now fixed.
    • No Action
    • covered by unit tests

    Description

      The Puppet generator, when generating a .pp file that contains a definition of a Puppet::Resource::ResourceType3, will emit a hash that corresponds to the title_patterns of the original ResourceType. Each value in this hash is an array of strings. In the original type, it was an array of one element arrays (a two element array where the second element is a Proc is possible but it is not supported by the generator, hence the simplification).

      The problem is that when the generated resource is instantiated. Instead of wrapping each string into an array, the whole array of strings is mapped into an array. This entry:

      /^((.+)\/(.*))$/ => ['name', 'top_level', 'lower_level']
      

      becomes

      /^((.+)\/(.*))$/ => [ ['name', 'top_level', 'lower_level'] ]
      

      instead of

      /^((.+)\/(.*))$/ => [ ['name'], ['top_level'], ['lower_level'] ]
      

      Subsequent attemtps to use this resource type crashes with:

      Error: undefined method `call' for :top_level:Symbol
      

      since it things that an array with more than one element contains a Proc.

      Attachments

        Activity

          People

            Unassigned Unassigned
            thomas.hallgren Thomas Hallgren
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Zendesk Support