Uploaded image for project: 'Puppet Development Kit'
  1. Puppet Development Kit
  2. PDK-1104

`pdk new ...` does not use the module's configured template, falls back to default template

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: PDK 1.7.0
    • Fix Version/s: PDK 1.8.0
    • Component/s: None
    • Environment:

      PDK: 1.7.0.pre (11)
      OS: Linux Debian testing

    • Template:
    • Team:
      Puppet Developer Experience
    • Method Found:
      Needs Assessment
    • Release Notes:
      Bug Fix
    • Release Notes Summary:
      This fixes a bug where PDK did not use the configured/specified template-url from the metadata.json when generating resources like class and defined_types.
    • QA Risk Assessment:
      Needs Assessment

      Description

      When creating a module from scratch using a custom template:

      david@davids:~/tmp$ pdk new module --template-url /home/david/git/pdk-templates/ --skip-interview test
      pdk (INFO): Creating new module: test
      pdk (INFO): Module 'test' generated at path '/home/david/tmp/test', from template '/home/david/git/pdk-templates/'.
      pdk (INFO): In your module directory, add classes with the 'pdk new class' command.
      david@davids:~/tmp$ cd test
      david@davids:~/tmp/test$ grep template metadata.json 
        "template-url": "/home/david/git/pdk-templates/",
        "template-ref": "heads/master-0-g6152319"
      david@davids:~/tmp/test$ pdk new class test2 --debug
      pdk (DEBUG): Using '/opt/puppetlabs/pdk/private/git/bin/git' from PDK package.
      pdk (DEBUG): Using '/opt/puppetlabs/pdk/private/git/bin/git' from PDK package.
      pdk (DEBUG): Executing '/opt/puppetlabs/pdk/private/git/bin/git ls-remote --exit-code file:///opt/puppetlabs/pdk/share/cache/pdk-templates.git'
      pdk (DEBUG): Execution of '/opt/puppetlabs/pdk/private/git/bin/git ls-remote --exit-code file:///opt/puppetlabs/pdk/share/cache/pdk-templates.git' complete (duration: 0.004242951s; exit code: 0)
      pdk (DEBUG): Using '/opt/puppetlabs/pdk/private/git/bin/git' from PDK package.
      pdk (DEBUG): Using '/opt/puppetlabs/pdk/private/git/bin/git' from PDK package.
      pdk (DEBUG): Executing '/opt/puppetlabs/pdk/private/git/bin/git clone file:///opt/puppetlabs/pdk/share/cache/pdk-templates.git /tmp/pdk-templates20180806-4380-1c93a4x'
      pdk (DEBUG): Execution of '/opt/puppetlabs/pdk/private/git/bin/git clone file:///opt/puppetlabs/pdk/share/cache/pdk-templates.git /tmp/pdk-templates20180806-4380-1c93a4x' complete (duration: 0.063834365s; exit code: 0)
      pdk (DEBUG): Using '/opt/puppetlabs/pdk/private/git/bin/git' from PDK package.
      pdk (DEBUG): Using '/opt/puppetlabs/pdk/private/git/bin/git' from PDK package.
      pdk (DEBUG): Executing '/opt/puppetlabs/pdk/private/git/bin/git -C /tmp/pdk-templates20180806-4380-1c93a4x reset --hard origin/master'
      pdk (DEBUG): Execution of '/opt/puppetlabs/pdk/private/git/bin/git -C /tmp/pdk-templates20180806-4380-1c93a4x reset --hard origin/master' complete (duration: 0.008775366s; exit code: 0)
      pdk (INFO): Creating '/home/david/tmp/test/manifests/test2.pp' from template.
      pdk (INFO): Creating '/home/david/tmp/test/spec/classes/test2_spec.rb' from template.
      david@davids:~/tmp/test$ 
      

      As you can see, the custom template is recorded correctly in the metadata.json, but subsequent PDK commands to not use that value, causing (potentially) incompatible templates to be used.

      Specifying the template url on the new class commandline seems to do the right thing:

      david@davids:~/tmp/test$ pdk new class test5 --template-url /home/david/git/pdk-templates/ --debug
      pdk (DEBUG): Using '/opt/puppetlabs/pdk/private/git/bin/git' from PDK package.
      pdk (DEBUG): Using '/opt/puppetlabs/pdk/private/git/bin/git' from PDK package.
      pdk (DEBUG): Executing '/opt/puppetlabs/pdk/private/git/bin/git rev-parse --is-bare-repository'
      pdk (DEBUG): Execution of '/opt/puppetlabs/pdk/private/git/bin/git rev-parse --is-bare-repository' complete (duration: 0.002430066s; exit code: 128)
      pdk (INFO): Creating '/home/david/tmp/test/manifests/test5.pp' from template.
      pdk (INFO): Creating '/home/david/tmp/test/spec/classes/test5_spec.rb' from template.
      david@davids:~/tmp/test$ 
      

      I could confirm that this call used the specified template and not the default template.

        Attachments

          Activity

            jsd-sla-details-panel

              People

              • Assignee:
                tim.sharpe Tim Sharpe
                Reporter:
                david.schmitt David Schmitt
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: