Remove extra appending of chartName for lint and template (#406)

Closes #407
This commit is contained in:
Eric Chin 2018-12-10 16:54:57 -05:00 committed by KUOKA Yusuke
parent 4b23213ce4
commit 2a35b6864c
1 changed files with 29 additions and 1 deletions

View File

@ -7,6 +7,7 @@ import (
"os"
"path"
"path/filepath"
"sort"
"strconv"
"strings"
"sync"
@ -385,8 +386,13 @@ func (state *HelmState) downloadCharts(helm helmexec.Interface, dir string, work
errs = append(errs, err)
}
}
chartPath = path.Join(chartPath, chartNameWithoutRepository(release.Chart))
// Set chartPath to be the path containing Chart.yaml, if found
fullChartPath, err := findChartDirectory(chartPath)
if err == nil {
chartPath = filepath.Dir(fullChartPath)
}
}
results <- &downloadResults{release.Name, chartPath}
}
wgFetch.Done()
@ -968,6 +974,28 @@ func chartNameWithoutRepository(chart string) string {
return chartSplit[len(chartSplit)-1]
}
// find "Chart.yaml"
func findChartDirectory(topLevelDir string) (string, error) {
var files []string
filepath.Walk(topLevelDir, func(path string, f os.FileInfo, _ error) error {
if !f.IsDir() {
r, err := regexp.MatchString("Chart.yaml", f.Name())
if err == nil && r {
files = append(files, path)
}
}
return nil
})
// Sort to get the shortest path
sort.Strings(files)
if len(files) > 0 {
first := files[0]
return first, nil
}
return topLevelDir, errors.New("No Chart.yaml found")
}
func (state *HelmState) flagsForUpgrade(helm helmexec.Interface, release *ReleaseSpec) ([]string, error) {
flags := []string{}
if release.Version != "" {