Merge pull request #744 from technosophos/fix/741-search

fix(helm): fix search bugs
pull/754/head
Matt Butcher 9 years ago
commit 475544fb43

@ -32,7 +32,6 @@ func search(cmd *cobra.Command, args []string) error {
return err return err
} }
if len(results) > 0 { if len(results) > 0 {
cmd.Println("Charts:")
for _, result := range results { for _, result := range results {
fmt.Println(result) fmt.Println(result)
} }
@ -68,11 +67,19 @@ func searchCacheForPattern(dir string, search string) ([]string, error) {
}) })
matches := []string{} matches := []string{}
for _, f := range fileList { 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) m := searchChartRefsForPattern(search, index.Entries)
repoName := strings.TrimSuffix(filepath.Base(f), "-index.yaml") repoName := strings.TrimSuffix(filepath.Base(f), "-index.yaml")
for _, c := range m { 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 return matches, nil

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

Loading…
Cancel
Save