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

4.x function api should contain way to add type aliases

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: PUP 4.5.0
    • Component/s: None
    • Labels:
      None
    • Template:
    • Epic Link:
    • Story Points:
      3
    • Sprint:
      Language 2016-03-23
    • Release Notes:
      New Feature
    • Release Notes Summary:
      The 4.x Function API for Ruby functions now has a mechanism that allows defining local complex types. This avoids long strings and repetition when specifying the data types of function parameters.

      Description

      For complex function parameters it is difficult to write the type signatures in a 4.x function API.
      As an example look at the 4.x function lookup(). In that function string variables and interpolation is used to define the the types of parameters in string form.

      It would be very useful if a function could add type aliases to the type system and then use those in the dispatcher.

      Tools like Puppet String would then be able to find them (it cannot understand the string interpolations. Users would also be helped, when they get an error, by the name of the type (along with an expanded details mis-match).

      It should be easy to come up with a type alias API, but a more difficult question is how to name these type aliases. A function in a module would naturally place the types in the module's name space. But what about an environment? Or in puppet? (which uses the global namespace).

      Somehow, it seems appropriate if the aliases, if being specific to a single function (and hence defined there) would use a name related to the function. If the types are more general, they should naturally not be introduced in a function.

      This leads to a couple of design decisions:

      • What is the namespace of type aliases in puppet itself?
      • 4.x function API for type aliases for parameters
      • In a Puppet Function, should we allow it to introduce type aliases as well as defining the function? (Now that is not allowed).
      • Where do we place general type aliases in Puppet?

      Example

      #... in a 4.x function
      local_types {
        type 'MyModule::PullSled::OhDeer = 'Enum[...]'
      }
      dispatch :some_method {
        param 'MyModule::PullSled::OhDeer' :a_deer
      }
      #... etc
      

      }

        Attachments

          Issue Links

            Activity

              jsd-sla-details-panel

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved: