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

Add ability to create Aliases for Puppet Types in PL

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: PUP 4.4.0
    • Component/s: Docs, Language
    • Labels:
      None
    • Template:
    • Story Points:
      3
    • Sprint:
      Language 2016-01-27, Language 2016-02-10, Language 2016-02-24
    • Release Notes:
      New Feature
    • Release Notes Summary:
      Hide
      It is now possible to define aliases for data types. The aliases are auto loaded from .pp files under a modules <root>/types/ and the filename must match that alias name. The alias is defined as in this simple example:

      type MyInteger = Integer

      This is used to create reusable and descriptive types.
      Show
      It is now possible to define aliases for data types. The aliases are auto loaded from .pp files under a modules <root>/types/ and the filename must match that alias name. The alias is defined as in this simple example: type MyInteger = Integer This is used to create reusable and descriptive types.

      Description

      An Puppet Type expression is often reused. It's also not uncommon that fairly complex expressions are repeated inside of an other expression. A mechanism for creating an alias for such types is therefore much needed. With this in place, a common pattern like:

      Pattern[/^((:?::)?[A-Z][\w]*)+$/]
      

      could be named and then referenced in other places.

      type QName = Pattern[/^((:?::)?[A-Z][\w]*)+$/]
      

      Similar to functions, it must be possible (and recommended) to use a prefix to avoid to clobber the global scope. The above example can then be written as:

      type PCore::QName = Pattern[/^((:?::)?[A-Z][\w]*)+$/]
      

      Aliases must be loaded the same way as functions, using the autoloader.
      When declaring an alias, it must be possible for the type declaration to reference the declared alias. I.e. it must be possible to declare things like:

      type TreeNode = Hash[String[1],TreeNode]
      

      which means that the TypeParser parsing the RHS must be aware of the pending alias declaration.

        Attachments

          Activity

            jsd-sla-details-panel

              People

              • Assignee:
                Unassigned
                Reporter:
                thomas.hallgren Thomas Hallgren
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Zendesk Support