Uploaded image for project: 'Red Hat Advanced Cluster Management'
  1. Red Hat Advanced Cluster Management
  2. ACM-7720

[RFE] add support for the `trunc` and `trimAll` sprig functions to template processing

XMLWordPrintable

    • False
    • None
    • False
    • Hide

      Provide the required acceptance criteria using this template.
      * `trunc` sprig function is available in PolicyGenerator templating
      * `trimAll` sprig function is available in PolicyGenerator templating
      Show
      Provide the required acceptance criteria using this template. * `trunc` sprig function is available in PolicyGenerator templating * `trimAll` sprig function is available in PolicyGenerator templating
    • GRC Sprint 2023-18
    • No

      Value Statement

      When dealing with templatizing kube resources, such as is done with PolicyGenerator there is often cause to generate dynamic resource names. when generating dynamic resource names you always have to be concerned about exceeding the 63 char limit for resource names. the way this problem is solved in the helm world is by using the `trunc` and `trimAll` functions such as:
      {{}}
      name: '{{ printf "%s-%s" myvar "my-post-fix" | trunc 63 | trimAll "" }}'
      But we dont have access to the trunc and trimAll functions in ACM templates at the moment.

      Using the list of funcitons currently avaialbe (https://access.redhat.com/documentation/en-us/red_hat_advanced_cluster_management_for_kubernetes/2.8/html-single/governance/index#open-source-community-functions) i can't even find a work around to achieve this same result, none of the string functions needed for dynamically cutting down a string are available.

      This essentially means its impossible to safely have dynamic resource names when creating PolicyGenerator templates because you run the risk of exceeding the 63 char limit (as i found out the hard way at a client).

      Definition of Done for Engineering Story Owner (Checklist)

      • ...

      Development Complete

      • The code is complete.
      • Functionality is working.
      • Any required downstream Docker file changes are made.

      Tests Automated

      • [ ] Unit/function tests have been automated and incorporated into the
        build.
      • [ ] 100% automated unit/function test coverage for new or changed APIs.

      Secure Design

      • [ ] Security has been assessed and incorporated into your threat model.

      Multidisciplinary Teams Readiness

      Support Readiness

      • [ ] The must-gather script has been updated.

              rhn-support-bjarvis Brian Jarvis
              itewksbu@redhat.com Ian Tewskbury
              Derek Ho Derek Ho
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved: