I have a range function but would like to break from the control if certain condition is met. Is there a way this can be achieved in helm template
UPDATE:
I have seen some related queries where conclusion is "break" is unsupported. But would like to get some official documentation OR reason in case this is not supported.
Have some good news here! Not sure from which exact version of helm
the update happened but you can for sure use the break
in your templates with the newest helm@v3.12.0.
This is because the new version of helm bumped the go
version to 1.20
and the break
has been introduced in the text/template
in go v1.18
.
So now you can do stuff like this:
{{- range $i, $e := until 10 -}}
{{- if lt $i 5 -}}
Less than five.
{{- else -}}
{{- break -}}
{{- end -}}
{{- end -}}
Happy helming!