From 3c6acd83c864beee72eaa666dee720897044df34 Mon Sep 17 00:00:00 2001 From: Stefan Reimer Date: Thu, 23 May 2024 21:17:35 +0000 Subject: [PATCH] feat: add new tool template function --- charts/kubezero-lib/Chart.yaml | 2 +- charts/kubezero-lib/templates/_helpers.tpl | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/charts/kubezero-lib/Chart.yaml b/charts/kubezero-lib/Chart.yaml index dd0afd4d..ba4a50a6 100644 --- a/charts/kubezero-lib/Chart.yaml +++ b/charts/kubezero-lib/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: kubezero-lib description: KubeZero helm library - common helm functions and blocks type: library -version: 0.1.6 +version: 0.2.0 home: https://kubezero.com icon: https://cdn.zero-downtime.net/assets/kubezero/logo-small-64.png keywords: diff --git a/charts/kubezero-lib/templates/_helpers.tpl b/charts/kubezero-lib/templates/_helpers.tpl index 7aeae2b8..f9dbe370 100644 --- a/charts/kubezero-lib/templates/_helpers.tpl +++ b/charts/kubezero-lib/templates/_helpers.tpl @@ -43,3 +43,16 @@ app.kubernetes.io/managed-by: {{ .Release.Service }} app.kubernetes.io/part-of: kubezero {{- end -}} +{{- /* +kubezero-lib.util.merge will merge two YAML templates and output the result. +This takes an array of three values: +- the top context +- the template name of the overrides (destination) +- the template name of the base (source) +*/}} +{{- define "kubezero-lib.util.merge" -}} +{{- $top := first . -}} +{{- $overrides := fromYaml (include (index . 1) $top) | default (dict ) -}} +{{- $tpl := fromYaml (include (index . 2) $top) | default (dict ) -}} +{{- toYaml (merge $overrides $tpl) -}} +{{- end -}}