From ae942c5288895c84c79171e5446773e4cb41c4ce Mon Sep 17 00:00:00 2001 From: Yusuke Kuoka Date: Tue, 13 Apr 2021 09:09:58 +0900 Subject: [PATCH] Fix --skip-crds not working with chartify (#1774) Follow-up for #1771 Ref #1770 Ref https://github.com/roboll/helmfile/pull/1771#issuecomment-817399338 --- pkg/app/app.go | 13 +++++++++++-- pkg/app/config.go | 1 + pkg/app/diff_test.go | 14 ++++++++++---- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/pkg/app/app.go b/pkg/app/app.go index 1012e140..61207796 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -166,9 +166,12 @@ func (a *App) Diff(c DiffConfigProvider) error { var errs []error + includeCRDs := !c.SkipCRDs() + prepErr := run.withPreparedCharts("diff", state.ChartPrepareOptions{ - SkipRepos: c.SkipDeps(), - SkipDeps: c.SkipDeps(), + SkipRepos: c.SkipDeps(), + SkipDeps: c.SkipDeps(), + IncludeCRDs: &includeCRDs, }, func() { msg, matched, affected, errs = a.diff(run, c) }) @@ -305,11 +308,14 @@ func (a *App) Fetch(c FetchConfigProvider) error { func (a *App) Sync(c SyncConfigProvider) error { return a.ForEachState(func(run *Run) (ok bool, errs []error) { + includeCRDs := !c.SkipCRDs() + prepErr := run.withPreparedCharts("sync", state.ChartPrepareOptions{ SkipRepos: c.SkipDeps(), SkipDeps: c.SkipDeps(), Wait: c.Wait(), WaitForJobs: c.WaitForJobs(), + IncludeCRDs: &includeCRDs, }, func() { ok, errs = a.sync(run, c) }) @@ -332,11 +338,14 @@ func (a *App) Apply(c ApplyConfigProvider) error { opts = append(opts, SetRetainValuesFiles(c.RetainValuesFiles() || c.SkipCleanup())) err := a.ForEachState(func(run *Run) (ok bool, errs []error) { + includeCRDs := !c.SkipCRDs() + prepErr := run.withPreparedCharts("apply", state.ChartPrepareOptions{ SkipRepos: c.SkipDeps(), SkipDeps: c.SkipDeps(), Wait: c.Wait(), WaitForJobs: c.WaitForJobs(), + IncludeCRDs: &includeCRDs, }, func() { matched, updated, es := a.apply(run, c) diff --git a/pkg/app/config.go b/pkg/app/config.go index 4517588c..c22574fd 100644 --- a/pkg/app/config.go +++ b/pkg/app/config.go @@ -83,6 +83,7 @@ type DiffConfigProvider interface { Values() []string Set() []string + SkipCRDs() bool SkipDeps() bool IncludeTests() bool diff --git a/pkg/app/diff_test.go b/pkg/app/diff_test.go index 90eade16..5008dea1 100644 --- a/pkg/app/diff_test.go +++ b/pkg/app/diff_test.go @@ -3,15 +3,16 @@ package app import ( "bufio" "bytes" + "io" + "path/filepath" + "sync" + "testing" + "github.com/roboll/helmfile/pkg/exectest" "github.com/roboll/helmfile/pkg/helmexec" "github.com/roboll/helmfile/pkg/testhelper" "github.com/variantdev/vals" "go.uber.org/zap" - "io" - "path/filepath" - "sync" - "testing" ) type diffConfig struct { @@ -20,6 +21,7 @@ type diffConfig struct { retainValuesFiles bool set []string validate bool + skipCRDs bool skipDeps bool includeTests bool suppressSecrets bool @@ -49,6 +51,10 @@ func (a diffConfig) Validate() bool { return a.validate } +func (a diffConfig) SkipCRDs() bool { + return a.skipCRDs +} + func (a diffConfig) SkipDeps() bool { return a.skipDeps }