fix failing tests

Signed-off-by: Alik Khilazhev <7482065+alikhil@users.noreply.github.com>
pull/30855/head
Alik Khilazhev 4 days ago
parent 98cfec128b
commit 9bc78168d4
No known key found for this signature in database
GPG Key ID: 141EBCECAE009661

@ -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")
}

@ -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)
}
}

@ -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"

@ -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

@ -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
---

Binary file not shown.

@ -833,19 +833,19 @@ func (m *Manager) locateLocalDependencies(baseChartPath string, resursive bool)
[]string{fullDepChartPath},
reversedDeps...,
)
}
if resursive {
subDeps, err := m.locateLocalDependencies(fullDepChartPath, resursive)
if resursive {
subDeps, err := m.locateLocalDependencies(fullDepChartPath, resursive)
if err != nil {
return nil, err
}
if err != nil {
return nil, err
}
reversedDeps = append(
subDeps,
reversedDeps...,
)
reversedDeps = append(
subDeps,
reversedDeps...,
)
}
}
}

Loading…
Cancel
Save