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

Document how to handle multiline strings in policy templates

XMLWordPrintable

    • False
    • None
    • False
    • No

      Create an informative issue (See each section, incomplete templates/issues won't be triaged)

      Prerequisite: Start with what we have

      Please document the workaround described in this case . I'd like a new section under Template processing introduction

      Draft:

      When handling multi-line string values such as a certificates, always add ` | toRawJson | toLiteral` at the end of the template pipeline for proper handling of line breaks. For example, if you are copying a certificate from a `Secret` and including it in a `ConfigMap`, the template pipeline may look like the following:

       ca.crt: '{{ fromSecret "openshift-config" "ca-config-map-secret" "ca.crt"  | base64dec | toRawJson | toLiteral }}'
      

      The reason why this works is that `toRawJson` converts the input value to a JSON string with new lines escaped. For example, `key: '{{ 'hello\nworld' | toRawJson }}'` would output `key: '"hello\nworld"'` after the templates are processed. Then `toLiteral` is required to remove the outer single quotes that were required in the policy definition. So the result of `key: '{{ 'hello\nworld' | toRawJson |toLiteral }}'`is `key: "hello\nworld"`.

      Describe the changes in the doc and link to your dev story

      Provide info for the following steps:

      1. - [x] Mandatory Add the required version to the Fix version/s field.

      2. - [ ] Mandatory Choose the type of documentation change.

            - [ ] New topic in an existing section or new section
            - [x] Update to an existing topic

      3. - [ ] Mandatory for GA content:
                  
             - [ ] Add steps and/or other important conceptual information here: 
             
                  
             - [ ] Add Required access level for the user to complete the task here:
             

             - [ ] Add verification at the end of the task, how does the user verify success (a command to run or a result to see?)
           
           
             - [ ] Add link to dev story here:

      4. - [ ] Mandatory for bugs: What is the diff? Clearly define what the problem is, what the change is, and link to the current documentation:

              mdockery@redhat.com Mikela Jackson
              mprahl Matthew Prahl
              Derek Ho Derek Ho
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: