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

Using eval_generate with a compound name_vars without a name appears to not work

    XMLWordPrintable

    Details

    • Template:
      PUP Bug Template
    • Team:
      Coremunity
    • Method Found:
      Inspection
    • QA Risk Assessment:
      Needs Assessment

      Description

      I have a custom type called registry_key with an eval_generate method which can purge values. The resource types created by eval_generate are registry_value which is now a type with compound namevars. When creating an instance of the type, it is required to pass a title (compound namevar types appear to need something simple as a resource key)

      This is fine and all works ok.... however in a proper puppet run the generated resources do not appear in the catalog correctly.

      I've tracked it down to:
      https://github.com/puppetlabs/puppet/blob/master/lib/puppet/transaction/additional_resource_generator.rb#L66

       made = Hash[generated.map(&:name).zip(generated)]
      

      It appears that this code takes each resources :name method and does "something" with it. The issue becomes that the compound namevar types return `nil` for it's name which then screws up the catalog.

      After digging into the Puppet::Type type I found a commit (https://github.com/puppetlabs/puppet/commit/607d7c6afec7ab73203382676cc98b6d52898e1d) from Luke back in 2006 which was converting the Puppet::Type name method into title. It appears that additional_resource_generator.rb was never updated to reflect this.

      Also there are quotes in the code from that commit

      +    # For now, leave the 'name' method functioning like it used to.  Once 'title'
      +    # works everywhere, I'll switch it.
      

      Currently:
      https://github.com/puppetlabs/puppet/blob/master/lib/puppet/type.rb#L2535-L2543

      Would it be safe to switch it now after 12 years?

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              glenn.sarti Glenn Sarti
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:

                  Zendesk Support