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

Fix various type system glitches, Puppet Data type should be limited to JSON types.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: PUP 5.0.0
    • Component/s: Docs
    • Labels:
      None
    • Template:
    • Acceptance Criteria:
      Hide

      That the following statement notices an array of "true":

      notice([Boolean, Numeric, String, Undef, Array[Data], Hash[String, Data]].map |$t| { $t < Data })

      and that the following statement notices an array of "false"

      notice([Scalar, Regexp, Variant[Data,Scalar],Array[Scalar], Hash[Integer, Data]].map |$t| { $t < Data })

      Show
      That the following statement notices an array of "true": notice([Boolean, Numeric, String, Undef, Array[Data], Hash[String, Data]].map | $t | { $t < Data }) and that the following statement notices an array of "false" notice([Scalar, Regexp, Variant[Data,Scalar],Array[Scalar], Hash[Integer, Data]].map | $t | { $t < Data })
    • Team:
      Puppet Developer Experience
    • Story Points:
      2
    • Sprint:
      PDE 2017-05-03, PDE 2017-05-31
    • Release Notes:
      New Feature
    • Release Notes Summary:
      Hide
      The definition of the {{Data}} data type has changed slightly. It is now restricted to only include those types that can be represented directly in JSON. This was the intention when the {{Data}} data type was introduced, but data types that should not have been allowed were accidentally included (notably {{Regexp}}). Now the {{Data}} type also restricts the data type of hash keys - they must now be of {{String}} type. These mistakes are now fixed in Puppet 5.0.0 and this makes the {{Data}} data type far more useful.

      The types {{Hash}} and {{Array}}, when used without any parameterized types, now defaults to {{Array\[Any]}} and {{Hash\[Any, Any]}} ({{Any}} is now used instead of {{Data}}). This means that unparameterized use of {{Array}} and {{Hash}} does not have to change due to the added constraints in {{Data}}. Explicit use of {{Data}} as a parameter data type may need to be revised in your manifests.

      A new data type {{RichData}} has been introduced. It matches all other data types except the {{Runtime}}, {{Iterator}}, {{Iterable}}, and {Callable}} data types.

      A new data type {{ScalarData}} has been added that matches only those scalar data types that can be directly represented in JSON ({{String}}, {{Integer}}, {{Float}}, and {{Boolean}}.

      The {{SemVerRange}} data type was earlier erroneously a subtype of {{Scalar}}. It is now a subtype of {{Any}}.
       
      As a bonus, the error reporting has been improved in that type mismatch errors retains information about type alias rather than just expanding the alias in the error output.
      Show
      The definition of the {{Data}} data type has changed slightly. It is now restricted to only include those types that can be represented directly in JSON. This was the intention when the {{Data}} data type was introduced, but data types that should not have been allowed were accidentally included (notably {{Regexp}}). Now the {{Data}} type also restricts the data type of hash keys - they must now be of {{String}} type. These mistakes are now fixed in Puppet 5.0.0 and this makes the {{Data}} data type far more useful. The types {{Hash}} and {{Array}}, when used without any parameterized types, now defaults to {{Array\[Any]}} and {{Hash\[Any, Any]}} ({{Any}} is now used instead of {{Data}}). This means that unparameterized use of {{Array}} and {{Hash}} does not have to change due to the added constraints in {{Data}}. Explicit use of {{Data}} as a parameter data type may need to be revised in your manifests. A new data type {{RichData}} has been introduced. It matches all other data types except the {{Runtime}}, {{Iterator}}, {{Iterable}}, and {Callable}} data types. A new data type {{ScalarData}} has been added that matches only those scalar data types that can be directly represented in JSON ({{String}}, {{Integer}}, {{Float}}, and {{Boolean}}. The {{SemVerRange}} data type was earlier erroneously a subtype of {{Scalar}}. It is now a subtype of {{Any}}.   As a bonus, the error reporting has been improved in that type mismatch errors retains information about type alias rather than just expanding the alias in the error output.
    • QA Risk Assessment:
      No Action

      Description

      The motivation behind the Data type is that instances of this type can be represented as JSON without conversion. As such, it must only represent the following:

      Data
      |- Boolean
      |- Integer
      |- Float
      |- String
      |- Undef
      |- Array[Data]
      |- Hash[String,Data]
      

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved:

                  Zendesk Support