diff --git a/common/templates/_configmap.tpl b/common/templates/_configmap.tpl new file mode 100644 index 0000000000000000000000000000000000000000..ae3c9bf204563179916c03505a876ec08e549299 --- /dev/null +++ b/common/templates/_configmap.tpl @@ -0,0 +1,15 @@ +{{- define "common.configmap" -}} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Values.name | default "configmap" | quote }} + {{- with .Values.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} + labels: + {{- include "common.variables.labels" . | nindent 4 }} +data: + {{- (include "common.variables.configmap.data" .) | nindent 2 }} +--- +{{- end }} diff --git a/common/templates/_helpers.tpl b/common/templates/_helpers.tpl index a19106818eabcd637c140828c35519a549203f2f..c86d105293524b09987174aa715738003710930d 100644 --- a/common/templates/_helpers.tpl +++ b/common/templates/_helpers.tpl @@ -59,3 +59,14 @@ Secret data {{- end }} {{- toYaml $data -}} {{- end }} + +{{/* +ConfigMap data +*/}} +{{- define "common.variables.configmap.data" -}} +{{- $data := dict -}} +{{- range $key, $value := .Values.data -}} + {{- $data = merge $data (dict $key $value) -}} +{{- end }} +{{- toYaml $data -}} +{{- end }} diff --git a/example/templates/configmaps.yaml b/example/templates/configmaps.yaml new file mode 100644 index 0000000000000000000000000000000000000000..30b403d3dcaaf65db9f02882dda0bdab4cb96b7c --- /dev/null +++ b/example/templates/configmaps.yaml @@ -0,0 +1,3 @@ +{{- if .Values.configmap }} +{{ include "common.configmap" (dict "Values" .Values.configmap "Chart" .Chart "Release" .Release) }} +{{- end }} diff --git a/example/values.yaml b/example/values.yaml index a1c0f696b9b4d492cefcccdbb23c28e324373cdb..e809e3c294a84d12e1ca30f9b746f8d7d03e4827 100644 --- a/example/values.yaml +++ b/example/values.yaml @@ -71,3 +71,8 @@ acme: - http01: ingress: class: traefik + +configmap: + name: configmap + data: + example: test