From 9bc78168d4ffadda0d7767d1101300649dddda92 Mon Sep 17 00:00:00 2001 From: Alik Khilazhev <7482065+alikhil@users.noreply.github.com> Date: Sun, 21 Sep 2025 22:59:35 +0200 Subject: [PATCH] fix failing tests Signed-off-by: Alik Khilazhev <7482065+alikhil@users.noreply.github.com> --- pkg/cmd/dependency.go | 2 +- pkg/cmd/dependency_build_test.go | 62 ++++++++++++++++++ pkg/cmd/helpers_test.go | 2 +- .../install-dependency-update-recursive.txt | 1 + .../template-dependency-update-recursive.txt | 6 -- pkg/cmd/testdata/testcharts/root-0.1.0.tgz | Bin 0 -> 1120 bytes pkg/downloader/manager.go | 20 +++--- 7 files changed, 75 insertions(+), 18 deletions(-) create mode 100644 pkg/cmd/testdata/testcharts/root-0.1.0.tgz diff --git a/pkg/cmd/dependency.go b/pkg/cmd/dependency.go index bb7dfe707..b3fc00552 100644 --- a/pkg/cmd/dependency.go +++ b/pkg/cmd/dependency.go @@ -133,5 +133,5 @@ func addDependencySubcommandFlags(f *pflag.FlagSet, client *action.Dependency) { f.BoolVar(&client.InsecureSkipTLSverify, "insecure-skip-tls-verify", false, "skip tls certificate checks for the chart download") f.BoolVar(&client.PlainHTTP, "plain-http", false, "use insecure HTTP connections for the chart download") f.StringVar(&client.CaFile, "ca-file", "", "verify certificates of HTTPS-enabled servers using this CA bundle") - f.BoolVar(&client.BuildOrUpdateRecursive, "recursive", false, "build dependencies recursively") + f.BoolVar(&client.BuildOrUpdateRecursive, "recursive", false, "build or update dependencies recursively") } diff --git a/pkg/cmd/dependency_build_test.go b/pkg/cmd/dependency_build_test.go index a3473301d..9d031457a 100644 --- a/pkg/cmd/dependency_build_test.go +++ b/pkg/cmd/dependency_build_test.go @@ -22,6 +22,7 @@ import ( "strings" "testing" + chart "helm.sh/helm/v4/pkg/chart/v2" chartutil "helm.sh/helm/v4/pkg/chart/v2/util" "helm.sh/helm/v4/pkg/provenance" "helm.sh/helm/v4/pkg/repo/v1" @@ -162,3 +163,64 @@ func TestDependencyBuildCmdWithHelmV2Hash(t *testing.T) { t.Fatal(err) } } + +// createTestingChart creates a basic chart that depends on reqtest-0.1.0 +// +// The baseURL can be used to point to a particular repository server. +func createTestingChartWithRecursion(t *testing.T, dest, name, baseURL string) { + t.Helper() + cfile := &chart.Chart{ + Metadata: &chart.Metadata{ + APIVersion: chart.APIVersionV2, + Name: name, + Version: "1.2.3", + Dependencies: []*chart.Dependency{ + {Name: "reqtest", Version: "0.1.0", Repository: baseURL}, + {Name: "compressedchart", Version: "0.1.0", Repository: baseURL}, + {Name: "root", Version: "0.1.0", Repository: baseURL}, + }, + }, + } + if err := chartutil.SaveDir(cfile, dest); err != nil { + t.Fatal(err) + } +} + +func TestDependencyBuildCmdRecursive(t *testing.T) { + srv := repotest.NewTempServer( + t, + repotest.WithChartSourceGlob("testdata/testcharts/*.tgz"), + ) + defer srv.Stop() + rootDir := srv.Root() + + srv.LinkIndices() + ociSrv, err := repotest.NewOCIServer(t, rootDir) + if err != nil { + t.Fatal(err) + } + + dir := func(p ...string) string { + return filepath.Join(append([]string{rootDir}, p...)...) + } + + ociChartName := "oci-depending-chart" + c := createTestingMetadataForOCI(ociChartName, ociSrv.RegistryURL) + if _, err := chartutil.Save(c, ociSrv.Dir); err != nil { + t.Fatal(err) + } + ociSrv.Run(t, repotest.WithDependingChart(c)) + + chartname := "chart-with-multi-level-deps" + createTestingChartWithRecursion(t, dir(), chartname, srv.URL()) + repoFile := filepath.Join(dir(), "repositories.yaml") + + cmd := fmt.Sprintf("dependency build '%s' --repository-config %s --repository-cache %s --plain-http --recursive", filepath.Join(rootDir, chartname), repoFile, rootDir) + _, out, err := executeActionCommand(cmd) + + // In the first pass, we basically want the same results as an update. + if err != nil { + t.Logf("Output: %s", out) + t.Fatal(err) + } +} diff --git a/pkg/cmd/helpers_test.go b/pkg/cmd/helpers_test.go index 3f04a6a9b..5432ff2de 100644 --- a/pkg/cmd/helpers_test.go +++ b/pkg/cmd/helpers_test.go @@ -31,8 +31,8 @@ import ( "helm.sh/helm/v4/internal/test" "helm.sh/helm/v4/pkg/action" + "helm.sh/helm/v4/pkg/chart/common" "helm.sh/helm/v4/pkg/chart/v2/loader" - chartutil "helm.sh/helm/v4/pkg/chart/v2/util" "helm.sh/helm/v4/pkg/cli" kubefake "helm.sh/helm/v4/pkg/kube/fake" release "helm.sh/helm/v4/pkg/release/v1" diff --git a/pkg/cmd/testdata/output/install-dependency-update-recursive.txt b/pkg/cmd/testdata/output/install-dependency-update-recursive.txt index 9b25fbe36..16ece824e 100644 --- a/pkg/cmd/testdata/output/install-dependency-update-recursive.txt +++ b/pkg/cmd/testdata/output/install-dependency-update-recursive.txt @@ -3,4 +3,5 @@ LAST DEPLOYED: Fri Sep 2 22:04:05 1977 NAMESPACE: default STATUS: deployed REVISION: 1 +DESCRIPTION: Install complete TEST SUITE: None diff --git a/pkg/cmd/testdata/output/template-dependency-update-recursive.txt b/pkg/cmd/testdata/output/template-dependency-update-recursive.txt index 46a53092f..5c451ad75 100644 --- a/pkg/cmd/testdata/output/template-dependency-update-recursive.txt +++ b/pkg/cmd/testdata/output/template-dependency-update-recursive.txt @@ -1,11 +1,5 @@ -Hang tight while we grab the latest from your chart repositories... -...Successfully got an update from the "kube-sigs-external-dns" chart repository -Update Complete. ⎈Happy Helming!⎈ Saving 1 charts Deleting outdated charts -Hang tight while we grab the latest from your chart repositories... -...Successfully got an update from the "kube-sigs-external-dns" chart repository -Update Complete. ⎈Happy Helming!⎈ Saving 1 charts Deleting outdated charts --- diff --git a/pkg/cmd/testdata/testcharts/root-0.1.0.tgz b/pkg/cmd/testdata/testcharts/root-0.1.0.tgz new file mode 100644 index 0000000000000000000000000000000000000000..265ce8d89c76894ba304ba13d23a9785febdfc30 GIT binary patch literal 1120 zcmV-m1fTmKiwG0|00000|0w_~VMtOiV@ORlOnEsqVl!4SWK%V1T2nbTPgYhoO;>Dc zVQyr3R8em|NM&qo0PLH=ZlgvV#<4fuWm#47p_TSH+8(>H|1&THrk6BHrAk#VO|(61 zt8`$71O)>EoG6MS<=nndpQO)IfhSECXOlXy$$B+E$@;J{FfjAs|Ja|4EUQL4N4%(p zXMBO-XyS3z_0gChHOlT zO}+)<1H939hKJJl|AZ$~S+1-AxX=Ifa?Ae?Fzx>?X!^gBlRV*-EJtCMM)Bc<=k@E$ z8W8vPKVz-_r>?8-|DEtb{fDjNI2AtHX-2`%JhvvY;(}M)w-CBfsXcY8HOr#$|8RHj zV6Vywxte3#?SJe5I4%EU7rWa39nssK3Tzky!!S%^raklax0>oPNB?SHv&X4})9q}Uit_!973NFx<-y?f z`8fr6iyV($yhZ0@QZL)=;^L+G^*5vMemOW!CTaGkYI;wd!PgpDZQL&Pra|NbVI4Bbf6R|-BNlv zQ+3nosmVuA9rT&AD{ngG@8$t-p20U?)LSBV2-{j z1pc_%KotVUEk!_o_GRH~<9fX=1T-3r<`bd${jUk;l})f`67T6cK*j9I{)1b%QO6k`OhfCHkO>bp$Ny|@i5{c zrrwy7Krk_Oz@yZa0h2WF>?raC^`r|9xE}K`q0#O6PrOfvZ`(fghPG=1*748BGUxvl zWI-3te>#-d+W%cJ*Z;RRocQ@2{PEav=wy-b!h7rf8^ zn6>}^!yKaLf1S{p|M5Kk?