Merge pull request #947 from ngtuna/master

Fix #872: index function should handle deleted charts correctly
pull/961/head
Michelle Noorali 9 years ago committed by GitHub
commit 80a7339e2f

@ -60,7 +60,7 @@ func search(cmd *cobra.Command, args []string) error {
func searchChartRefsForPattern(search string, chartRefs map[string]*repo.ChartRef) []string { func searchChartRefsForPattern(search string, chartRefs map[string]*repo.ChartRef) []string {
matches := []string{} matches := []string{}
for k, c := range chartRefs { for k, c := range chartRefs {
if strings.Contains(c.Name, search) { if strings.Contains(c.Name, search) && !c.Removed {
matches = append(matches, k) matches = append(matches, k)
continue continue
} }

@ -105,7 +105,6 @@ func LoadChartRepository(dir, url string) (*ChartRepository, error) {
} }
return nil return nil
}) })
return r, nil return r, nil
} }
@ -124,6 +123,8 @@ func (r *ChartRepository) Index() error {
r.IndexFile = &IndexFile{Entries: make(map[string]*ChartRef)} r.IndexFile = &IndexFile{Entries: make(map[string]*ChartRef)}
} }
existCharts := map[string]bool{}
for _, path := range r.ChartPaths { for _, path := range r.ChartPaths {
ch, err := chartutil.Load(path) ch, err := chartutil.Load(path)
if err != nil { if err != nil {
@ -156,6 +157,15 @@ func (r *ChartRepository) Index() error {
r.IndexFile.Entries[key] = entry r.IndexFile.Entries[key] = entry
// chart is existing
existCharts[key] = true
}
// update deleted charts with Removed = true
for k := range r.IndexFile.Entries {
if _, ok := existCharts[k]; !ok {
r.IndexFile.Entries[k].Removed = true
}
} }
return r.saveIndexFile() return r.saveIndexFile()

Loading…
Cancel
Save