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

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

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

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

Loading…
Cancel
Save