Introduce a named-template to explicitely interpret values

Summary

As explained in our chart, and used in many places in values.yaml, we have to explicitly force the interpretation of values that contain gotpl when they are referred by other values.

For example, following values:

a: foo
b: '{{ .Values.a }}'
c: '{{ .Values.b | b64enc }}'

The value of c would be unpredictable, as we can't guarantee that b has be has already be interpreted when c is evaluated. If not, c could evaluate to e3sgLlZhbHVlcy5hIH19Cg== (the base64 encoding of "{{ .Values.a }}" string) instead of Zm9vCg== (the base64 encoding of "foo")

Few named templates have been developed to force that interpretation (like 'interpret-as-string'), that can be used as following to force value interpretation:

c: '{{ tuple . .Values.b | include "interpret-as-string" | b64enc }}'

But they don't work in every circumstances, for example we don't have any solutions for values that would render complex types, and have to use following syntax (like here) that is not user friendly:

foo: '{{- index (tuple . .Values.bar | include "interpret-inner-gotpl" | fromJson) "result" | do-something-with-value }}'

The idea would be to introduce an interpret template that can be called upfront to force the interpretation of a given value:

foo: '{{- tuple . ".bar" | include "interpret" }}{{ .Values.bar | do-something-with-value }}'

Similarly, first example would become:

c: '{{- tuple . ".b" | include "interpret" }}{{ .Values.b | b64enc }}'

It would be much easier to use, as developpers wouldn't have to deal with the type of value any more.

Edited Sep 27, 2024 by Francois Eleouet
Assignee Loading
Time tracking Loading