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

Add service for obtaining class information per environment

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: PUP 4.3.0
    • Component/s: None
    • Labels:
      None
    • Template:
    • Story Points:
      3
    • Sprint:
      Language 2015-07-22, Language 2015-08-05
    • Release Notes:
      Not Needed
    • Release Notes Summary:
      Part of larger feature - this alone is only an enabler.

      Description

      A new service is needed to be able to efficiently obtain information about a list of classes and their parameters in an environment. Before this, close to a full catalog build was required to obtain this information.

      The new API:

      • Is defined in Puppet::InfoService that has class level methods that defines services
      • A class level method classes_per_environment that produces information about available classes and their parameters

      The classes_per_environment takes a hash as an argument (with a map of environment name to files) as follows:

      { 'env1' => [ 'path1/file.pp', ...], 'env2' => [ ... ] }
      

      The aggregate result should look like this:

      {
      'environment' => {
        'filename' => {
          :error     => 'errormessage',
          :classes => [
            { :name => 'classname',
              :params => [
                { :name => 'paramname',
                  :type => 'puppettype',
                  :default_source => '....',
                  :default_literal => <OBJECT>
                },
               # next param
              ],
            # next class
            ],
        # next file
        },
      # next env
      }
      

      Where:

      • :error - if the file could not be parsed or has validation errors, this entry contains the error message, and there is no :classes entry
      • :classes - an array of hashes, each hash describing one class, may be empty if there are no classes in the file
      • :name => 'classname' - is the fully qualitfed name of the class as a String
      • :params - is an array of parameters for the class, non existing if there are no parameters
      • :name => 'paramname' - is the name of a parameter in the class as a String
      • :type => 'puppettype' - is the Puppet Type in String form if the parameter is explicitly typed
      • :default_source - is the source text that forms the default value expression
      • :default_literal' - is the default value literal, if the default value expression is a literal expression. The value is a numeric, string, boolean, array or hash and for array or hash, the keys and values must be literal (same rule recursively).

      Invariants:

      • A parameter that has a literal default expression has 'default_literal' set. If a default expression is given and it is not literal, then the 'default_source' value is set. If there is no default value expression (the parameter is required), neither default_source nor default_literal will be set.
      • A parameter that is untyped, and has no default value expression is mapped to an empty hash.
      • A file that did not parser, or had validation errors contains a :error entry, but no :classes
      • A file that parsed and validated does not have a :error entry

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                henrik.lindberg Henrik Lindberg
              • Votes:
                0 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Zendesk Support