mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-18 18:49:50 +02:00
feat: include func support (#1187)
* feat: include func support Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
@@ -76,6 +76,7 @@ ${kubectl} create namespace ${test_ns} || fail "Could not create namespace ${tes
|
||||
|
||||
# TEST CASES----------------------------------------------------------------------------------------------------------
|
||||
|
||||
. ${dir}/test-cases/include-template-func.sh
|
||||
. ${dir}/test-cases/happypath.sh
|
||||
. ${dir}/test-cases/chartify-with-non-chart-dir.sh
|
||||
. ${dir}/test-cases/diff-args.sh
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
include_template_func_case_input_dir="${cases_dir}/include-template-func/input"
|
||||
include_template_func_case_output_dir="${cases_dir}/include-template-func/output"
|
||||
|
||||
config_file="helmfile.yaml.gotmpl"
|
||||
|
||||
include_template_func_template_out_file=${include_template_func_case_output_dir}/template-result
|
||||
if [[ $EXTRA_HELMFILE_FLAGS == *--enable-live-output* ]]; then
|
||||
include_template_func_template_out_file=${include_template_func_case_output_dir}/template-result-live
|
||||
fi
|
||||
|
||||
include_template_func_template_tmp=$(mktemp -d)
|
||||
include_template_func_template_reverse=${include_template_func_template_tmp}/include_template_func.template.build.yaml
|
||||
|
||||
test_start "include_template_func template"
|
||||
info "Comparing include_template_func template output ${include_template_func_template_reverse} with ${include_template_func_case_output_dir}/result.yaml"
|
||||
for i in $(seq 10); do
|
||||
info "Comparing build/include_template_func-template #$i"
|
||||
${helmfile} -f ${include_template_func_case_input_dir}/${config_file} template --concurrency 1
|
||||
${helmfile} -f ${include_template_func_case_input_dir}/${config_file} template --concurrency 1 &> ${include_template_func_template_reverse} || fail "\"helmfile template\" shouldn't fail"
|
||||
diff -u ${include_template_func_template_out_file} ${include_template_func_template_reverse} || fail "\"helmfile template\" should be consistent"
|
||||
echo code=$?
|
||||
done
|
||||
test_pass "include_template_func template"
|
||||
@@ -0,0 +1,3 @@
|
||||
{{- define "echo" -}}
|
||||
{{ .Echo }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,8 @@
|
||||
releases:
|
||||
- name: '{{ include "echo" (dict "Echo" "include") }}'
|
||||
chart: ../../../charts/raw
|
||||
values:
|
||||
- values/configmap.gotmpl
|
||||
|
||||
helmfiles:
|
||||
- nested/helmfile.yaml.gotmpl
|
||||
@@ -0,0 +1,3 @@
|
||||
{{- define "echo" -}}
|
||||
nested-{{ .Echo }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,12 @@
|
||||
releases:
|
||||
- name: '{{ include "echo" (dict "Echo" "include") }}'
|
||||
chart: ../../../../charts/raw
|
||||
values:
|
||||
- templates:
|
||||
- |
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ include "echo" (dict "Echo" "include") }}
|
||||
data:
|
||||
name: {{ include "echo" (dict "Echo" "include") }}
|
||||
@@ -0,0 +1,3 @@
|
||||
{{- define "echo" -}}
|
||||
{{ .Echo }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,8 @@
|
||||
templates:
|
||||
- |
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ include "echo" (dict "Echo" "include") }}
|
||||
data:
|
||||
name: {{ include "echo" (dict "Echo" "include") }}
|
||||
@@ -0,0 +1,22 @@
|
||||
Building dependency release=nested-include, chart=../../../../charts/raw
|
||||
Templating release=nested-include, chart=../../../../charts/raw
|
||||
---
|
||||
# Source: raw/templates/resources.yaml
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: nested-include
|
||||
data:
|
||||
name: nested-include
|
||||
|
||||
Building dependency release=include, chart=../../../charts/raw
|
||||
Templating release=include, chart=../../../charts/raw
|
||||
---
|
||||
# Source: raw/templates/resources.yaml
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: include
|
||||
data:
|
||||
name: include
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
Live output is enabled
|
||||
Building dependency release=nested-include, chart=../../../../charts/raw
|
||||
Templating release=nested-include, chart=../../../../charts/raw
|
||||
---
|
||||
# Source: raw/templates/resources.yaml
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: nested-include
|
||||
data:
|
||||
name: nested-include
|
||||
|
||||
Building dependency release=include, chart=../../../charts/raw
|
||||
Templating release=include, chart=../../../charts/raw
|
||||
---
|
||||
# Source: raw/templates/resources.yaml
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: include
|
||||
data:
|
||||
name: include
|
||||
|
||||
Reference in New Issue
Block a user