From 32bf8a941438dc7fec161e1e94d3aa685e4148cc Mon Sep 17 00:00:00 2001
From: Andri Joos <andri@joos.io>
Date: Sat, 25 Jan 2025 00:38:55 +0100
Subject: [PATCH] add configmap template

---
 common/templates/_configmap.tpl | 15 +++++++++++++++
 common/templates/_helpers.tpl   | 11 +++++++++++
 2 files changed, 26 insertions(+)
 create mode 100644 common/templates/_configmap.tpl

diff --git a/common/templates/_configmap.tpl b/common/templates/_configmap.tpl
new file mode 100644
index 0000000..ae3c9bf
--- /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 a191068..c86d105 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 }}
-- 
GitLab