From 5ec70ab27fbf54ab529984db154953cbf68da78f Mon Sep 17 00:00:00 2001 From: Martin Hickey Date: Wed, 5 Feb 2020 09:38:30 +0100 Subject: [PATCH] fix(chart): lock digest differs when dependency build with Helm 2 and then Helm 3 (#7261) * Fix issue with apiVersion v1 lock digest When apiVersion v1 chart dependencies are built with Helm 2 and then built with Helm 3, the lock digests differ. To avoid this issue, a depdendency update is forced. Signed-off-by: Martin Hickey * Check against Helm v2 hash Handle scenario where dependency hash was generated by Helm v2 but need to do a dependency build with Helm v3. Signed-off-by: Martin Hickey * Add unit test Signed-off-by: Martin Hickey * Refactor unit test Refactor unit test to use an existing chart as dependency Signed-off-by: Martin Hickey * Update after review Comments: - https://github.com/helm/helm/pull/7261#discussion_r373827088 - https://github.com/helm/helm/pull/7261#discussion_r373827250 Signed-off-by: Martin Hickey --- cmd/helm/dependency_build_test.go | 13 +++++++++++ .../testcharts/issue-7233/.helmignore | 22 ++++++++++++++++++ .../testdata/testcharts/issue-7233/Chart.yaml | 5 ++++ .../issue-7233/charts/alpine-0.1.0.tgz | Bin 0 -> 1167 bytes .../testcharts/issue-7233/requirements.lock | 6 +++++ .../testcharts/issue-7233/requirements.yaml | 4 ++++ .../issue-7233/templates/configmap.yaml | 7 ++++++ .../testcharts/issue-7233/values.yaml | 1 + internal/resolver/resolver.go | 16 +++++++++++++ pkg/downloader/manager.go | 13 ++++++++++- 10 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 cmd/helm/testdata/testcharts/issue-7233/.helmignore create mode 100644 cmd/helm/testdata/testcharts/issue-7233/Chart.yaml create mode 100644 cmd/helm/testdata/testcharts/issue-7233/charts/alpine-0.1.0.tgz create mode 100644 cmd/helm/testdata/testcharts/issue-7233/requirements.lock create mode 100644 cmd/helm/testdata/testcharts/issue-7233/requirements.yaml create mode 100644 cmd/helm/testdata/testcharts/issue-7233/templates/configmap.yaml create mode 100644 cmd/helm/testdata/testcharts/issue-7233/values.yaml diff --git a/cmd/helm/dependency_build_test.go b/cmd/helm/dependency_build_test.go index 58ef3d3a1..eeca12fa6 100644 --- a/cmd/helm/dependency_build_test.go +++ b/cmd/helm/dependency_build_test.go @@ -100,3 +100,16 @@ func TestDependencyBuildCmd(t *testing.T) { t.Errorf("mismatched versions. Expected %q, got %q", "0.1.0", v) } } + +func TestDependencyBuildCmdWithHelmV2Hash(t *testing.T) { + chartName := "testdata/testcharts/issue-7233" + + cmd := fmt.Sprintf("dependency build '%s'", chartName) + _, out, err := executeActionCommand(cmd) + + // Want to make sure the build can verify Helm v2 hash + if err != nil { + t.Logf("Output: %s", out) + t.Fatal(err) + } +} diff --git a/cmd/helm/testdata/testcharts/issue-7233/.helmignore b/cmd/helm/testdata/testcharts/issue-7233/.helmignore new file mode 100644 index 000000000..50af03172 --- /dev/null +++ b/cmd/helm/testdata/testcharts/issue-7233/.helmignore @@ -0,0 +1,22 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/cmd/helm/testdata/testcharts/issue-7233/Chart.yaml b/cmd/helm/testdata/testcharts/issue-7233/Chart.yaml new file mode 100644 index 000000000..b31997acb --- /dev/null +++ b/cmd/helm/testdata/testcharts/issue-7233/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: issue-7233 +version: 0.1.0 diff --git a/cmd/helm/testdata/testcharts/issue-7233/charts/alpine-0.1.0.tgz b/cmd/helm/testdata/testcharts/issue-7233/charts/alpine-0.1.0.tgz new file mode 100644 index 0000000000000000000000000000000000000000..a64d9ed46a25dec2446050321772fc2d1d35417a GIT binary patch literal 1167 zcmV;A1aSKwiwG0|00000|0w_~VMtOiV@ORlOnEsqVl!4SWK%V1T2nbTPgYhoO;>Dc zVQyr3R8em|NM&qo0PI*zkJ~mA-m`wiK)J@U{EhgwcoX0a+6KY42v8J7J(k86u@tG2 zl(nkk|6Y)kylZWg!7!$MJkRbge~so=5(gf(iGz_kk=_?C(C4hoqDnapVknK6Z44u=`>Jkpta z1_JFTA8vt`rAkOIgTZm~mYJ+vM~Tece7|Vd>JmqzC=OoQS^q+5_`gG5l0H)cc#i+^ zIPUU)F`D%Jzl3~nw9M;4!_1e~ryp+aFSq$YwYL(@PhZ-xeh0+nG&$x*qzER-T$ zNTJ!9lf{eNqNi+F!UNZQPin^!g3s`4DGkBl@U$zK&;~_9AtX}lNZ3vba=axC%mAUT zolh76wt6>!MgnpUaswtK_~wXe4e$*Xm<$b6qzDp4Xsq+JGuf}|I^;{HwmO~|YLC2Y z<>RHt7H+?X$X_$Ak4@%7=P>=)YAjP`{5eCZaoZ@^HkR@{4IAC~^T*~SMZfbVjg z5hr0A=zImL%tdUHEkOnrg6zOX_-~jD*_Bd18V98ChqXXOT+rjVy?MQ_Xod6#W z785~pw#^K$K^BJP>^DlGIfW)x99k}IR2)MNIp|s#ymRh3!G+Jz+1MT1$(-dMY1cTp zqhtVfTZ2rHa(QCVB$x`BA>~er<+!ye$5*4}7h=bsY9jL-ZQA-N9IlxdYED#yufsQS z9EU&m9nF){)c>1z*Kfaj7vNZo@w6-Hvw@O-F+A0SXGZ|oz$kKk28(ZKoCqqiN;1BM%E7&kj_rQ;m zt#-Wco9@kRCq%=e#V>v8_tNm6?u^1;&h!`H z+57)w(&7JfG#>Z-zl0dl#@1l}AHapdz=y%#C`fxbn>75l&EUD{|0nq0z5h=Z)41pV hCFGR