apiVersion: v1
kind: Secret
metadata:
  name: {{ .Release.Name }}-env
type: Opaque
data:
{{- $files := .Files }}
{{- with $files.Get ".env.k8s" }}
{{- range $line := splitList "\n" . }}
{{- $line := trim $line }}
{{- if and (ne (len $line) 0) (not (hasPrefix "#" $line)) }}
{{- $kv := splitList "=" $line }}
{{- if eq (len $kv) 2 }}
  {{ index $kv 0 | trim | quote }}: {{ index $kv 1 | trim | b64enc | quote }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
