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

add ability to lookup "below" in hierarchy

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Ready for Engineering
    • Priority: Normal
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: PUP 5.y
    • Component/s: None
    • Labels:
      None
    • Template:
    • Epic Link:
    • Sub-team:
    • Team:
      Froyo
    • Story Points:
      2
    • Sprint:
      PDE 2017-03-22, PDE 2017-04-05, PDE 2017-04-19, Language Triage
    • QA Risk Assessment:
      Needs Assessment

      Description

      In order to be able to filter or modify a value bound at a lower precedence in ways that the built in hiera interpolation or aliasing features can handle it is of great value to be able to lookup the value that would be the result of lower precedence entries and return that.

      This mechanism should be available via the $context object via a lookup_below(key). This method takes a no args lambda that is called if the lookup results in not_found. If no lambda is given and the lookup_below(key) results in not_found that also becomes the result of the function calling lookup_below (it does not return to it).

      The rest of the arguments to the lookup_below are the same as for a lookup.

      As an example a user may do something like this for the lookup of key

      return "some prefix: #{context.lookup_below(key)"
      

      Without the lookup_below feature this is impossible since a lookup of the same key would lead to an endless recursion and hiera would error out.

      This mechanism can thus be used to implement filter/map like behavior, change the data type etc. As an example, a function could filter all "password" keys to wrap them as Sensitive values, a lookup of a hash 'x', could add entries to that hash that comes from other keys, and other similar advanced cases.

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:

                Zendesk Support