I see somewhat strange behaviour of helm template:
My tpl function does this:
{{- define "spark-k8s-application.maxExecutors" -}}
...
{{- printf "%d" .Values.application.dynamicAllocation.maxExecutors | int }}
Later I use it for a label:
labels:
spark-executors-max: {{ include "spark-k8s-application.maxExecutors" . | quote }}
But whatever number I put in my input parameters, it is always rendered as "0" How could I render the correct integer value?
CodePudding user response:
The problem was in parenthesis and operation order.
This expression works as expected:
{{- printf "%d" (.Values.application.dynamicAllocation.maxExecutors | int) }}
Looks like you have to be very explicit about order of operations in go templates.