diff --git a/pkg/downloader/manager.go b/pkg/downloader/manager.go index 98d66a20f..ca70d4659 100644 --- a/pkg/downloader/manager.go +++ b/pkg/downloader/manager.go @@ -217,13 +217,11 @@ func (m *Manager) downloadAll(deps []*chartutil.Dependency) error { var saveError error for _, dep := range deps { var isSubChart bool - if strings.HasPrefix(dep.Repository, "file://") { - //check if file repo path does belong to the current chart "/charts" folder - isSubChart, err = resolver.IsLocalSubChart(dep.Repository, m.ChartPath) - if err != nil { - saveError = err - } //else everythig is fine. - } + //check if file repo path does belong to the current chart "/charts" folder + isSubChart, err = resolver.IsLocalSubChart(dep.Repository, m.ChartPath) + if err != nil { + saveError = err + } //else everything is fine. //Only download or package dependencies that are not sub chart in the "/charts" folder if !isSubChart { diff --git a/pkg/downloader/manager_test.go b/pkg/downloader/manager_test.go index ed806ccae..375f13669 100644 --- a/pkg/downloader/manager_test.go +++ b/pkg/downloader/manager_test.go @@ -203,10 +203,10 @@ func TestDownloadAllSubChartsOnly(t *testing.T) { } //create the /charts subdir chartsFolder := filepath.Join(tmp, "charts") + err = os.Mkdir(chartsFolder, 0755) if err != nil { t.Fatal(err) } - os.Mkdir(chartsFolder, 0755) tests := []struct { name string @@ -215,7 +215,7 @@ func TestDownloadAllSubChartsOnly(t *testing.T) { err bool }{ { - name: "sub char relative no dot", + name: "sub chart relative no dot", req: []*chartutil.Dependency{ {Name: "foo", Repository: "file://charts/foo"}, }, @@ -236,8 +236,7 @@ func TestDownloadAllSubChartsOnly(t *testing.T) { for _, tt := range tests { //we only check the downloadAll does not return any error. - err := m.downloadAll(tt.req) - if err != nil { + if err := m.downloadAll(tt.req); err != nil { t.Fatal(err) } } diff --git a/pkg/resolver/resolver.go b/pkg/resolver/resolver.go index 669de8d63..c64b0bd8e 100644 --- a/pkg/resolver/resolver.go +++ b/pkg/resolver/resolver.go @@ -167,7 +167,6 @@ func IsLocalSubChart(repo string, chartpath string) (bool, error) { if !strings.HasPrefix(repo, "file://") { return false, nil } - var isSubChart bool destPath := filepath.Join(chartpath, "charts") origPath, err := GenerateLocalPath(repo, chartpath) @@ -178,6 +177,5 @@ func IsLocalSubChart(repo string, chartpath string) (bool, error) { if err != nil { return false, err } - isSubChart = !strings.HasPrefix(relPath, ".") - return isSubChart, nil + return !strings.HasPrefix(relPath, "."), nil } diff --git a/pkg/resolver/resolver_test.go b/pkg/resolver/resolver_test.go index 41fbd3009..4305537e0 100644 --- a/pkg/resolver/resolver_test.go +++ b/pkg/resolver/resolver_test.go @@ -190,25 +190,25 @@ func TestIsSubChart(t *testing.T) { res: true, }, { - name: "absolute subchart ", + name: "absolute subchart", chartPath: "/foo", repo: "file:///foo/charts/bar", res: true, }, { - name: "absolute not subchart ", + name: "absolute not subchart", chartPath: "/foo", repo: "file:///bar/charts/bar", res: false, }, { - name: "relative not subchart ", + name: "relative not subchart", chartPath: "/foo", repo: "file:///./bar", res: false, }, { - name: "not file:// ", + name: "not file://", chartPath: "/foo", repo: "XXX", res: false,