From bfce033cc0ee9575e9c1a975dcd7878e70fcf2c1 Mon Sep 17 00:00:00 2001 From: ngtuna Date: Tue, 12 Jul 2016 11:30:06 +0700 Subject: [PATCH 1/4] fix(helm): helm repo index should not delete entry, instead it should update removed=true --- pkg/repo/repo.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/repo/repo.go b/pkg/repo/repo.go index b113629f2..c9d022799 100644 --- a/pkg/repo/repo.go +++ b/pkg/repo/repo.go @@ -105,7 +105,6 @@ func LoadChartRepository(dir, url string) (*ChartRepository, error) { } return nil }) - return r, nil } @@ -124,6 +123,8 @@ func (r *ChartRepository) Index() error { r.IndexFile = &IndexFile{Entries: make(map[string]*ChartRef)} } + var existCharts map[string]bool = make(map[string]bool) + for _, path := range r.ChartPaths { ch, err := chartutil.Load(path) if err != nil { @@ -156,6 +157,15 @@ func (r *ChartRepository) Index() error { 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() From 90192b4b2e5fa700e3a7d6c9a234cbe7d779f53b Mon Sep 17 00:00:00 2001 From: ngtuna Date: Tue, 12 Jul 2016 12:05:10 +0700 Subject: [PATCH 2/4] fix(helm): helm search should only display only those charts with a remove boolean that is set to false --- cmd/helm/search.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/helm/search.go b/cmd/helm/search.go index 287de252a..3c06aec47 100644 --- a/cmd/helm/search.go +++ b/cmd/helm/search.go @@ -60,7 +60,7 @@ func search(cmd *cobra.Command, args []string) error { func searchChartRefsForPattern(search string, chartRefs map[string]*repo.ChartRef) []string { matches := []string{} for k, c := range chartRefs { - if strings.Contains(c.Name, search) { + if strings.Contains(c.Name, search) && !c.Removed { matches = append(matches, k) continue } From 03e59fd6c06d43f94e00bf795a5e169594a8ab58 Mon Sep 17 00:00:00 2001 From: ngtuna Date: Tue, 12 Jul 2016 14:09:11 +0700 Subject: [PATCH 3/4] bypass gofmt --- pkg/repo/repo.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/repo/repo.go b/pkg/repo/repo.go index c9d022799..2d662590a 100644 --- a/pkg/repo/repo.go +++ b/pkg/repo/repo.go @@ -123,7 +123,8 @@ func (r *ChartRepository) Index() error { r.IndexFile = &IndexFile{Entries: make(map[string]*ChartRef)} } - var existCharts map[string]bool = make(map[string]bool) + var existCharts map[string]bool + existCharts = make(map[string]bool) for _, path := range r.ChartPaths { ch, err := chartutil.Load(path) @@ -162,7 +163,7 @@ func (r *ChartRepository) Index() error { } // update deleted charts with Removed = true - for k, _ := range r.IndexFile.Entries { + for k := range r.IndexFile.Entries { if _, ok := existCharts[k]; !ok { r.IndexFile.Entries[k].Removed = true } From a2d6817b9b3abc009f4130fe0a18b2a7bb38c24e Mon Sep 17 00:00:00 2001 From: ngtuna Date: Sun, 17 Jul 2016 00:54:25 +0700 Subject: [PATCH 4/4] go idiom typo --- pkg/repo/repo.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/repo/repo.go b/pkg/repo/repo.go index 2d662590a..61dffa049 100644 --- a/pkg/repo/repo.go +++ b/pkg/repo/repo.go @@ -123,8 +123,7 @@ func (r *ChartRepository) Index() error { r.IndexFile = &IndexFile{Entries: make(map[string]*ChartRef)} } - var existCharts map[string]bool - existCharts = make(map[string]bool) + existCharts := map[string]bool{} for _, path := range r.ChartPaths { ch, err := chartutil.Load(path)