Fix repo sync to work on repos duplicated between helm v2 and v3 (#1816)

Fixes #1815
This commit is contained in:
Yusuke Kuoka 2021-04-30 09:27:23 +09:00 committed by GitHub
parent 204f78c8ff
commit dabd7ad99f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 3 deletions

View File

@ -5,17 +5,28 @@ import (
) )
type Context struct { type Context struct {
updatedRepos map[string]bool updatedRepos map[string]bool
updatedReposV2 map[string]bool
} }
func NewContext() Context { func NewContext() Context {
return 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 { 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 { for _, r := range updated {
ctx.updatedRepos[r] = true ctx.updatedRepos[r] = true

View File

@ -348,6 +348,7 @@ func (st *HelmState) ApplyOverrides(spec *ReleaseSpec) {
} }
type RepoUpdater interface { type RepoUpdater interface {
IsHelm3() bool
AddRepo(name, repository, cafile, certfile, keyfile, username, password string, managed string) error AddRepo(name, repository, cafile, certfile, keyfile, username, password string, managed string) error
UpdateRepo() error UpdateRepo() error
RegistryLogin(name string, username string, password string) error RegistryLogin(name string, username string, password string) error