fix fetch does not work with kustomized releases (#624)

* fix fetch does not work with kustomized releases

Signed-off-by: xiaomudk <xiaomudk@gmail.com>

* add tests

Signed-off-by: yxxhero <aiopsclub@163.com>

Signed-off-by: xiaomudk <xiaomudk@gmail.com>
Signed-off-by: yxxhero <aiopsclub@163.com>
Co-authored-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
xiaomudk 2023-01-15 09:19:01 +08:00 committed by GitHub
parent 8d96bbb0e4
commit 1f134d931f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 40 additions and 1 deletions

View File

@ -1190,7 +1190,7 @@ func (st *HelmState) PrepareCharts(helm helmexec.Interface, dir string, concurre
skipDepsDefault := release.SkipDeps == nil && st.HelmDefaults.SkipDeps
skipDeps := (!isLocal && !chartFetchedByGoGetter) || skipDepsGlobal || skipDepsRelease || skipDepsDefault
if chartification != nil {
if chartification != nil && helmfileCommand != "pull" {
c := chartify.New(
chartify.HelmBin(st.DefaultHelmBinary),
chartify.UseHelm3(helm3),

View File

@ -85,6 +85,7 @@ ${kubectl} create namespace ${test_ns} || fail "Could not create namespace ${tes
# TEST CASES----------------------------------------------------------------------------------------------------------
. ${dir}/test-cases/kustomized-fetch.sh
. ${dir}/test-cases/happypath.sh
. ${dir}/test-cases/regression.sh
. ${dir}/test-cases/secretssops.sh

View File

@ -0,0 +1,12 @@
yaml_kustomized_fetch_input_dir="${cases_dir}/kustomized-fetch/input"
test_start "kustomized fetch issue"
info "Checking kustomized fetch issue with ${yaml_kustomized_fetch_input_dir}/helmfile.yaml"
for i in $(seq 10); do
info "checking kustomized fetch issue #$i"
kustomized_fetch_tmp=$(mktemp -d)
${helmfile} -f ${yaml_kustomized_fetch_input_dir}/helmfile.yaml fetch --output-dir ${kustomized_fetch_tmp} || fail "\"helmfile fetch\" shouldn't fail"
rm -fr ${kustomized_fetch_tmp}
echo code=$?
done

View File

@ -0,0 +1,26 @@
repositories:
- name: incubator
url: https://charts.helm.sh/incubator
---
releases:
- name: service-a
chart: incubator/raw
values:
- resources:
- apiVersion: v1
kind: ConfigMap
metadata:
name: raw1
namespace: default
data:
foo: FOO
transformers:
- apiVersion: builtin
kind: LabelTransformer
metadata:
name: justForTests
labels:
some-cool: label
fieldSpecs:
- path: metadata/labels
create: true