mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-06 20:51:30 +02:00
Resolves #1232 CHANGES: * Disable repo update when installed is false When install is false, we do not need to update the repositories and get the chart. Signed-off-by: Guillaume Perrin <guillaume28.perrin@gmail.com>
45 lines
791 B
Go
45 lines
791 B
Go
package app
|
|
|
|
import (
|
|
"github.com/roboll/helmfile/pkg/state"
|
|
)
|
|
|
|
type Context struct {
|
|
updatedRepos map[string]struct{}
|
|
}
|
|
|
|
func NewContext() Context {
|
|
return Context{
|
|
updatedRepos: map[string]struct{}{},
|
|
}
|
|
}
|
|
|
|
func (ctx Context) SyncReposOnce(st *state.HelmState, helm state.RepoUpdater) []error {
|
|
var errs []error
|
|
|
|
hasInstalled := false
|
|
for _, release := range st.Releases {
|
|
hasInstalled = hasInstalled || release.Installed == nil || *release.Installed
|
|
}
|
|
|
|
if !hasInstalled {
|
|
return errs
|
|
}
|
|
|
|
allUpdated := true
|
|
for _, r := range st.Repositories {
|
|
_, exists := ctx.updatedRepos[r.Name]
|
|
allUpdated = allUpdated && exists
|
|
}
|
|
|
|
if !allUpdated {
|
|
errs = st.SyncRepos(helm)
|
|
|
|
for _, r := range st.Repositories {
|
|
ctx.updatedRepos[r.Name] = struct{}{}
|
|
}
|
|
}
|
|
|
|
return errs
|
|
}
|