Uploaded image for project: 'Modules'
  1. Modules
  2. MODULES-2760

DSC - Refactor type validation into helpers

    XMLWordPrintable

Details

    • Task
    • Status: Accepted
    • Normal
    • Resolution: Unresolved
    • None
    • None
    • dsc
    • Hide

      Given a DSC test run
      When the tests are run
      Then they complete in less time

      Given input DSC resource definitions
      When generating their Puppet types with our build process
      Then less code will be produced for each type and less tests will be produced for each type

      Fewer duplicate tests will run.

      Show
      Given a DSC test run When the tests are run Then they complete in less time Given input DSC resource definitions When generating their Puppet types with our build process Then less code will be produced for each type and less tests will be produced for each type Fewer duplicate tests will run.
    • Windows
    • 2

    Description

      Currently, validation of Puppet types is performed when code generation produces the types - https://github.com/puppetlabs/puppetlabs-dsc/blob/master/build/dsc/templates/dsc_type.rb.erb#L139-L206

      However, for other reasons (principally for handling EmbeddedInstance values), each property now carries with it, it's original MOF type per https://github.com/puppetlabs/puppetlabs-dsc/blob/master/build/dsc/templates/dsc_type.rb.erb#L112

      Further, helpers were added at https://github.com/puppetlabs/puppetlabs-dsc/blob/master/lib/puppet_x/puppetlabs/dsc_type_helpers.rb for common munging behavior and for validating mof types.

      Therefore, we should be able to rewrite the validation procedures to use these helpers instead of always modifying type generation templates. This has the positives of

      • Reducing the amount of code generation churn
      • Easily changing behavior in one location
      • Simplification of the ERB template for generating types, which is starting to get unwieldy
      • Reducing the overall amount of code maintained

       

      Steps to produce:

      • add unit tests for existing methods in dsc_type_helpers to dsc_type_helpers_spec.rb
      • identify validation code that can be moved without extra work to dsc_type_helpers.rb in dsc_type.rb.erb
      • investigate how to handle code that cannot be moved from template syntax

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              ethan Ethan Brown
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Zendesk Support