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

Allow type alias to define a mapping between puppet names and runtime types

    XMLWordPrintable

Details

    • New Feature
    • Status: Closed
    • Normal
    • Resolution: Fixed
    • None
    • PUP 4.5.0
    • None
    • None
    • Hide

      That the Runtime type in puppet now accepts parameters allowing it to define a mapping between a runtime type, and a puppet type name, or by mapping patterns:

      A one to one mapping:

      type MyModule::ImplementationRegistry = Object[{}]
      type Runtime[ruby, 'Puppet::Pops::Types::ImplementationRegistry'] = MyModule::ImplementationRegistry
      notice MyModule::ImplementationRegistry
      

      And a pattern based mapping:

      type MyModule::TypeMismatchDescriber = Object[{}]
      type Runtime[ruby, [/^Puppet::Pops::Types::(\\w+)$/, 'MyModule::\\1']] = [/^MyModule::(\\w+)$/, 'Puppet::Pops::Types::\\1']
      notice MyModule::TypeMismatchDescriber
      

      There is no user facing functionality at this point except being able to create an notice these mappings (as this is a technical enabler for serialization/deserialization), and that errors are raised if attempting to define mappings with illegal parameters / data types.

      Show
      That the Runtime type in puppet now accepts parameters allowing it to define a mapping between a runtime type, and a puppet type name, or by mapping patterns: A one to one mapping: type MyModule::ImplementationRegistry = Object[{}] type Runtime[ruby, 'Puppet::Pops::Types::ImplementationRegistry' ] = MyModule::ImplementationRegistry notice MyModule::ImplementationRegistry And a pattern based mapping: type MyModule::TypeMismatchDescriber = Object[{}] type Runtime[ruby, [/^Puppet::Pops::Types::(\\w+)$/, 'MyModule::\\1' ]] = [/^MyModule::(\\w+)$/, 'Puppet::Pops::Types::\\1' ] notice MyModule::TypeMismatchDescriber There is no user facing functionality at this point except being able to create an notice these mappings (as this is a technical enabler for serialization/deserialization), and that errors are raised if attempting to define mappings with illegal parameters / data types.
    • 2
    • Language 2016-04-20
    • Not Needed
    • This is a highly specialized feature for implementors of puppet and implementors of serialization protocols.

    Description

      When doing serialization between runtimes of different versions or implementation languages it is of value to be able to define the mapping between names in the puppet name space and the implementation that is performing the operation.

      This relates to PUP-5928 where it is possible to define a pattern so that each class in a package does not have to be stated and instead be matched with a pattern. The functionality in PUP-5928 is used here for further functionality.

      The type alias mechanism should be extended to give special meaning to a mapping of a Runtime type to a Puppet Type. The semantics of this is "this runtime type is a representation of this puppet type".

      As an example - this is what puppet uses internally:

      type Runtime[ruby, Float] = Float
      

      By making it possible to specify these mappings, there is nothing special or secret about any of the mappings. Serialization simply refers to a type model to know what the bindings are supposed to be in the implementation that serializes/deserializes.

      It is of great value to use the pattern in PUP--5928 to also specify the RHS:

      type Runtime['ruby', [/^Puppet::Pops::Model::(\w+)$/, 'PCore::AST::\1']] =
         [/^PCore::AST::(\w+)$/, 'Puppet::Pops::Model::\1']
      

      (Or similar syntax). This would mean, all the classes in the Ruby MyPackage that has the pattern P<something>Type would be mapped to the corresponding puppet name e.g. MyPackage::PFooType is mapped to MyModule::MyPackage::Foo as a puppet name.

      Attachments

        Issue Links

          Activity

            People

              john.duarte John Duarte
              henrik.lindberg Henrik Lindberg
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Zendesk Support