Use gopkg.in/yaml.v2 for Helmfile v0.x (#609)

This should fix #435 for Helmfile v0.x releases since the next v0.150.0.
We introduce a new envvar to opt-in to the new YAML library, so that you can give it a shot before upgrading your Helmfile to v1. The same envvar can be used to opt-out of the new YAML library after you upgrade to Helmfile v1, giving you a more flexible migration story.

Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>
This commit is contained in:
Yusuke Kuoka
2023-01-04 18:17:24 +09:00
committed by GitHub
parent 490bb5d147
commit 4688cf0132
28 changed files with 357 additions and 246 deletions
+31 -3
View File
@@ -8,7 +8,8 @@ import (
"os/exec"
"path/filepath"
"regexp"
"runtime"
goruntime "runtime"
"strconv"
"strings"
"testing"
"time"
@@ -57,6 +58,18 @@ func (f fakeInit) Force() bool {
}
func TestHelmfileTemplateWithBuildCommand(t *testing.T) {
t.Run("with goccy/go-yaml", func(t *testing.T) {
testHelmfileTemplateWithBuildCommand(t, true)
})
t.Run("with gopkg.in/yaml.v2", func(t *testing.T) {
testHelmfileTemplateWithBuildCommand(t, false)
})
}
func testHelmfileTemplateWithBuildCommand(t *testing.T, goccyGoYaml bool) {
t.Setenv(envvar.GoccyGoYaml, strconv.FormatBool(goccyGoYaml))
localChartPortSets := make(map[int]struct{})
logger := helmexec.NewLogger(os.Stderr, "info")
@@ -69,10 +82,10 @@ func TestHelmfileTemplateWithBuildCommand(t *testing.T) {
err := helmfileInit.CheckHelmPlugins()
require.NoError(t, err)
_, filename, _, _ := runtime.Caller(0)
_, filename, _, _ := goruntime.Caller(0)
projectRoot := filepath.Join(filepath.Dir(filename), "..", "..", "..", "..")
helmfileBin := filepath.Join(projectRoot, "helmfile")
if runtime.GOOS == "windows" {
if goruntime.GOOS == "windows" {
helmfileBin = helmfileBin + ".exe"
}
testdataDir := "testdata/snapshot"
@@ -200,6 +213,15 @@ func TestHelmfileTemplateWithBuildCommand(t *testing.T) {
}
}
tmpDir := t.TempDir()
// HELM_CACHE_HOME contains downloaded chart archives
helmCacheHome := filepath.Join(tmpDir, "helm_cache")
// HELMFILE_CACHE_HOME contains remote charts and manifests downloaded by Helmfile using the go-getter integration
helmfileCacheHome := filepath.Join(tmpDir, "helmfile_cache")
// HELM_CONFIG_HOME contains the registry auth file (registry.json) and the index of all the repos added via helm-repo-add (repositories.yaml).
helmConfigHome := filepath.Join(tmpDir, "helm_config")
t.Logf("Using HELM_CACHE_HOME=%s, HELMFILE_CACHE_HOME=%s, HELM_CONFIG_HOME=%s", helmCacheHome, helmfileCacheHome, helmConfigHome)
inputFile := filepath.Join(testdataDir, name, "input.yaml")
outputFile := filepath.Join(testdataDir, name, "output.yaml")
@@ -214,6 +236,9 @@ func TestHelmfileTemplateWithBuildCommand(t *testing.T) {
cmd.Env,
envvar.TempDir+"=/tmp/helmfile",
envvar.DisableRunnerUniqueID+"=1",
"HELM_CACHE_HOME="+helmCacheHome,
"HELM_CONFIG_HOME="+helmConfigHome,
"HELMFILE_CACHE_HOME="+helmfileCacheHome,
)
got, err := cmd.CombinedOutput()
if err != nil {
@@ -231,6 +256,9 @@ func TestHelmfileTemplateWithBuildCommand(t *testing.T) {
gotStr = chartGitFullPathRegex.ReplaceAllString(gotStr, `chart=$$GoGetterPath`)
// Replace helm version with $HelmVersion
gotStr = helmShortVersionRegex.ReplaceAllString(gotStr, `$$HelmVersion`)
// Replace all occurrences of HELMFILE_CACHE_HOME with /home/runner/.cache/helmfile
// for stable test result
gotStr = strings.ReplaceAll(gotStr, helmfileCacheHome, "/home/runner/.cache/helmfile")
// OCI based helm charts are pulled and exported under temporary directory.
// We are not sure the exact name of the temporary directory generated by helmfile,
@@ -6,23 +6,23 @@ helmBinary: helm
environments:
default: {}
repositories:
- name: aservo
url: https://aservo.github.io/charts
- name: aservo
url: https://aservo.github.io/charts
releases:
- chart: aservo/util
version: 0.0.1
name: default-shared-resources
namespace: default
labels:
service: shared-resources
- chart: aservo/util
version: 0.0.1
needs:
- default/default-shared-resources
name: default-release-resources
namespace: default
labels:
service: release-resources
- chart: aservo/util
version: 0.0.1
name: default-shared-resources
namespace: default
labels:
service: shared-resources
- chart: aservo/util
version: 0.0.1
needs:
- default/default-shared-resources
name: default-release-resources
namespace: default
labels:
service: release-resources
templates:
defaults:
name: default-{{ .Release.Labels.service }}
@@ -1,8 +1,4 @@
Building dependency release=foo, chart=$WD/temp1/foo
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "myrepo" chart repository
...Successfully got an update from the "istio" chart repository
Update Complete. ⎈Happy Helming!⎈
Saving 1 charts
Downloading raw from repo oci://localhost:5000/myrepo
Deleting outdated charts
@@ -1,9 +1,5 @@
Building dependency release=foo, chart=../../charts/raw-0.1.0
Building dependency release=baz, chart=$WD/temp1/baz
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "myrepo" chart repository
...Successfully got an update from the "istio" chart repository
Update Complete. ⎈Happy Helming!⎈
Saving 1 charts
Downloading raw from repo oci://localhost:5001/myrepo
Deleting outdated charts
@@ -1,4 +1,3 @@
helmfileArgs:
- template
- --debug
- --concurrency=1
@@ -1,103 +1,5 @@
processing file "input.yaml" in directory "testdata/snapshot/pr_560"
changing working directory to "/home/runner/work/helmfile/helmfile/test/e2e/template/helmfile/testdata/snapshot/pr_560"
first-pass rendering starting for "input.yaml.part.0": inherited=&{default map[] map[]}, overrode=<nil>
first-pass uses: &{default map[] map[]}
first-pass rendering output of "input.yaml.part.0":
0: releases:
1: - name: foo
2: chart: ../../charts/raw-0.1.0
3: values:
4: - templates:
5: - |
6: apiVersion: v1
7: kind: ConfigMap
8: metadata:
9: name: {{ .Release.Name }}-1
10: namespace: {{ .Release.Namespace }}
11: data:
12: foo: FOO
13: - git::https://github.com/helmfile/helmfile.git@test/e2e/template/helmfile/testdata/snapshot/pr_560/values.yaml?ref=main
14: secrets:
15: - git::https://github.com/helmfile/helmfile.git@test/e2e/template/helmfile/testdata/snapshot/pr_560/secrets.yaml?ref=main
16: missingFileHandler: Debug
17:
first-pass produced: &{default map[] map[]}
first-pass rendering result of "input.yaml.part.0": {default map[] map[]}
vals:
map[]
defaultVals:[]
second-pass rendering result of "input.yaml.part.0":
0: releases:
1: - name: foo
2: chart: ../../charts/raw-0.1.0
3: values:
4: - templates:
5: - |
6: apiVersion: v1
7: kind: ConfigMap
8: metadata:
9: name: {{ .Release.Name }}-1
10: namespace: {{ .Release.Namespace }}
11: data:
12: foo: FOO
13: - git::https://github.com/helmfile/helmfile.git@test/e2e/template/helmfile/testdata/snapshot/pr_560/values.yaml?ref=main
14: secrets:
15: - git::https://github.com/helmfile/helmfile.git@test/e2e/template/helmfile/testdata/snapshot/pr_560/secrets.yaml?ref=main
16: missingFileHandler: Debug
17:
merged environment: &{default map[] map[]}
helm> $HelmVersion
helm>
Building dependency release=foo, chart=../../charts/raw-0.1.0
exec: helm dependency build ../../charts/raw-0.1.0
1 release(s) found in input.yaml
processing 1 groups of releases in this order:
GROUP RELEASES
1 foo
processing releases in group 1/1: foo
remote> getter: git
remote> scheme: https
remote> user:
remote> host: github.com
remote> dir: /helmfile/helmfile.git
remote> file: test/e2e/template/helmfile/testdata/snapshot/pr_560/values.yaml
remote> home: /home/runner/.cache/helmfile
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
remote> downloading git::https://github.com/helmfile/helmfile.git?ref=main to values/https_github_com_helmfile_helmfile_git.ref=main
client: {Ctx:context.Background Src:git::https://github.com/helmfile/helmfile.git?ref=main Dst:/home/runner/.cache/helmfile/values/https_github_com_helmfile_helmfile_git.ref=main Pwd:/home/runner/.cache/helmfile Mode:3 Umask:---------- Detectors:[] Decompressors:map[] Getters:map[] Dir:false ProgressListener:<nil> Insecure:false DisableSymlinks:false Options:[]}
skipping missing values file matching "git::https://github.com/helmfile/helmfile.git@test/e2e/template/helmfile/testdata/snapshot/pr_560/values.yaml?ref=main"
remote> getter: git
remote> scheme: https
remote> user:
remote> host: github.com
remote> dir: /helmfile/helmfile.git
remote> file: test/e2e/template/helmfile/testdata/snapshot/pr_560/secrets.yaml
remote> home: /home/runner/.cache/helmfile
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-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
helm>
helm>
helm> ---
helm> # Source: raw/templates/resources.yaml
helm> apiVersion: v1
helm> kind: ConfigMap
helm> metadata:
helm> name: foo-1
helm> namespace: default
helm> data:
helm> foo: FOO
helm>
---
# Source: raw/templates/resources.yaml
apiVersion: v1
@@ -108,6 +10,3 @@ metadata:
data:
foo: FOO
Removed /tmp/helmfile/foo-values-d459bc67c
Removed /tmp/helmfile
changing working directory back to "/home/runner/work/helmfile/helmfile/test/e2e/template/helmfile"
@@ -3,3 +3,5 @@ localChartRepoServer:
port: 18084
helmfileArgs:
- template
# Prevent two releases foo and bar from racing and randomizing the log
- --concurrency=1
@@ -12,7 +12,7 @@ templates:
values:
- template1: template1
valuesTemplate:
- template1Label: "{{` '{{ .Release.Labels.template1 }}' `}}"
- template1Label: "{{`{{ .Release.Labels.template1 }}`}}"
labels:
template1: template1
inherit:
@@ -23,8 +23,8 @@ templates:
values:
- template2: template2
valuesTemplate:
- inheritedBaseLabel: "{{` '{{ .Release.Labels.base }}' `}}"
template2Label: "{{` '{{ .Release.Labels.template2 }}' `}}"
- inheritedBaseLabel: "{{`{{ .Release.Labels.base }}`}}"
template2Label: "{{`{{ .Release.Labels.template2 }}`}}"
labels:
template2: template2
inherit:
@@ -46,7 +46,7 @@ releases:
name: {{`{{ .Release.Name }}`}}-1
namespace: {{`{{ .Release.Namespace }}`}}
data:
{{` {{ .Values | toYaml | nindent 2 }} `}}
{{` {{ (unset .Values "templates") | toYaml | nindent 2 }} `}}
- name: foo2
chart: ../../charts/raw-0.1.0
inherit:
@@ -60,4 +60,4 @@ releases:
name: {{`{{ .Release.Name }}`}}-1
namespace: {{`{{ .Release.Namespace }}`}}
data:
{{` {{ .Values | toYaml | nindent 2 }} `}}
{{` {{ (unset .Values "templates") | toYaml | nindent 2 }} `}}
@@ -16,9 +16,6 @@ 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
---
@@ -33,13 +30,4 @@ 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 }}
+19 -11
View File
@@ -2,6 +2,14 @@ if [[ helm_major_version -eq 3 ]]; then
chart_need_case_input_dir="${cases_dir}/chart-needs/input"
chart_need_case_output_dir="${cases_dir}/chart-needs/output"
config_file="helmfile.yaml"
if [[ ${HELMFILE_V1MODE} = true ]]; then
pushd "${chart_need_case_input_dir}"
mv "${config_file}" "${config_file}.gotmpl"
config_file="${config_file}.gotmpl"
popd
fi
chart_needs_tmp=$(mktemp -d)
chart_needs_template_reverse=${chart_needs_tmp}/chart.needs.template.log
chart_needs_lint_reverse=${chart_needs_tmp}/chart.needs.lint.log
@@ -20,46 +28,46 @@ if [[ helm_major_version -eq 3 ]]; then
for i in $(seq 10); do
info "Comparing template/chart-needs #$i"
${helmfile} -f ${chart_need_case_input_dir}/helmfile.yaml template --include-needs > ${chart_needs_template_reverse} || fail "\"helmfile template\" shouldn't fail"
${helmfile} -f ${chart_need_case_input_dir}/${config_file} template --include-needs > ${chart_needs_template_reverse} || fail "\"helmfile template\" shouldn't fail"
./dyff between -bs ${chart_need_case_output_dir}/template ${chart_needs_template_reverse} || fail "\"helmfile template\" should be consistent"
echo code=$?
done
for i in $(seq 10); do
info "Comparing lint/chart-needs #$i"
${helmfile} -f ${chart_need_case_input_dir}/helmfile.yaml lint --include-needs | grep -v Linting > ${chart_needs_lint_reverse} || fail "\"helmfile lint\" shouldn't fail"
${helmfile} -f ${chart_need_case_input_dir}/${config_file} lint --include-needs | grep -v Linting > ${chart_needs_lint_reverse} || fail "\"helmfile lint\" shouldn't fail"
diff -u ${lint_out_file} ${chart_needs_lint_reverse} || fail "\"helmfile lint\" should be consistent"
echo code=$?
done
for i in $(seq 10); do
info "Comparing diff/chart-needs #$i"
${helmfile} -f ${chart_need_case_input_dir}/helmfile.yaml diff --include-needs | grep -Ev "Comparing release=azuredisk-csi-storageclass, chart=/tmp/.*/azuredisk-csi-storageclass" > ${chart_needs_diff_reverse} || fail "\"helmfile diff\" shouldn't fail"
${helmfile} -f ${chart_need_case_input_dir}/${config_file} diff --include-needs | grep -Ev "Comparing release=azuredisk-csi-storageclass, chart=/tmp/.*/azuredisk-csi-storageclass" > ${chart_needs_diff_reverse} || fail "\"helmfile diff\" shouldn't fail"
diff -u ${diff_out_file} ${chart_needs_diff_reverse} || fail "\"helmfile diff\" should be consistent"
echo code=$?
done
info "Applying ${chart_need_case_input_dir}/helmfile.yaml"
${helmfile} -f ${chart_need_case_input_dir}/helmfile.yaml apply --include-needs
info "Applying ${chart_need_case_input_dir}/${config_file}"
${helmfile} -f ${chart_need_case_input_dir}/${config_file} apply --include-needs
code=$?
[ ${code} -eq 0 ] || fail "unexpected exit code returned by helmfile apply: want 0, got ${code}"
${kubectl} get storageclass managed-csi -o yaml | grep -q "provisioner: disk.csi.azure.com" || fail "storageclass managed-csi should be created when applying helmfile.yaml"
info "Destroying ${chart_need_case_input_dir}/helmfile.yaml"
${helmfile} -f ${chart_need_case_input_dir}/helmfile.yaml destroy
info "Destroying ${chart_need_case_input_dir}/${config_file}"
${helmfile} -f ${chart_need_case_input_dir}/${config_file} destroy
code=$?
[ ${code} -eq 0 ] || fail "unexpected exit code returned by helmfile destroy: want 0, got ${code}"
info "Syncing ${chart_need_case_input_dir}/helmfile.yaml"
${helmfile} -f ${chart_need_case_input_dir}/helmfile.yaml sync --include-needs
info "Syncing ${chart_need_case_input_dir}/${config_file}"
${helmfile} -f ${chart_need_case_input_dir}/${config_file} sync --include-needs
code=$?
[ ${code} -eq 0 ] || fail "unexpected exit code returned by helmfile apply: want 0, got ${code}"
${kubectl} get storageclass managed-csi -o yaml | grep -q "provisioner: disk.csi.azure.com" || fail "storageclass managed-csi should be created when syncing helmfile.yaml"
info "Destroying ${chart_need_case_input_dir}/helmfile.yaml"
${helmfile} -f ${chart_need_case_input_dir}/helmfile.yaml destroy
info "Destroying ${chart_need_case_input_dir}/${config_file}"
${helmfile} -f ${chart_need_case_input_dir}/${config_file} destroy
code=$?
[ ${code} -eq 0 ] || fail "unexpected exit code returned by helmfile destroy: want 0, got ${code}"
+31 -23
View File
@@ -2,22 +2,30 @@ test_start "happypath - simple rollout of httpbin chart"
happypath_case_input_dir="${cases_dir}/happypath/input"
happypath_case_output_dir="${cases_dir}/happypath/output"
config_file="happypath.yaml"
info "Diffing ${happypath_case_input_dir}/happypath.yaml"
bash -c "${helmfile} -f ${happypath_case_input_dir}/happypath.yaml diff --detailed-exitcode; code="'$?'"; [ "'${code}'" -eq 2 ]" || fail "unexpected exit code returned by helmfile diff"
if [[ ${HELMFILE_V1MODE} = true ]]; then
pushd "${happypath_case_input_dir}"
mv "${config_file}" "${config_file}.gotmpl"
config_file="${config_file}.gotmpl"
popd
fi
info "Diffing ${happypath_case_input_dir}/happypath.yaml without color"
bash -c "${helmfile} -f ${happypath_case_input_dir}/happypath.yaml --no-color diff --detailed-exitcode; code="'$?'"; [ "'${code}'" -eq 2 ]" || fail "unexpected exit code returned by helmfile diff"
info "Diffing ${happypath_case_input_dir}/${config_file}"
bash -c "${helmfile} -f ${happypath_case_input_dir}/${config_file} diff --detailed-exitcode; code="'$?'"; [ "'${code}'" -eq 2 ]" || fail "unexpected exit code returned by helmfile diff"
info "Diffing ${happypath_case_input_dir}/happypath.yaml with limited context"
bash -c "${helmfile} -f ${happypath_case_input_dir}/happypath.yaml diff --context 3 --detailed-exitcode; code="'$?'"; [ "'${code}'" -eq 2 ]" || fail "unexpected exit code returned by helmfile diff"
info "Diffing ${happypath_case_input_dir}/${config_file} without color"
bash -c "${helmfile} -f ${happypath_case_input_dir}/${config_file} --no-color diff --detailed-exitcode; code="'$?'"; [ "'${code}'" -eq 2 ]" || fail "unexpected exit code returned by helmfile diff"
info "Diffing ${happypath_case_input_dir}/happypath.yaml with altered output"
bash -c "${helmfile} -f ${happypath_case_input_dir}/happypath.yaml diff --output simple --detailed-exitcode; code="'$?'"; [ "'${code}'" -eq 2 ]" || fail "unexpected exit code returned by helmfile diff"
info "Diffing ${happypath_case_input_dir}/${config_file} with limited context"
bash -c "${helmfile} -f ${happypath_case_input_dir}/${config_file} diff --context 3 --detailed-exitcode; code="'$?'"; [ "'${code}'" -eq 2 ]" || fail "unexpected exit code returned by helmfile diff"
info "Templating ${happypath_case_input_dir}/happypath.yaml"
info "Diffing ${happypath_case_input_dir}/${config_file} with altered output"
bash -c "${helmfile} -f ${happypath_case_input_dir}/${config_file} diff --output simple --detailed-exitcode; code="'$?'"; [ "'${code}'" -eq 2 ]" || fail "unexpected exit code returned by helmfile diff"
info "Templating ${happypath_case_input_dir}/${config_file}"
rm -rf ${dir}/tmp
${helmfile} -f ${happypath_case_input_dir}/happypath.yaml --debug template --output-dir tmp
${helmfile} -f ${happypath_case_input_dir}/${config_file} --debug template --output-dir tmp
code=$?
[ ${code} -eq 0 ] || fail "unexpected exit code returned by helmfile template: ${code}"
for output in $(ls -d ${dir}/tmp/*); do
@@ -30,39 +38,39 @@ for output in $(ls -d ${dir}/tmp/*); do
done
done
info "Applying ${happypath_case_input_dir}/happypath.yaml"
bash -c "${helmfile} -f ${happypath_case_input_dir}/happypath.yaml apply --detailed-exitcode; code="'$?'"; echo Code: "'$code'"; [ "'${code}'" -eq 2 ]" || fail "unexpected exit code returned by helmfile apply"
info "Applying ${happypath_case_input_dir}/${config_file}"
bash -c "${helmfile} -f ${happypath_case_input_dir}/${config_file} apply --detailed-exitcode; code="'$?'"; echo Code: "'$code'"; [ "'${code}'" -eq 2 ]" || fail "unexpected exit code returned by helmfile apply"
info "Syncing ${happypath_case_input_dir}/happypath.yaml"
${helmfile} -f ${happypath_case_input_dir}/happypath.yaml sync
info "Syncing ${happypath_case_input_dir}/${config_file}"
${helmfile} -f ${happypath_case_input_dir}/${config_file} sync
wait_deploy_ready httpbin-httpbin
retry 5 "curl --fail $(minikube service --url --namespace=${test_ns} httpbin-httpbin)/status/200"
[ ${retry_result} -eq 0 ] || fail "httpbin failed to return 200 OK"
info "Applying ${happypath_case_input_dir}/happypath.yaml"
${helmfile} -f ${happypath_case_input_dir}/happypath.yaml apply --detailed-exitcode
info "Applying ${happypath_case_input_dir}/${config_file}"
${helmfile} -f ${happypath_case_input_dir}/${config_file} apply --detailed-exitcode
code=$?
[ ${code} -eq 0 ] || fail "unexpected exit code returned by helmfile apply: want 0, got ${code}"
info "Locking dependencies"
${helmfile} -f ${happypath_case_input_dir}/happypath.yaml deps
${helmfile} -f ${happypath_case_input_dir}/${config_file} deps
code=$?
[ ${code} -eq 0 ] || fail "unexpected exit code returned by helmfile deps: ${code}"
info "Applying ${happypath_case_input_dir}/happypath.yaml with locked dependencies"
${helmfile} -f ${happypath_case_input_dir}/happypath.yaml apply
info "Applying ${happypath_case_input_dir}/${config_file} with locked dependencies"
${helmfile} -f ${happypath_case_input_dir}/${config_file} apply
code=$?
[ ${code} -eq 0 ] || fail "unexpected exit code returned by helmfile apply: ${code}"
${helm} list --namespace=${test_ns} || fail "unable to list releases"
info "Deleting release"
${helmfile} -f ${happypath_case_input_dir}/happypath.yaml delete
${helmfile} -f ${happypath_case_input_dir}/${config_file} destroy
${helm} status --namespace=${test_ns} httpbin &> /dev/null && fail "release should not exist anymore after a delete"
info "Ensuring \"helmfile delete\" doesn't fail when no releases installed"
${helmfile} -f ${happypath_case_input_dir}/happypath.yaml delete || fail "\"helmfile delete\" shouldn't fail when there are no installed releases"
info "Ensuring \"helmfile destroy\" doesn't fail when no releases installed"
${helmfile} -f ${happypath_case_input_dir}/${config_file} destroy || fail "\"helmfile delete\" shouldn't fail when there are no installed releases"
info "Ensuring \"helmfile template\" output does contain only YAML docs"
(${helmfile} -f ${happypath_case_input_dir}/happypath.yaml template | kubectl apply -f -) || fail "\"helmfile template | kubectl apply -f -\" shouldn't fail"
(${helmfile} -f ${happypath_case_input_dir}/${config_file} template | kubectl apply -f -) || fail "\"helmfile template | kubectl apply -f -\" shouldn't fail"
test_pass "happypath"
@@ -2,6 +2,14 @@ if [[ helm_major_version -eq 3 ]]; then
postrender_diff_case_input_dir="${cases_dir}/postrender-diff/input"
postrender_diff_case_output_dir="${cases_dir}/postrender-diff/output"
config_file="helmfile.yaml"
if [[ ${HELMFILE_V1MODE} = true ]]; then
pushd "${postrender_diff_case_input_dir}"
mv "${config_file}" "${config_file}.gotmpl"
config_file="${config_file}.gotmpl"
popd
fi
postrender_diff_out_file=${postrender_diff_case_output_dir}/result
if [[ $EXTRA_HELMFILE_FLAGS == *--enable-live-output* ]]; then
postrender_diff_out_file=${postrender_diff_case_output_dir}/result-live
@@ -14,7 +22,7 @@ if [[ helm_major_version -eq 3 ]]; then
info "Comparing postrender diff output ${postrender_diff_reverse} with ${postrender_diff_case_output_dir}/result.yaml"
for i in $(seq 10); do
info "Comparing build/postrender-diff #$i"
${helmfile} -f ${postrender_diff_case_input_dir}/helmfile.yaml diff --concurrency 1 &> ${postrender_diff_reverse} || fail "\"helmfile diff\" shouldn't fail"
${helmfile} -f ${postrender_diff_case_input_dir}/${config_file} diff --concurrency 1 &> ${postrender_diff_reverse} || fail "\"helmfile diff\" shouldn't fail"
diff -u ${postrender_diff_out_file} ${postrender_diff_reverse} || fail "\"helmfile diff\" should be consistent"
echo code=$?
done
+26 -4
View File
@@ -3,15 +3,37 @@ test_start "regression tests"
if [[ helm_major_version -eq 3 ]]; then
regression_case_input_dir="${cases_dir}/regression/input"
info "https://github.com/roboll/helmfile/issues/1857"
(${helmfile} -f ${regression_case_input_dir}/issue.1857.yaml --state-values-set grafanaEnabled=true template | grep grafana 1>/dev/null) || fail "\"helmfile template\" shouldn't include grafana"
! (${helmfile} -f ${regression_case_input_dir}/issue.1857.yaml --state-values-set grafanaEnabled=false template | grep grafana) || fail "\"helmfile template\" shouldn't include grafana"
config_file="issue.1857.yaml"
if [[ ${HELMFILE_V1MODE} = true ]]; then
pushd "${regression_case_input_dir}"
mv "${config_file}" "${config_file}.gotmpl"
config_file="${config_file}.gotmpl"
popd
fi
(${helmfile} -f ${regression_case_input_dir}/${config_file} --state-values-set grafanaEnabled=true template | grep grafana 1>/dev/null) || fail "\"helmfile template\" shouldn't include grafana"
! (${helmfile} -f ${regression_case_input_dir}/${config_file} --state-values-set grafanaEnabled=false template | grep grafana) || fail "\"helmfile template\" shouldn't include grafana"
info "https://github.com/roboll/helmfile/issues/1867"
(${helmfile} -f ${regression_case_input_dir}/issue.1867.yaml template 1>/dev/null) || fail "\"helmfile template\" shouldn't fail"
config_file="issue.1867.yaml"
if [[ ${HELMFILE_V1MODE} = true ]]; then
pushd "${regression_case_input_dir}"
mv "${config_file}" "${config_file}.gotmpl"
config_file="${config_file}.gotmpl"
popd
fi
(${helmfile} -f ${regression_case_input_dir}/${config_file} template 1>/dev/null) || fail "\"helmfile template\" shouldn't fail"
info "https://github.com/roboll/helmfile/issues/2118"
(${helmfile} -f ${regression_case_input_dir}/issue.2118.yaml template 1>/dev/null) || fail "\"helmfile template\" shouldn't fail"
config_file="issue.2118.yaml"
if [[ ${HELMFILE_V1MODE} = true ]]; then
pushd "${regression_case_input_dir}"
mv "${config_file}" "${config_file}.gotmpl"
config_file="${config_file}.gotmpl"
popd
fi
(${helmfile} -f ${regression_case_input_dir}/${config_file} template 1>/dev/null) || fail "\"helmfile template\" shouldn't fail"
else
info "There are no regression tests for helm 2 because all the target charts have dropped helm 2 support."
fi
+11 -4
View File
@@ -5,6 +5,13 @@ if [[ helm_major_version -eq 3 ]]; then
secretssops_case_input_dir="${cases_dir}/secretssops/input"
secretssops_case_output_dir="${cases_dir}/secretssops/output"
config_file="secretssops.yaml"
if [[ ${HELMFILE_V1MODE} = true ]]; then
pushd "${secretssops_case_input_dir}"
mv "${config_file}" "${config_file}.gotmpl"
config_file="${config_file}.gotmpl"
popd
fi
mkdir -p ${secretssops_case_input_dir}/tmp
@@ -19,7 +26,7 @@ if [[ helm_major_version -eq 3 ]]; then
info "Ensure helmfile fails when no helm-secrets is installed"
unset code
${helmfile} -f ${secretssops_case_input_dir}/secretssops.yaml -e direct build || code="$?"; code="${code:-0}"
${helmfile} -f ${secretssops_case_input_dir}/${config_file} -e direct build || code="$?"; code="${code:-0}"
echo Code: "${code}"
[ "${code}" -ne 0 ] || fail "\"helmfile build\" should fail without secrets plugin"
@@ -31,7 +38,7 @@ if [[ helm_major_version -eq 3 ]]; then
${helm} plugin install https://github.com/jkroepke/helm-secrets --version v${HELM_SECRETS_VERSION}
info "Ensure helmfile succeed when helm-secrets is installed"
${helmfile} -f ${secretssops_case_input_dir}/secretssops.yaml -e direct build || fail "\"helmfile build\" shouldn't fail"
${helmfile} -f ${secretssops_case_input_dir}/${config_file} -e direct build || fail "\"helmfile build\" shouldn't fail"
test_pass "secretssops.2"
@@ -46,7 +53,7 @@ if [[ helm_major_version -eq 3 ]]; then
info "Comparing build/direct output ${direct} with ${secretssops_case_output_dir}"
for i in $(seq 10); do
info "Comparing build/direct #$i"
${helmfile} -f ${secretssops_case_input_dir}/secretssops.yaml -e direct template --skip-deps > ${direct} || fail "\"helmfile template\" shouldn't fail"
${helmfile} -f ${secretssops_case_input_dir}/${config_file} -e direct template --skip-deps > ${direct} || fail "\"helmfile template\" shouldn't fail"
./dyff between -bs ${secretssops_case_output_dir}/direct.build.yaml ${direct} || fail "\"helmfile template\" should be consistent"
echo code=$?
done
@@ -54,7 +61,7 @@ if [[ helm_major_version -eq 3 ]]; then
info "Comparing build/reverse output ${direct} with ${secretssops_case_output_dir}"
for i in $(seq 10); do
info "Comparing build/reverse #$i"
${helmfile} -f ${secretssops_case_input_dir}/secretssops.yaml -e reverse template --skip-deps > ${reverse} || fail "\"helmfile template\" shouldn't fail"
${helmfile} -f ${secretssops_case_input_dir}/${config_file} -e reverse template --skip-deps > ${reverse} || fail "\"helmfile template\" shouldn't fail"
./dyff between -bs ${secretssops_case_output_dir}/reverse.build.yaml ${reverse} || fail "\"helmfile template\" should be consistent"
echo code=$?
done
+18 -14
View File
@@ -1,17 +1,21 @@
if [[ helm_major_version -eq 3 ]]; then
yaml_overwrite_case_input_dir="${cases_dir}/yaml-overwrite/input"
yaml_overwrite_case_output_dir="${cases_dir}/yaml-overwrite/output"
if [[ ${HELMFILE_V1MODE} = true ]]; then
yaml_overwrite_case_input_dir="${cases_dir}/yaml-overwrite/input"
yaml_overwrite_case_output_dir="${cases_dir}/yaml-overwrite/output"
yaml_overwrite_tmp=$(mktemp -d)
yaml_overwrite_reverse=${yaml_overwrite_tmp}/yaml.override.build.yaml
yaml_overwrite_tmp=$(mktemp -d)
yaml_overwrite_reverse=${yaml_overwrite_tmp}/yaml.override.build.yaml
test_start "yaml overwrite feature"
info "Comparing yaml overwrite feature output ${yaml_overwrite_reverse} with ${yaml_overwrite_case_output_dir}/overwritten.yaml"
for i in $(seq 10); do
info "Comparing build/yaml-overwrite #$i"
${helmfile} -f ${yaml_overwrite_case_input_dir}/issue.657.yaml template --skip-deps > ${yaml_overwrite_reverse} || fail "\"helmfile template\" shouldn't fail"
./dyff between -bs ${yaml_overwrite_case_output_dir}/overwritten.yaml ${yaml_overwrite_reverse} || fail "\"helmfile template\" should be consistent"
echo code=$?
done
test_pass "yaml overwrite feature"
fi
test_start "yaml overwrite feature"
info "Comparing yaml overwrite feature output ${yaml_overwrite_reverse} with ${yaml_overwrite_case_output_dir}/overwritten.yaml"
for i in $(seq 10); do
info "Comparing build/yaml-overwrite #$i"
${helmfile} -f ${yaml_overwrite_case_input_dir}/issue.657.yaml.gotmpl template --skip-deps > ${yaml_overwrite_reverse} || fail "\"helmfile template\" shouldn't fail"
./dyff between -bs ${yaml_overwrite_case_output_dir}/overwritten.yaml ${yaml_overwrite_reverse} || fail "\"helmfile template\" should be consistent"
echo code=$?
done
test_pass "yaml overwrite feature"
else
test_pass "[skipped] yaml overwrite feature"
fi
fi