parent
3284df2752
commit
eff2a7bf84
|
|
@ -101,13 +101,11 @@ func Init(app *App) *App {
|
||||||
|
|
||||||
func (a *App) Deps(c DepsConfigProvider) error {
|
func (a *App) Deps(c DepsConfigProvider) error {
|
||||||
return a.ForEachStateFiltered(func(run *Run) (errs []error) {
|
return a.ForEachStateFiltered(func(run *Run) (errs []error) {
|
||||||
err := run.withPreparedCharts(false, func() {
|
prepErrs := run.withReposAndPreparedCharts(false, c.SkipRepos(), func() {
|
||||||
errs = run.Deps(c)
|
errs = run.Deps(c)
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
errs = append(errs, prepErrs...)
|
||||||
errs = append(errs, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
return
|
||||||
})
|
})
|
||||||
|
|
@ -155,7 +153,7 @@ func (a *App) Diff(c DiffConfigProvider) error {
|
||||||
|
|
||||||
var errs []error
|
var errs []error
|
||||||
|
|
||||||
err := run.withPreparedCharts(false, func() {
|
prepErrs := run.withReposAndPreparedCharts(false, c.SkipDeps(), func() {
|
||||||
msg, matched, affected, errs = run.Diff(c)
|
msg, matched, affected, errs = run.Diff(c)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -163,9 +161,7 @@ func (a *App) Diff(c DiffConfigProvider) error {
|
||||||
a.Logger.Info(*msg)
|
a.Logger.Info(*msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
errs = append(errs, prepErrs...)
|
||||||
errs = append(errs, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
affectedAny = affectedAny || affected
|
affectedAny = affectedAny || affected
|
||||||
|
|
||||||
|
|
@ -208,13 +204,11 @@ func (a *App) Diff(c DiffConfigProvider) error {
|
||||||
|
|
||||||
func (a *App) Template(c TemplateConfigProvider) error {
|
func (a *App) Template(c TemplateConfigProvider) error {
|
||||||
return a.ForEachState(func(run *Run) (ok bool, errs []error) {
|
return a.ForEachState(func(run *Run) (ok bool, errs []error) {
|
||||||
err := run.withPreparedCharts(true, func() {
|
prepErrs := run.withReposAndPreparedCharts(true, c.SkipDeps(), func() {
|
||||||
ok, errs = a.template(run, c)
|
ok, errs = a.template(run, c)
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
errs = append(errs, prepErrs...)
|
||||||
errs = append(errs, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
return
|
||||||
})
|
})
|
||||||
|
|
@ -222,13 +216,11 @@ func (a *App) Template(c TemplateConfigProvider) error {
|
||||||
|
|
||||||
func (a *App) Lint(c LintConfigProvider) error {
|
func (a *App) Lint(c LintConfigProvider) error {
|
||||||
return a.ForEachStateFiltered(func(run *Run) (errs []error) {
|
return a.ForEachStateFiltered(func(run *Run) (errs []error) {
|
||||||
err := run.withPreparedCharts(true, func() {
|
prepErrs := run.withReposAndPreparedCharts(true, c.SkipDeps(), func() {
|
||||||
errs = run.Lint(c)
|
errs = run.Lint(c)
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
errs = append(errs, prepErrs...)
|
||||||
errs = append(errs, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
return
|
||||||
})
|
})
|
||||||
|
|
@ -236,13 +228,11 @@ func (a *App) Lint(c LintConfigProvider) error {
|
||||||
|
|
||||||
func (a *App) Sync(c SyncConfigProvider) error {
|
func (a *App) Sync(c SyncConfigProvider) error {
|
||||||
return a.ForEachState(func(run *Run) (ok bool, errs []error) {
|
return a.ForEachState(func(run *Run) (ok bool, errs []error) {
|
||||||
err := run.withPreparedCharts(false, func() {
|
prepErrs := run.withReposAndPreparedCharts(false, c.SkipDeps(), func() {
|
||||||
ok, errs = a.sync(run, c)
|
ok, errs = a.sync(run, c)
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
errs = append(errs, prepErrs...)
|
||||||
errs = append(errs, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
return
|
||||||
})
|
})
|
||||||
|
|
@ -258,7 +248,7 @@ func (a *App) Apply(c ApplyConfigProvider) error {
|
||||||
opts = append(opts, SetRetainValuesFiles(c.RetainValuesFiles()))
|
opts = append(opts, SetRetainValuesFiles(c.RetainValuesFiles()))
|
||||||
|
|
||||||
err := a.ForEachState(func(run *Run) (ok bool, errs []error) {
|
err := a.ForEachState(func(run *Run) (ok bool, errs []error) {
|
||||||
err := run.withPreparedCharts(false, func() {
|
prepErrs := run.withReposAndPreparedCharts(false, c.SkipDeps(), func() {
|
||||||
matched, updated, es := a.apply(run, c)
|
matched, updated, es := a.apply(run, c)
|
||||||
|
|
||||||
mut.Lock()
|
mut.Lock()
|
||||||
|
|
@ -268,9 +258,7 @@ func (a *App) Apply(c ApplyConfigProvider) error {
|
||||||
ok, errs = matched, es
|
ok, errs = matched, es
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
errs = append(errs, prepErrs...)
|
||||||
errs = append(errs, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}, opts...)
|
}, opts...)
|
||||||
|
|
@ -935,7 +923,6 @@ func (a *App) findDesiredStateFiles(specifiedPath string, opts LoadOpts) ([]stri
|
||||||
func (a *App) apply(r *Run, c ApplyConfigProvider) (bool, bool, []error) {
|
func (a *App) apply(r *Run, c ApplyConfigProvider) (bool, bool, []error) {
|
||||||
st := r.state
|
st := r.state
|
||||||
helm := r.helm
|
helm := r.helm
|
||||||
ctx := r.ctx
|
|
||||||
|
|
||||||
allReleases := st.GetReleasesWithOverrides()
|
allReleases := st.GetReleasesWithOverrides()
|
||||||
|
|
||||||
|
|
@ -952,9 +939,6 @@ func (a *App) apply(r *Run, c ApplyConfigProvider) (bool, bool, []error) {
|
||||||
st.Releases = toApply
|
st.Releases = toApply
|
||||||
|
|
||||||
if !c.SkipDeps() {
|
if !c.SkipDeps() {
|
||||||
if errs := ctx.SyncReposOnce(st, helm); errs != nil && len(errs) > 0 {
|
|
||||||
return false, false, errs
|
|
||||||
}
|
|
||||||
if errs := st.BuildDeps(helm); errs != nil && len(errs) > 0 {
|
if errs := st.BuildDeps(helm); errs != nil && len(errs) > 0 {
|
||||||
return false, false, errs
|
return false, false, errs
|
||||||
}
|
}
|
||||||
|
|
@ -1126,7 +1110,6 @@ Do you really want to delete?
|
||||||
func (a *App) sync(r *Run, c SyncConfigProvider) (bool, []error) {
|
func (a *App) sync(r *Run, c SyncConfigProvider) (bool, []error) {
|
||||||
st := r.state
|
st := r.state
|
||||||
helm := r.helm
|
helm := r.helm
|
||||||
ctx := r.ctx
|
|
||||||
|
|
||||||
allReleases := st.GetReleasesWithOverrides()
|
allReleases := st.GetReleasesWithOverrides()
|
||||||
|
|
||||||
|
|
@ -1143,9 +1126,6 @@ func (a *App) sync(r *Run, c SyncConfigProvider) (bool, []error) {
|
||||||
st.Releases = toSync
|
st.Releases = toSync
|
||||||
|
|
||||||
if !c.SkipDeps() {
|
if !c.SkipDeps() {
|
||||||
if errs := ctx.SyncReposOnce(st, helm); errs != nil && len(errs) > 0 {
|
|
||||||
return false, errs
|
|
||||||
}
|
|
||||||
if errs := st.BuildDeps(helm); errs != nil && len(errs) > 0 {
|
if errs := st.BuildDeps(helm); errs != nil && len(errs) > 0 {
|
||||||
return false, errs
|
return false, errs
|
||||||
}
|
}
|
||||||
|
|
@ -1252,7 +1232,6 @@ func (a *App) sync(r *Run, c SyncConfigProvider) (bool, []error) {
|
||||||
func (a *App) template(r *Run, c TemplateConfigProvider) (bool, []error) {
|
func (a *App) template(r *Run, c TemplateConfigProvider) (bool, []error) {
|
||||||
st := r.state
|
st := r.state
|
||||||
helm := r.helm
|
helm := r.helm
|
||||||
ctx := r.ctx
|
|
||||||
|
|
||||||
allReleases := st.GetReleasesWithOverrides()
|
allReleases := st.GetReleasesWithOverrides()
|
||||||
|
|
||||||
|
|
@ -1269,9 +1248,6 @@ func (a *App) template(r *Run, c TemplateConfigProvider) (bool, []error) {
|
||||||
st.Releases = toRender
|
st.Releases = toRender
|
||||||
|
|
||||||
if !c.SkipDeps() {
|
if !c.SkipDeps() {
|
||||||
if errs := ctx.SyncReposOnce(st, helm); errs != nil && len(errs) > 0 {
|
|
||||||
return false, errs
|
|
||||||
}
|
|
||||||
if errs := st.BuildDeps(helm); errs != nil && len(errs) > 0 {
|
if errs := st.BuildDeps(helm); errs != nil && len(errs) > 0 {
|
||||||
return false, errs
|
return false, errs
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,21 @@ func (r *Run) askForConfirmation(msg string) bool {
|
||||||
return AskForConfirmation(msg)
|
return AskForConfirmation(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *Run) withReposAndPreparedCharts(forceDownload bool, skipRepos bool, f func()) []error {
|
||||||
|
if !skipRepos {
|
||||||
|
ctx := r.ctx
|
||||||
|
if errs := ctx.SyncReposOnce(r.state, r.helm); errs != nil && len(errs) > 0 {
|
||||||
|
return errs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := r.withPreparedCharts(forceDownload, f); err != nil {
|
||||||
|
return []error{err}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (r *Run) withPreparedCharts(forceDownload bool, f func()) error {
|
func (r *Run) withPreparedCharts(forceDownload bool, f func()) error {
|
||||||
if r.ReleaseToChart != nil {
|
if r.ReleaseToChart != nil {
|
||||||
panic("Run.PrepareCharts can be called only once")
|
panic("Run.PrepareCharts can be called only once")
|
||||||
|
|
@ -66,12 +81,6 @@ func (r *Run) withPreparedCharts(forceDownload bool, f func()) error {
|
||||||
func (r *Run) Deps(c DepsConfigProvider) []error {
|
func (r *Run) Deps(c DepsConfigProvider) []error {
|
||||||
r.helm.SetExtraArgs(argparser.GetArgs(c.Args(), r.state)...)
|
r.helm.SetExtraArgs(argparser.GetArgs(c.Args(), r.state)...)
|
||||||
|
|
||||||
if !c.SkipRepos() {
|
|
||||||
if errs := r.ctx.SyncReposOnce(r.state, r.helm); errs != nil && len(errs) > 0 {
|
|
||||||
return errs
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return r.state.UpdateDeps(r.helm)
|
return r.state.UpdateDeps(r.helm)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -102,7 +111,6 @@ func (r *Run) Status(c StatusesConfigProvider) []error {
|
||||||
func (r *Run) Diff(c DiffConfigProvider) (*string, bool, bool, []error) {
|
func (r *Run) Diff(c DiffConfigProvider) (*string, bool, bool, []error) {
|
||||||
st := r.state
|
st := r.state
|
||||||
helm := r.helm
|
helm := r.helm
|
||||||
ctx := r.ctx
|
|
||||||
|
|
||||||
allReleases := st.GetReleasesWithOverrides()
|
allReleases := st.GetReleasesWithOverrides()
|
||||||
|
|
||||||
|
|
@ -120,9 +128,6 @@ func (r *Run) Diff(c DiffConfigProvider) (*string, bool, bool, []error) {
|
||||||
st.Releases = toDiff
|
st.Releases = toDiff
|
||||||
|
|
||||||
if !c.SkipDeps() {
|
if !c.SkipDeps() {
|
||||||
if errs := ctx.SyncReposOnce(st, helm); errs != nil && len(errs) > 0 {
|
|
||||||
return nil, false, false, errs
|
|
||||||
}
|
|
||||||
if errs := st.BuildDeps(helm); errs != nil && len(errs) > 0 {
|
if errs := st.BuildDeps(helm); errs != nil && len(errs) > 0 {
|
||||||
return nil, false, false, errs
|
return nil, false, false, errs
|
||||||
}
|
}
|
||||||
|
|
@ -175,15 +180,11 @@ func (r *Run) Test(c TestConfigProvider) []error {
|
||||||
func (r *Run) Lint(c LintConfigProvider) []error {
|
func (r *Run) Lint(c LintConfigProvider) []error {
|
||||||
st := r.state
|
st := r.state
|
||||||
helm := r.helm
|
helm := r.helm
|
||||||
ctx := r.ctx
|
|
||||||
|
|
||||||
values := c.Values()
|
values := c.Values()
|
||||||
args := argparser.GetArgs(c.Args(), st)
|
args := argparser.GetArgs(c.Args(), st)
|
||||||
workers := c.Concurrency()
|
workers := c.Concurrency()
|
||||||
if !c.SkipDeps() {
|
if !c.SkipDeps() {
|
||||||
if errs := ctx.SyncReposOnce(st, helm); errs != nil && len(errs) > 0 {
|
|
||||||
return errs
|
|
||||||
}
|
|
||||||
if errs := st.BuildDeps(helm); errs != nil && len(errs) > 0 {
|
if errs := st.BuildDeps(helm); errs != nil && len(errs) > 0 {
|
||||||
return errs
|
return errs
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue