I am attempting to create a kubernetes ConfigMap with helm, which simply consists of the first line within a config file. I put my file in helm/config/file.txt
, which has several lines of content, but I only want to extract the first. My first attempt at this was to loop over the lines of the file (naturally), but quit out after the first loop:
apiVersion: v1
kind: ConfigMap
metadata:
name: one-line-cm
data:
first-line:
{{- range .Files.Lines "config/file.txt" }}
{{ . }}
{{ break }} # not a real thing
{{- end }}
Unfortunately, break
doesn't seem to be a concept/function in helm, even though it is within golang. I discovered this the hard way, as well as reading about a similar question in this other post: Helm: break loop (range) in template
I'm not stuck on using a loop, I'm just wondering if there's another solution to perform the simple task of extracting the first line from a file with helm syntax.