Im trying to use recursion in order to be adding contents of files in the ConfigMap.yaml but i dont seem to get it right. I dont get the content of the file no matter what i try. The location of the file is correct because i can get the content without recursion. {{.Files.Get "config/gitlab.conf" | indent 4 -}}
Any help would be greatly appreciated! Thank you
ConfigMap.yaml:
{{- if .Values.volConfigMap}}
{{- range .Values.volConfigMap }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .config.configName }}
namespace: {{ $.Release.Namespace }}
data:
{{- if .config.file }}
{{- range $path, $config := .config.file }}
{{ $path }}: |
{{ tpl ($.Files.Get $config) $ | indent 4 -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
Values.yaml:
config:
configName: gitlab-conf
file:
logstash.conf: config/gitlab.conf
OUTPUT:
apiVersion: v1
kind: ConfigMap
metadata:
name: gitlab-conf
namespace: elk
data:
logstash.conf: |
The |-
marker in YAML takes a multi-line string. This can be a useful technique for embedding big blocks of data inside of your manifests, as exemplified here.
{{- if .Values.volConfigMap }}
{{- range .Values.volConfigMap }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .config.configName }}
namespace: {{ $.Release.Namespace }}
data:
{{- if .config.file }}
{{- range $k, $v := .config.file }}
{{ $k }}: |-
{{ $.Files.Get $v | nindent 4 }}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}