Client Version: v1.19.0 GoVersion: go1.15
Server Version: v1.28.2 GoVersion: go1.20.8
Hi,
I’m trying to build a go template file that would print the pod name if pod uses particular secret.
As part of it I’m ranging over env/envFrom/volumes to check if that secret is used.
Some pods have however multiple environment variables using the same secret so the pod name is printed out several times.
I tried to put {{continue}} and {{break}} into the template but got and error:
error: error parsing template {{- range .items}}
{{- range .spec.containers}}
{{- range .env}}
{{- if .valueFrom.secretKeyRef}}
{{- if eq .valueFrom.secretKeyRef.name "my-secret"}}
{{- .metadata.name}}{{- " - "}}{{- .valueFrom.secretKeyRef.name}}{{"\n"}}
{{break}}
{{- end}}
{{- end}}
{{- end}}
{{- range .envFrom}}
{{- if .secretRef}}
{{- if eq .secretRef.name "my-secret"}}
{{- .metadata.name}}{{- " - "}}{{- .valueFrom.secretKeyRef.name}}{{"\n"}}
{{break}}
{{- end}}
{{- end}}
{{- end}}
{{- end}}
{{- range .spec.volumes}}
{{- if .secret }}
{{- if eq .secret.secretName "my-secret"}}
{{- .metadata.name}}{{- " - "}}{{- .valueFrom.secretKeyRef.name}}{{"\n"}}
{{break}}
{{- end}}
{{- end}}
{{- end}}
{{- end}}
, template: output:7: function "break" not defined
I’m wondering if the supported functions are documented somewhere and/or if there’s a way to jump out of the range loop if the search term is found?