feat: inherit field for release template inheritance (#606)

* feat: `inherit` field for release template inheritance

Ref https://github.com/helmfile/helmfile/issues/435#issuecomment-1364749414

Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>

* Fix wording

Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>

* Comment on releaseWithInheritedTemplate

Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>

* Update Release Template doc with the new `inherit` feature

Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>

* Fix a typo in code comment

Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>

Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>
This commit is contained in:
Yusuke Kuoka
2022-12-28 10:01:04 +09:00
committed by GitHub
parent 6b19577987
commit 490bb5d147
9 changed files with 324 additions and 14 deletions
@@ -82,7 +82,7 @@ remote> getter dest: values/https_github_com_helmfile_helmfile_git.ref=main
remote> cached dir: /home/runner/.cache/helmfile/values/https_github_com_helmfile_helmfile_git.ref=main
skipping missing secrets file matching "git::https://github.com/helmfile/helmfile.git@test/e2e/template/helmfile/testdata/snapshot/pr_560/secrets.yaml?ref=main"
Templating release=foo, chart=../../charts/raw-0.1.0
exec: helm template foo ../../charts/raw-0.1.0 --values /tmp/helmfile/foo-values-649697bc75 --debug
exec: helm template foo ../../charts/raw-0.1.0 --values /tmp/helmfile/foo-values-d459bc67c --debug
helm> install.go:192: [debug] Original chart version: ""
helm>
helm> install.go:209: [debug] CHART PATH: /home/runner/work/helmfile/helmfile/test/e2e/template/helmfile/testdata/charts/raw-0.1.0
@@ -108,6 +108,6 @@ metadata:
data:
foo: FOO
Removed /tmp/helmfile/foo-values-649697bc75
Removed /tmp/helmfile/foo-values-d459bc67c
Removed /tmp/helmfile
changing working directory back to "/home/runner/work/helmfile/helmfile/test/e2e/template/helmfile"
@@ -0,0 +1,5 @@
localChartRepoServer:
enabled: true
port: 18084
helmfileArgs:
- template
@@ -0,0 +1,63 @@
repositories:
- name: myrepo
url: http://localhost:18084/
templates:
base:
valuesTemplate:
- base: base
labels:
base: base
template1:
values:
- template1: template1
valuesTemplate:
- template1Label: "{{` '{{ .Release.Labels.template1 }}' `}}"
labels:
template1: template1
inherit:
template: base
except:
- labels
template2:
values:
- template2: template2
valuesTemplate:
- inheritedBaseLabel: "{{` '{{ .Release.Labels.base }}' `}}"
template2Label: "{{` '{{ .Release.Labels.template2 }}' `}}"
labels:
template2: template2
inherit:
template: base
except:
- valuesTemplate
releases:
- name: foo1
chart: ../../charts/raw-0.1.0
inherit:
template: template1
values:
- templates:
- |
apiVersion: v1
kind: ConfigMap
metadata:
name: {{`{{ .Release.Name }}`}}-1
namespace: {{`{{ .Release.Namespace }}`}}
data:
{{` {{ .Values | toYaml | nindent 2 }} `}}
- name: foo2
chart: ../../charts/raw-0.1.0
inherit:
template: template2
values:
- templates:
- |
apiVersion: v1
kind: ConfigMap
metadata:
name: {{`{{ .Release.Name }}`}}-1
namespace: {{`{{ .Release.Namespace }}`}}
data:
{{` {{ .Values | toYaml | nindent 2 }} `}}
@@ -0,0 +1,45 @@
Adding repo myrepo http://localhost:18084/
"myrepo" has been added to your repositories
Building dependency release=foo1, chart=../../charts/raw-0.1.0
Building dependency release=foo2, chart=../../charts/raw-0.1.0
Templating release=foo1, chart=../../charts/raw-0.1.0
---
# Source: raw/templates/resources.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: foo1-1
namespace: default
data:
base: base
template1: template1
template1Label: template1
templates:
- "apiVersion: v1\nkind: ConfigMap\nmetadata:\n name: {{ .Release.Name }}-1\n namespace:
{{ .Release.Namespace }}\ndata:\n {{ .Values | toYaml | nindent 2 }} \n"
Templating release=foo2, chart=../../charts/raw-0.1.0
---
# Source: raw/templates/resources.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: foo2-1
namespace: default
data:
inheritedBaseLabel: base
template2: template2
template2Label: template2
templates:
- |-
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-1
namespace: {{ .Release.Namespace }}
data:
{{ .Values | toYaml | nindent 2 }}