fix(helm): fix failing helm dep up on subchar requirements

changes following the review
Closes #3742
Signed-off-by: Sebastien Gandon <sgandon@talend.com>

Signed-off-by: Sebastien Gandon <sgandon@talend.com>
pull/3987/head
Sebastien Gandon 7 years ago
parent d04b43179b
commit ead7b9024d

@ -217,13 +217,11 @@ func (m *Manager) downloadAll(deps []*chartutil.Dependency) error {
var saveError error var saveError error
for _, dep := range deps { for _, dep := range deps {
var isSubChart bool var isSubChart bool
if strings.HasPrefix(dep.Repository, "file://") { //check if file repo path does belong to the current chart "/charts" folder
//check if file repo path does belong to the current chart "/charts" folder isSubChart, err = resolver.IsLocalSubChart(dep.Repository, m.ChartPath)
isSubChart, err = resolver.IsLocalSubChart(dep.Repository, m.ChartPath) if err != nil {
if err != nil { saveError = err
saveError = err } //else everything is fine.
} //else everythig is fine.
}
//Only download or package dependencies that are not sub chart in the "/charts" folder //Only download or package dependencies that are not sub chart in the "/charts" folder
if !isSubChart { if !isSubChart {

@ -203,10 +203,10 @@ func TestDownloadAllSubChartsOnly(t *testing.T) {
} }
//create the /charts subdir //create the /charts subdir
chartsFolder := filepath.Join(tmp, "charts") chartsFolder := filepath.Join(tmp, "charts")
err = os.Mkdir(chartsFolder, 0755)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
os.Mkdir(chartsFolder, 0755)
tests := []struct { tests := []struct {
name string name string
@ -215,7 +215,7 @@ func TestDownloadAllSubChartsOnly(t *testing.T) {
err bool err bool
}{ }{
{ {
name: "sub char relative no dot", name: "sub chart relative no dot",
req: []*chartutil.Dependency{ req: []*chartutil.Dependency{
{Name: "foo", Repository: "file://charts/foo"}, {Name: "foo", Repository: "file://charts/foo"},
}, },
@ -236,8 +236,7 @@ func TestDownloadAllSubChartsOnly(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
//we only check the downloadAll does not return any error. //we only check the downloadAll does not return any error.
err := m.downloadAll(tt.req) if err := m.downloadAll(tt.req); err != nil {
if err != nil {
t.Fatal(err) t.Fatal(err)
} }
} }

@ -167,7 +167,6 @@ func IsLocalSubChart(repo string, chartpath string) (bool, error) {
if !strings.HasPrefix(repo, "file://") { if !strings.HasPrefix(repo, "file://") {
return false, nil return false, nil
} }
var isSubChart bool
destPath := filepath.Join(chartpath, "charts") destPath := filepath.Join(chartpath, "charts")
origPath, err := GenerateLocalPath(repo, chartpath) origPath, err := GenerateLocalPath(repo, chartpath)
@ -178,6 +177,5 @@ func IsLocalSubChart(repo string, chartpath string) (bool, error) {
if err != nil { if err != nil {
return false, err return false, err
} }
isSubChart = !strings.HasPrefix(relPath, ".") return !strings.HasPrefix(relPath, "."), nil
return isSubChart, nil
} }

@ -190,25 +190,25 @@ func TestIsSubChart(t *testing.T) {
res: true, res: true,
}, },
{ {
name: "absolute subchart ", name: "absolute subchart",
chartPath: "/foo", chartPath: "/foo",
repo: "file:///foo/charts/bar", repo: "file:///foo/charts/bar",
res: true, res: true,
}, },
{ {
name: "absolute not subchart ", name: "absolute not subchart",
chartPath: "/foo", chartPath: "/foo",
repo: "file:///bar/charts/bar", repo: "file:///bar/charts/bar",
res: false, res: false,
}, },
{ {
name: "relative not subchart ", name: "relative not subchart",
chartPath: "/foo", chartPath: "/foo",
repo: "file:///./bar", repo: "file:///./bar",
res: false, res: false,
}, },
{ {
name: "not file:// ", name: "not file://",
chartPath: "/foo", chartPath: "/foo",
repo: "XXX", repo: "XXX",
res: false, res: false,

Loading…
Cancel
Save