Add ability to specify and override helmDefaults.wait via cli (#1678)

This commit is contained in:
Jason Witkowski 2021-02-23 22:47:27 -05:00 committed by GitHub
parent f24b61f100
commit bd3838c059
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 1 deletions

12
main.go
View File

@ -353,6 +353,10 @@ func main() {
Name: "skip-deps",
Usage: `skip running "helm repo update" and "helm dependency build"`,
},
cli.BoolFlag{
Name: "wait",
Usage: `Override helmDefaults.wait setting "helm upgrade --install --wait"`,
},
},
Action: action(func(run *app.App, c configImpl) error {
return run.Sync(c)
@ -417,6 +421,10 @@ func main() {
Name: "skip-deps",
Usage: `skip running "helm repo update" and "helm dependency build"`,
},
cli.BoolFlag{
Name: "wait",
Usage: `Override helmDefaults.wait setting "helm upgrade --install --wait"`,
},
},
Action: action(func(run *app.App, c configImpl) error {
return run.Apply(c)
@ -603,6 +611,10 @@ func (c configImpl) SkipRepos() bool {
return c.c.Bool("skip-repos")
}
func (c configImpl) Wait() bool {
return c.c.Bool("wait")
}
func (c configImpl) Values() []string {
return c.c.StringSlice("values")
}

View File

@ -294,6 +294,7 @@ func (a *App) Sync(c SyncConfigProvider) error {
prepErr := run.withPreparedCharts("sync", state.ChartPrepareOptions{
SkipRepos: c.SkipDeps(),
SkipDeps: c.SkipDeps(),
Wait: c.Wait(),
}, func() {
ok, errs = a.sync(run, c)
})
@ -319,6 +320,7 @@ func (a *App) Apply(c ApplyConfigProvider) error {
prepErr := run.withPreparedCharts("apply", state.ChartPrepareOptions{
SkipRepos: c.SkipDeps(),
SkipDeps: c.SkipDeps(),
Wait: c.Wait(),
}, func() {
matched, updated, es := a.apply(run, c)
@ -1179,6 +1181,7 @@ Do you really want to apply?
syncOpts := state.SyncOpts{
Set: c.Set(),
SkipCleanup: c.RetainValuesFiles() || c.SkipCleanup(),
Wait: c.Wait(),
}
return subst.SyncReleases(&affectedReleases, helm, c.Values(), c.Concurrency(), &syncOpts)
}))
@ -1393,7 +1396,8 @@ func (a *App) sync(r *Run, c SyncConfigProvider) (bool, []error) {
subst.Releases = rs
opts := &state.SyncOpts{
Set: c.Set(),
Set: c.Set(),
Wait: c.Wait(),
}
return subst.SyncReleases(&affectedReleases, helm, c.Values(), c.Concurrency(), opts)
}))

View File

@ -2315,12 +2315,17 @@ type applyConfig struct {
interactive bool
skipDiffOnInstall bool
logger *zap.SugaredLogger
wait bool
}
func (a applyConfig) Args() string {
return a.args
}
func (a applyConfig) Wait() bool {
return a.wait
}
func (a applyConfig) Values() []string {
return a.values
}

View File

@ -39,6 +39,7 @@ type ApplyConfigProvider interface {
Values() []string
Set() []string
SkipDeps() bool
Wait() bool
IncludeTests() bool
@ -65,6 +66,7 @@ type SyncConfigProvider interface {
Values() []string
Set() []string
SkipDeps() bool
Wait() bool
concurrencyConfig
loggingConfig

View File

@ -504,6 +504,10 @@ func (st *HelmState) prepareSyncReleases(helm helmexec.Interface, additionalValu
}
}
if opts.Wait {
flags = append(flags, "--wait")
}
if len(errs) > 0 {
results <- syncPrepareResult{errors: errs, files: files}
continue
@ -578,6 +582,7 @@ func (st *HelmState) DetectReleasesToBeDeleted(helm helmexec.Interface, releases
type SyncOpts struct {
Set []string
SkipCleanup bool
Wait bool
}
type SyncOpt interface{ Apply(*SyncOpts) }
@ -876,6 +881,7 @@ type ChartPrepareOptions struct {
SkipRepos bool
SkipDeps bool
SkipResolve bool
Wait bool
}
type chartPrepareResult struct {