add duplicate check before downloading repo indexes

Signed-off-by: Lucas Medeiros <lucas@lucasmdrs.com>
pull/9881/head
Lucas Medeiros 4 years ago
parent fa558f7843
commit 1cc60c71af
No known key found for this signature in database
GPG Key ID: D3993AFC1442399F

@ -530,6 +530,11 @@ func (m *Manager) ensureMissingRepos(repoNames map[string]string, deps []*chart.
// the dependencies that are not known to the user if update skipping // the dependencies that are not known to the user if update skipping
// is not configured. // is not configured.
if !m.SkipUpdate && len(ru) > 0 { if !m.SkipUpdate && len(ru) > 0 {
// Some dependencies might have a diferent names but point to the same repository
// after creating a unique key we should remove duplicated entries to avoid unecessary work
ru = removeDuplicates(ru)
fmt.Fprintln(m.Out, "Getting updates for unmanaged Helm repositories...") fmt.Fprintln(m.Out, "Getting updates for unmanaged Helm repositories...")
if err := m.parallelRepoUpdate(ru); err != nil { if err := m.parallelRepoUpdate(ru); err != nil {
return repoNames, err return repoNames, err
@ -896,3 +901,18 @@ func key(name string) (string, error) {
} }
return hex.EncodeToString(hash.Sum(nil)), nil return hex.EncodeToString(hash.Sum(nil)), nil
} }
// removeDuplicates remove entries with the same name or unique key
func removeDuplicates(re []*repo.Entry) []*repo.Entry {
m := make(map[string]struct{})
uniq := make([]*repo.Entry, 0)
for _, r := range re {
if _, ok := m[r.Name]; ok {
continue
}
m[r.Name] = struct{}{}
uniq = append(uniq, r)
}
return uniq
}

Loading…
Cancel
Save