fix(helm): fix search bugs

This fixes three things:
- #741 output is wrong
- #743 nil pointer error because of unchecked error
- Printing "Chart:" string in output
pull/744/head
Matt Butcher 9 years ago
parent 968901f9f7
commit f2b63805c2

@ -32,7 +32,6 @@ func search(cmd *cobra.Command, args []string) error {
return err
}
if len(results) > 0 {
cmd.Println("Charts:")
for _, result := range results {
fmt.Println(result)
}
@ -68,11 +67,19 @@ func searchCacheForPattern(dir string, search string) ([]string, error) {
})
matches := []string{}
for _, f := range fileList {
index, _ := repo.LoadIndexFile(f)
index, err := repo.LoadIndexFile(f)
if err != nil {
return matches, fmt.Errorf("index %s corrupted: %s", f, err)
}
m := searchChartRefsForPattern(search, index.Entries)
repoName := strings.TrimSuffix(filepath.Base(f), "-index.yaml")
for _, c := range m {
matches = append(matches, repoName+"/"+c)
// TODO: Is it possible for this file to be missing? Or to have
// an extension other than .tgz? Should the actual filename be in
// the YAML?
fname := filepath.Join(repoName, c+".tgz")
matches = append(matches, fname)
}
}
return matches, nil

@ -23,10 +23,10 @@ var searchTestCases = []searchTestCase{
var searchCacheTestCases = []searchTestCase{
{"notthere", []string{}},
{"odd", []string{"foobar/oddness-1.2.3"}},
{"sumtin", []string{"local/alpine-1.0.0", "foobar/oddness-1.2.3"}},
{"foobar", []string{"foobar/foobar-0.1.0"}},
{"web", []string{"local/nginx-0.1.0"}},
{"odd", []string{"foobar/oddness-1.2.3.tgz"}},
{"sumtin", []string{"local/alpine-1.0.0.tgz", "foobar/oddness-1.2.3.tgz"}},
{"foobar", []string{"foobar/foobar-0.1.0.tgz"}},
{"web", []string{"local/nginx-0.1.0.tgz"}},
}
func validateEntries(t *testing.T, in string, found []string, expected []string) {

Loading…
Cancel
Save