From dabd7ad99fad920fbe3e5cb27ab90ae6242c737d Mon Sep 17 00:00:00 2001 From: Yusuke Kuoka Date: Fri, 30 Apr 2021 09:27:23 +0900 Subject: [PATCH] Fix repo sync to work on repos duplicated between helm v2 and v3 (#1816) Fixes #1815 --- pkg/app/context.go | 17 ++++++++++++++--- pkg/state/state.go | 1 + 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/pkg/app/context.go b/pkg/app/context.go index 592bcba2..db9f5f4a 100644 --- a/pkg/app/context.go +++ b/pkg/app/context.go @@ -5,17 +5,28 @@ import ( ) type Context struct { - updatedRepos map[string]bool + updatedRepos map[string]bool + updatedReposV2 map[string]bool } func NewContext() Context { return Context{ - updatedRepos: map[string]bool{}, + updatedRepos: map[string]bool{}, + updatedReposV2: map[string]bool{}, } } func (ctx Context) SyncReposOnce(st *state.HelmState, helm state.RepoUpdater) error { - updated, err := st.SyncRepos(helm, ctx.updatedRepos) + var ( + updated []string + err error + ) + + if helm.IsHelm3() { + updated, err = st.SyncRepos(helm, ctx.updatedRepos) + } else { + updated, err = st.SyncRepos(helm, ctx.updatedReposV2) + } for _, r := range updated { ctx.updatedRepos[r] = true diff --git a/pkg/state/state.go b/pkg/state/state.go index 49314023..a5010200 100644 --- a/pkg/state/state.go +++ b/pkg/state/state.go @@ -348,6 +348,7 @@ func (st *HelmState) ApplyOverrides(spec *ReleaseSpec) { } type RepoUpdater interface { + IsHelm3() bool AddRepo(name, repository, cafile, certfile, keyfile, username, password string, managed string) error UpdateRepo() error RegistryLogin(name string, username string, password string) error