Skip to content

Commit

Permalink
Add --skip-crds to helmfile sync and helmfile apply (#1771)
Browse files Browse the repository at this point in the history
Resolves #1770
  • Loading branch information
mumoshu authored Apr 11, 2021
1 parent 589b26a commit a111e89
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
12 changes: 12 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,10 @@ func main() {
Value: "",
Usage: "pass args to helm exec",
},
cli.BoolFlag{
Name: "skip-crds",
Usage: "if set, no CRDs will be installed on sync. By default, CRDs are installed if not already present",
},
cli.BoolFlag{
Name: "skip-deps",
Usage: `skip running "helm repo update" and "helm dependency build"`,
Expand Down Expand Up @@ -434,6 +438,10 @@ func main() {
Name: "skip-cleanup",
Usage: "Stop cleaning up temporary values generated by helmfile and helm-secrets. Useful for debugging. Don't use in production for security",
},
cli.BoolFlag{
Name: "skip-crds",
Usage: "if set, no CRDs will be installed on sync. By default, CRDs are installed if not already present",
},
cli.BoolFlag{
Name: "skip-diff-on-install",
Usage: "Skips running helm-diff on releases being newly installed on this apply. Useful when the release manifests are too huge to be reviewed, or it's too time-consuming to diff at all",
Expand Down Expand Up @@ -815,6 +823,10 @@ func (c configImpl) SkipCleanup() bool {
return c.c.Bool("skip-cleanup")
}

func (c configImpl) SkipCRDs() bool {
return c.c.Bool("skip-crds")
}

func (c configImpl) SkipDiffOnInstall() bool {
return c.c.Bool("skip-diff-on-install")
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,7 @@ Do you really want to apply?
syncOpts := state.SyncOpts{
Set: c.Set(),
SkipCleanup: c.RetainValuesFiles() || c.SkipCleanup(),
SkipCRDs: c.SkipCRDs(),
Wait: c.Wait(),
WaitForJobs: c.WaitForJobs(),
}
Expand Down Expand Up @@ -1595,6 +1596,7 @@ func (a *App) sync(r *Run, c SyncConfigProvider) (bool, []error) {

opts := &state.SyncOpts{
Set: c.Set(),
SkipCRDs: c.SkipCRDs(),
Wait: c.Wait(),
WaitForJobs: c.WaitForJobs(),
}
Expand Down
10 changes: 10 additions & 0 deletions pkg/app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2243,6 +2243,7 @@ type configImpl struct {
output string
includeCRDs bool
skipCleanup bool
skipCRDs bool
skipDeps bool
}

Expand Down Expand Up @@ -2270,6 +2271,10 @@ func (c configImpl) SkipCleanup() bool {
return c.skipCleanup
}

func (c configImpl) SkipCRDs() bool {
return c.skipCRDs
}

func (c configImpl) SkipDeps() bool {
return c.skipDeps
}
Expand Down Expand Up @@ -2305,6 +2310,7 @@ type applyConfig struct {
set []string
validate bool
skipCleanup bool
skipCRDs bool
skipDeps bool
includeTests bool
suppressSecrets bool
Expand Down Expand Up @@ -2349,6 +2355,10 @@ func (a applyConfig) SkipCleanup() bool {
return a.skipCleanup
}

func (a applyConfig) SkipCRDs() bool {
return a.skipCRDs
}

func (a applyConfig) SkipDeps() bool {
return a.skipDeps
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type ApplyConfigProvider interface {

Values() []string
Set() []string
SkipCRDs() bool
SkipDeps() bool
Wait() bool
WaitForJobs() bool
Expand Down Expand Up @@ -68,6 +69,7 @@ type SyncConfigProvider interface {

Values() []string
Set() []string
SkipCRDs() bool
SkipDeps() bool
Wait() bool
WaitForJobs() bool
Expand Down
5 changes: 5 additions & 0 deletions pkg/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,10 @@ func (st *HelmState) prepareSyncReleases(helm helmexec.Interface, additionalValu
}
}

if opts.SkipCRDs {
flags = append(flags, "--skip-crds")
}

if opts.Wait {
flags = append(flags, "--wait")
}
Expand Down Expand Up @@ -595,6 +599,7 @@ func (st *HelmState) DetectReleasesToBeDeleted(helm helmexec.Interface, releases
type SyncOpts struct {
Set []string
SkipCleanup bool
SkipCRDs bool
Wait bool
WaitForJobs bool
}
Expand Down

0 comments on commit a111e89

Please sign in to comment.