Fix --skip-crds not working with chartify (#1774)

Follow-up for #1771
Ref #1770
Ref https://github.com/roboll/helmfile/pull/1771#issuecomment-817399338
This commit is contained in:
Yusuke Kuoka 2021-04-13 09:09:58 +09:00 committed by GitHub
parent a111e89b27
commit ae942c5288
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 6 deletions

View File

@ -166,9 +166,12 @@ func (a *App) Diff(c DiffConfigProvider) error {
var errs []error var errs []error
includeCRDs := !c.SkipCRDs()
prepErr := run.withPreparedCharts("diff", state.ChartPrepareOptions{ prepErr := run.withPreparedCharts("diff", state.ChartPrepareOptions{
SkipRepos: c.SkipDeps(), SkipRepos: c.SkipDeps(),
SkipDeps: c.SkipDeps(), SkipDeps: c.SkipDeps(),
IncludeCRDs: &includeCRDs,
}, func() { }, func() {
msg, matched, affected, errs = a.diff(run, c) 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 { 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) {
includeCRDs := !c.SkipCRDs()
prepErr := run.withPreparedCharts("sync", state.ChartPrepareOptions{ prepErr := run.withPreparedCharts("sync", state.ChartPrepareOptions{
SkipRepos: c.SkipDeps(), SkipRepos: c.SkipDeps(),
SkipDeps: c.SkipDeps(), SkipDeps: c.SkipDeps(),
Wait: c.Wait(), Wait: c.Wait(),
WaitForJobs: c.WaitForJobs(), WaitForJobs: c.WaitForJobs(),
IncludeCRDs: &includeCRDs,
}, func() { }, func() {
ok, errs = a.sync(run, c) 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())) opts = append(opts, SetRetainValuesFiles(c.RetainValuesFiles() || c.SkipCleanup()))
err := a.ForEachState(func(run *Run) (ok bool, errs []error) { err := a.ForEachState(func(run *Run) (ok bool, errs []error) {
includeCRDs := !c.SkipCRDs()
prepErr := run.withPreparedCharts("apply", state.ChartPrepareOptions{ prepErr := run.withPreparedCharts("apply", state.ChartPrepareOptions{
SkipRepos: c.SkipDeps(), SkipRepos: c.SkipDeps(),
SkipDeps: c.SkipDeps(), SkipDeps: c.SkipDeps(),
Wait: c.Wait(), Wait: c.Wait(),
WaitForJobs: c.WaitForJobs(), WaitForJobs: c.WaitForJobs(),
IncludeCRDs: &includeCRDs,
}, func() { }, func() {
matched, updated, es := a.apply(run, c) matched, updated, es := a.apply(run, c)

View File

@ -83,6 +83,7 @@ type DiffConfigProvider interface {
Values() []string Values() []string
Set() []string Set() []string
SkipCRDs() bool
SkipDeps() bool SkipDeps() bool
IncludeTests() bool IncludeTests() bool

View File

@ -3,15 +3,16 @@ package app
import ( import (
"bufio" "bufio"
"bytes" "bytes"
"io"
"path/filepath"
"sync"
"testing"
"github.com/roboll/helmfile/pkg/exectest" "github.com/roboll/helmfile/pkg/exectest"
"github.com/roboll/helmfile/pkg/helmexec" "github.com/roboll/helmfile/pkg/helmexec"
"github.com/roboll/helmfile/pkg/testhelper" "github.com/roboll/helmfile/pkg/testhelper"
"github.com/variantdev/vals" "github.com/variantdev/vals"
"go.uber.org/zap" "go.uber.org/zap"
"io"
"path/filepath"
"sync"
"testing"
) )
type diffConfig struct { type diffConfig struct {
@ -20,6 +21,7 @@ type diffConfig struct {
retainValuesFiles bool retainValuesFiles bool
set []string set []string
validate bool validate bool
skipCRDs bool
skipDeps bool skipDeps bool
includeTests bool includeTests bool
suppressSecrets bool suppressSecrets bool
@ -49,6 +51,10 @@ func (a diffConfig) Validate() bool {
return a.validate return a.validate
} }
func (a diffConfig) SkipCRDs() bool {
return a.skipCRDs
}
func (a diffConfig) SkipDeps() bool { func (a diffConfig) SkipDeps() bool {
return a.skipDeps return a.skipDeps
} }