From 45283bfcdeee57b1e9b4555245e0b1ab24e9dd03 Mon Sep 17 00:00:00 2001 From: yxxhero Date: Fri, 10 Jun 2022 12:42:31 +0800 Subject: [PATCH] move all subcommand to sigle file Signed-off-by: yxxhero --- cmd/apply.go | 115 ++++++++++++ cmd/build.go | 23 +++ cmd/cache.go | 35 ++++ cmd/delete.go | 37 ++++ cmd/destroy.go | 33 ++++ cmd/fetch.go | 32 ++++ cmd/lint.go | 41 +++++ cmd/list.go | 28 +++ cmd/root.go | 13 ++ cmd/status.go | 29 +++ cmd/sync.go | 69 ++++++++ cmd/test.go | 46 +++++ cmd/version.go | 17 ++ cmd/write-values.go | 40 +++++ main.go | 420 -------------------------------------------- 15 files changed, 558 insertions(+), 420 deletions(-) create mode 100644 cmd/apply.go create mode 100644 cmd/build.go create mode 100644 cmd/cache.go create mode 100644 cmd/delete.go create mode 100644 cmd/destroy.go create mode 100644 cmd/fetch.go create mode 100644 cmd/lint.go create mode 100644 cmd/list.go create mode 100644 cmd/status.go create mode 100644 cmd/sync.go create mode 100644 cmd/test.go create mode 100644 cmd/version.go create mode 100644 cmd/write-values.go diff --git a/cmd/apply.go b/cmd/apply.go new file mode 100644 index 00000000..273f0db7 --- /dev/null +++ b/cmd/apply.go @@ -0,0 +1,115 @@ +package cmd + +import ( + "github.com/helmfile/helmfile/pkg/app" + "github.com/helmfile/helmfile/pkg/config" + "github.com/urfave/cli" +) + +func addApplySubcommand(cliApp *cli.App) { + cliApp.Commands = append(cliApp.Commands, cli.Command{ + Name: "apply", + Usage: "apply all resources from state file only when there are changes", + Flags: []cli.Flag{ + cli.StringSliceFlag{ + Name: "set", + Usage: "additional values to be merged into the command", + }, + cli.StringSliceFlag{ + Name: "values", + Usage: "additional value files to be merged into the command", + }, + cli.IntFlag{ + Name: "concurrency", + Value: 0, + Usage: "maximum number of concurrent helm processes to run, 0 is unlimited", + }, + cli.BoolFlag{ + Name: "validate", + Usage: "validate your manifests against the Kubernetes cluster you are currently pointing at. Note that this requiers access to a Kubernetes cluster to obtain information necessary for validating, like the list of available API versions", + }, + cli.IntFlag{ + Name: "context", + Value: 0, + Usage: "output NUM lines of context around changes", + }, + cli.StringFlag{ + Name: "output", + Value: "", + Usage: "output format for diff plugin", + }, + cli.BoolFlag{ + Name: "detailed-exitcode", + Usage: "return a non-zero exit code 2 instead of 0 when there were changes detected AND the changes are synced successfully", + }, + cli.StringFlag{ + Name: "args", + Value: "", + Usage: "pass args to helm exec", + }, + cli.BoolFlag{ + Name: "retain-values-files", + Usage: "DEPRECATED: Use skip-cleanup instead", + }, + cli.BoolFlag{ + 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.BoolTFlag{ + Name: "skip-needs", + Usage: `do not automatically include releases from the target release's "needs" when --selector/-l flag is provided. Does nothing when when --selector/-l flag is not provided. Defaults to true when --include-needs or --include-transitive-needs is not provided`, + }, + cli.BoolFlag{ + Name: "include-needs", + Usage: `automatically include releases from the target release's "needs" when --selector/-l flag is provided. Does nothing when when --selector/-l flag is not provided`, + }, + cli.BoolFlag{ + Name: "include-transitive-needs", + Usage: `like --include-needs, but also includes transitive needs (needs of needs). Does nothing when when --selector/-l flag is not provided. Overrides exclusions of other selectors and conditions.`, + }, + 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", + }, + cli.BoolFlag{ + Name: "include-tests", + Usage: "enable the diffing of the helm test hooks", + }, + cli.StringSliceFlag{ + Name: "suppress", + Usage: "suppress specified Kubernetes objects in the diff output. Can be provided multiple times. For example: --suppress KeycloakClient --suppress VaultSecret", + }, + cli.BoolFlag{ + Name: "suppress-secrets", + Usage: "suppress secrets in the diff output. highly recommended to specify on CI/CD use-cases", + }, + cli.BoolFlag{ + Name: "show-secrets", + Usage: "do not redact secret values in the diff output. should be used for debug purpose only", + }, + cli.BoolFlag{ + Name: "suppress-diff", + Usage: "suppress diff in the output. Usable in new installs", + }, + cli.BoolFlag{ + 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"`, + }, + cli.BoolFlag{ + Name: "wait-for-jobs", + Usage: `Override helmDefaults.waitForJobs setting "helm upgrade --install --wait-for-jobs"`, + }, + }, + Action: Action(func(a *app.App, c config.ConfigImpl) error { + return a.Apply(c) + }), + }) +} diff --git a/cmd/build.go b/cmd/build.go new file mode 100644 index 00000000..58f73498 --- /dev/null +++ b/cmd/build.go @@ -0,0 +1,23 @@ +package cmd + +import ( + "github.com/helmfile/helmfile/pkg/app" + "github.com/helmfile/helmfile/pkg/config" + "github.com/urfave/cli" +) + +func addBuildSubcommand(cliApp *cli.App) { + cliApp.Commands = append(cliApp.Commands, cli.Command{ + Name: "build", + Usage: "output compiled helmfile state(s) as YAML", + Flags: []cli.Flag{ + cli.BoolFlag{ + Name: "embed-values", + Usage: "Read all the values files for every release and embed into the output helmfile.yaml", + }, + }, + Action: Action(func(a *app.App, c config.ConfigImpl) error { + return a.PrintState(c) + }), + }) +} diff --git a/cmd/cache.go b/cmd/cache.go new file mode 100644 index 00000000..7cefb813 --- /dev/null +++ b/cmd/cache.go @@ -0,0 +1,35 @@ +package cmd + +import ( + "github.com/helmfile/helmfile/pkg/app" + "github.com/helmfile/helmfile/pkg/config" + "github.com/urfave/cli" +) + +var cacheInfoSubcommand = cli.Command{ + Name: "info", + Usage: "cache info", + Action: Action(func(a *app.App, c config.ConfigImpl) error { + return a.ShowCacheDir(c) + }), +} + +var cacheCleanupSubcommand = cli.Command{ + Name: "cleanup", + Usage: "clean up cache directory", + Action: Action(func(a *app.App, c config.ConfigImpl) error { + return a.CleanCacheDir(c) + }), +} + +func addCacheSubcommand(cliApp *cli.App) { + cliApp.Commands = append(cliApp.Commands, cli.Command{ + Name: "cache", + Usage: "cache management", + ArgsUsage: "[command]", + Subcommands: []cli.Command{ + cacheCleanupSubcommand, + cacheInfoSubcommand, + }, + }) +} diff --git a/cmd/delete.go b/cmd/delete.go new file mode 100644 index 00000000..96c9ad46 --- /dev/null +++ b/cmd/delete.go @@ -0,0 +1,37 @@ +package cmd + +import ( + "github.com/helmfile/helmfile/pkg/app" + "github.com/helmfile/helmfile/pkg/config" + "github.com/urfave/cli" +) + +func addDeleteSubcommand(cliApp *cli.App) { + cliApp.Commands = append(cliApp.Commands, cli.Command{ + Name: "delete", + Usage: "DEPRECATED: delete releases from state file (helm delete)", + Flags: []cli.Flag{ + cli.IntFlag{ + Name: "concurrency", + Value: 0, + Usage: "maximum number of concurrent helm processes to run, 0 is unlimited", + }, + cli.StringFlag{ + Name: "args", + Value: "", + Usage: "pass args to helm exec", + }, + cli.BoolFlag{ + Name: "purge", + Usage: "purge releases i.e. free release names and histories", + }, + cli.BoolFlag{ + Name: "skip-deps", + Usage: `skip running "helm repo update" and "helm dependency build"`, + }, + }, + Action: Action(func(a *app.App, c config.ConfigImpl) error { + return a.Delete(c) + }), + }) +} diff --git a/cmd/destroy.go b/cmd/destroy.go new file mode 100644 index 00000000..04f13c82 --- /dev/null +++ b/cmd/destroy.go @@ -0,0 +1,33 @@ +package cmd + +import ( + "github.com/helmfile/helmfile/pkg/app" + "github.com/helmfile/helmfile/pkg/config" + "github.com/urfave/cli" +) + +func addDestroySubcommand(cliApp *cli.App) { + cliApp.Commands = append(cliApp.Commands, cli.Command{ + Name: "destroy", + Usage: "deletes and then purges releases", + Flags: []cli.Flag{ + cli.IntFlag{ + Name: "concurrency", + Value: 0, + Usage: "maximum number of concurrent helm processes to run, 0 is unlimited", + }, + cli.StringFlag{ + Name: "args", + Value: "", + Usage: "pass args to helm exec", + }, + cli.BoolFlag{ + Name: "skip-deps", + Usage: `skip running "helm repo update" and "helm dependency build"`, + }, + }, + Action: Action(func(a *app.App, c config.ConfigImpl) error { + return a.Destroy(c) + }), + }) +} diff --git a/cmd/fetch.go b/cmd/fetch.go new file mode 100644 index 00000000..f6c6b802 --- /dev/null +++ b/cmd/fetch.go @@ -0,0 +1,32 @@ +package cmd + +import ( + "github.com/helmfile/helmfile/pkg/app" + "github.com/helmfile/helmfile/pkg/config" + "github.com/urfave/cli" +) + +func addFetchSubcommand(cliApp *cli.App) { + cliApp.Commands = append(cliApp.Commands, cli.Command{ + Name: "fetch", + Usage: "fetch charts from state file", + Flags: []cli.Flag{ + cli.IntFlag{ + Name: "concurrency", + Value: 0, + Usage: "maximum number of concurrent downloads of release charts", + }, + cli.BoolFlag{ + Name: "skip-deps", + Usage: `skip running "helm repo update" and "helm dependency build"`, + }, + cli.StringFlag{ + Name: "output-dir", + Usage: "directory to store charts (default: temporary directory which is deleted when the command terminates)", + }, + }, + Action: Action(func(a *app.App, c config.ConfigImpl) error { + return a.Fetch(c) + }), + }) +} diff --git a/cmd/lint.go b/cmd/lint.go new file mode 100644 index 00000000..1185d4cd --- /dev/null +++ b/cmd/lint.go @@ -0,0 +1,41 @@ +package cmd + +import ( + "github.com/helmfile/helmfile/pkg/app" + "github.com/helmfile/helmfile/pkg/config" + "github.com/urfave/cli" +) + +func addLintSubcommand(cliApp *cli.App) { + cliApp.Commands = append(cliApp.Commands, cli.Command{ + Name: "lint", + Usage: "lint charts from state file (helm lint)", + Flags: []cli.Flag{ + cli.StringFlag{ + Name: "args", + Value: "", + Usage: "pass args to helm exec", + }, + cli.StringSliceFlag{ + Name: "set", + Usage: "additional values to be merged into the command", + }, + cli.StringSliceFlag{ + Name: "values", + Usage: "additional value files to be merged into the command", + }, + cli.IntFlag{ + Name: "concurrency", + Value: 0, + Usage: "maximum number of concurrent downloads of release charts", + }, + cli.BoolFlag{ + Name: "skip-deps", + Usage: `skip running "helm repo update" and "helm dependency build"`, + }, + }, + Action: Action(func(a *app.App, c config.ConfigImpl) error { + return a.Lint(c) + }), + }) +} diff --git a/cmd/list.go b/cmd/list.go new file mode 100644 index 00000000..81735cbd --- /dev/null +++ b/cmd/list.go @@ -0,0 +1,28 @@ +package cmd + +import ( + "github.com/helmfile/helmfile/pkg/app" + "github.com/helmfile/helmfile/pkg/config" + "github.com/urfave/cli" +) + +func addListSubcommand(cliApp *cli.App) { + cliApp.Commands = append(cliApp.Commands, cli.Command{ + Name: "list", + Usage: "list releases defined in state file", + Flags: []cli.Flag{ + cli.StringFlag{ + Name: "output", + Value: "", + Usage: "output releases list as a json string", + }, + cli.BoolFlag{ + Name: "keep-temp-dir", + Usage: "Keep temporary directory", + }, + }, + Action: Action(func(a *app.App, c config.ConfigImpl) error { + return a.ListReleases(c) + }), + }) +} diff --git a/cmd/root.go b/cmd/root.go index c8d4b7b7..a76edf4b 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -30,6 +30,19 @@ func RootCommand() *cli.App { addChartsSubcommand(cliApp) addDiffSubcommand(cliApp) addTemplateSubcommand(cliApp) + addWriteValuesSubcommand(cliApp) + addLintSubcommand(cliApp) + addFetchSubcommand(cliApp) + addSyncSubcommand(cliApp) + addApplySubcommand(cliApp) + addStatusSubcommand(cliApp) + addDeleteSubcommand(cliApp) + addDestroySubcommand(cliApp) + addTestSubcommand(cliApp) + addBuildSubcommand(cliApp) + addListSubcommand(cliApp) + addCacheSubcommand(cliApp) + addVersionSubcommand(cliApp) return cliApp } diff --git a/cmd/status.go b/cmd/status.go new file mode 100644 index 00000000..0a423fb1 --- /dev/null +++ b/cmd/status.go @@ -0,0 +1,29 @@ +package cmd + +import ( + "github.com/helmfile/helmfile/pkg/app" + "github.com/helmfile/helmfile/pkg/config" + "github.com/urfave/cli" +) + +func addStatusSubcommand(cliApp *cli.App) { + cliApp.Commands = append(cliApp.Commands, cli.Command{ + Name: "status", + Usage: "retrieve status of releases in state file", + Flags: []cli.Flag{ + cli.IntFlag{ + Name: "concurrency", + Value: 0, + Usage: "maximum number of concurrent helm processes to run, 0 is unlimited", + }, + cli.StringFlag{ + Name: "args", + Value: "", + Usage: "pass args to helm exec", + }, + }, + Action: Action(func(a *app.App, c config.ConfigImpl) error { + return a.Status(c) + }), + }) +} diff --git a/cmd/sync.go b/cmd/sync.go new file mode 100644 index 00000000..791cbff4 --- /dev/null +++ b/cmd/sync.go @@ -0,0 +1,69 @@ +package cmd + +import ( + "github.com/helmfile/helmfile/pkg/app" + "github.com/helmfile/helmfile/pkg/config" + "github.com/urfave/cli" +) + +func addSyncSubcommand(cliApp *cli.App) { + cliApp.Commands = append(cliApp.Commands, cli.Command{ + Name: "sync", + Usage: "sync all resources from state file (repos, releases and chart deps)", + Flags: []cli.Flag{ + cli.StringSliceFlag{ + Name: "set", + Usage: "additional values to be merged into the command", + }, + cli.StringSliceFlag{ + Name: "values", + Usage: "additional value files to be merged into the command", + }, + cli.IntFlag{ + Name: "concurrency", + Value: 0, + Usage: "maximum number of concurrent helm processes to run, 0 is unlimited", + }, + cli.StringFlag{ + Name: "args", + 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"`, + }, + cli.BoolTFlag{ + Name: "skip-needs", + Usage: `do not automatically include releases from the target release's "needs" when --selector/-l flag is provided. Does nothing when when --selector/-l flag is not provided. Defaults to true when --include-needs or --include-transitive-needs is not provided`, + }, + cli.BoolFlag{ + Name: "include-needs", + Usage: `automatically include releases from the target release's "needs" when --selector/-l flag is provided. Does nothing when when --selector/-l flag is not provided`, + }, + cli.BoolFlag{ + Name: "include-transitive-needs", + Usage: `like --include-needs, but also includes transitive needs (needs of needs). Does nothing when when --selector/-l flag is not provided. Overrides exclusions of other selectors and conditions.`, + }, + cli.BoolFlag{ + Name: "validate", + Usage: `ADVANCED CONFIGURATION: When sync is going to involve helm-template as a part of the "chartify" process, it might fail due to missing .Capabilities. This flag makes instructs helmfile to pass --validate to helm-template so it populates .Capabilities and validates your manifests against the Kubernetes cluster you are currently pointing at. Note that this requiers access to a Kubernetes cluster to obtain information necessary for validating, like the list of available API versions`, + }, + cli.BoolFlag{ + Name: "wait", + Usage: `Override helmDefaults.wait setting "helm upgrade --install --wait"`, + }, + cli.BoolFlag{ + Name: "wait-for-jobs", + Usage: `Override helmDefaults.waitForJobs setting "helm upgrade --install --wait-for-jobs"`, + }, + }, + Action: Action(func(a *app.App, c config.ConfigImpl) error { + return a.Sync(c) + }), + }) +} diff --git a/cmd/test.go b/cmd/test.go new file mode 100644 index 00000000..3c4119e6 --- /dev/null +++ b/cmd/test.go @@ -0,0 +1,46 @@ +package cmd + +import ( + "github.com/helmfile/helmfile/pkg/app" + "github.com/helmfile/helmfile/pkg/config" + "github.com/urfave/cli" +) + +func addTestSubcommand(cliApp *cli.App) { + cliApp.Commands = append(cliApp.Commands, cli.Command{ + Name: "test", + Usage: "test releases from state file (helm test)", + Flags: []cli.Flag{ + cli.BoolFlag{ + Name: "cleanup", + Usage: "delete test pods upon completion", + }, + cli.BoolFlag{ + Name: "logs", + Usage: "Dump the logs from test pods (this runs after all tests are complete, but before any cleanup)", + }, + cli.StringFlag{ + Name: "args", + Value: "", + Usage: "pass additional args to helm exec", + }, + cli.IntFlag{ + Name: "timeout", + Value: 300, + Usage: "maximum time for tests to run before being considered failed", + }, + cli.IntFlag{ + Name: "concurrency", + Value: 0, + Usage: "maximum number of concurrent helm processes to run, 0 is unlimited", + }, + cli.BoolFlag{ + Name: "skip-deps", + Usage: `skip running "helm repo update" and "helm dependency build"`, + }, + }, + Action: Action(func(a *app.App, c config.ConfigImpl) error { + return a.Test(c) + }), + }) +} diff --git a/cmd/version.go b/cmd/version.go new file mode 100644 index 00000000..0c55d847 --- /dev/null +++ b/cmd/version.go @@ -0,0 +1,17 @@ +package cmd + +import ( + "github.com/urfave/cli" +) + +func addVersionSubcommand(cliApp *cli.App) { + cliApp.Commands = append(cliApp.Commands, cli.Command{ + Name: "version", + Usage: "Show the version for Helmfile.", + ArgsUsage: "[command]", + Action: func(c *cli.Context) error { + cli.ShowVersion(c) + return nil + }, + }) +} diff --git a/cmd/write-values.go b/cmd/write-values.go new file mode 100644 index 00000000..b1117fbc --- /dev/null +++ b/cmd/write-values.go @@ -0,0 +1,40 @@ +package cmd + +import ( + "github.com/helmfile/helmfile/pkg/app" + "github.com/helmfile/helmfile/pkg/config" + "github.com/urfave/cli" +) + +func addWriteValuesSubcommand(cliApp *cli.App) { + cliApp.Commands = append(cliApp.Commands, cli.Command{ + Name: "write-values", + Usage: "write values files for releases. Similar to `helmfile template`, write values files instead of manifests.", + Flags: []cli.Flag{ + cli.StringSliceFlag{ + Name: "set", + Usage: "additional values to be merged into the command", + }, + cli.StringSliceFlag{ + Name: "values", + Usage: "additional value files to be merged into the command", + }, + cli.StringFlag{ + Name: "output-file-template", + Usage: "go text template for generating the output file. Default: {{ .State.BaseName }}-{{ .State.AbsPathSHA1 }}/{{ .Release.Name}}.yaml", + }, + cli.IntFlag{ + Name: "concurrency", + Value: 0, + Usage: "maximum number of concurrent downloads of release charts", + }, + cli.BoolFlag{ + Name: "skip-deps", + Usage: `skip running "helm repo update" and "helm dependency build"`, + }, + }, + Action: Action(func(a *app.App, c config.ConfigImpl) error { + return a.WriteValues(c) + }), + }) +} diff --git a/main.go b/main.go index 21bb7501..cb43438d 100644 --- a/main.go +++ b/main.go @@ -5,431 +5,11 @@ import ( "os" "github.com/helmfile/helmfile/cmd" - "github.com/helmfile/helmfile/pkg/app" - "github.com/helmfile/helmfile/pkg/config" - "github.com/urfave/cli" ) func main() { rootCmd := cmd.RootCommand() - subCommands := []cli.Command{ - { - Name: "write-values", - Usage: "write values files for releases. Similar to `helmfile template`, write values files instead of manifests.", - Flags: []cli.Flag{ - cli.StringSliceFlag{ - Name: "set", - Usage: "additional values to be merged into the command", - }, - cli.StringSliceFlag{ - Name: "values", - Usage: "additional value files to be merged into the command", - }, - cli.StringFlag{ - Name: "output-file-template", - Usage: "go text template for generating the output file. Default: {{ .State.BaseName }}-{{ .State.AbsPathSHA1 }}/{{ .Release.Name}}.yaml", - }, - cli.IntFlag{ - Name: "concurrency", - Value: 0, - Usage: "maximum number of concurrent downloads of release charts", - }, - cli.BoolFlag{ - Name: "skip-deps", - Usage: `skip running "helm repo update" and "helm dependency build"`, - }, - }, - Action: cmd.Action(func(a *app.App, c config.ConfigImpl) error { - return a.WriteValues(c) - }), - }, - { - Name: "lint", - Usage: "lint charts from state file (helm lint)", - Flags: []cli.Flag{ - cli.StringFlag{ - Name: "args", - Value: "", - Usage: "pass args to helm exec", - }, - cli.StringSliceFlag{ - Name: "set", - Usage: "additional values to be merged into the command", - }, - cli.StringSliceFlag{ - Name: "values", - Usage: "additional value files to be merged into the command", - }, - cli.IntFlag{ - Name: "concurrency", - Value: 0, - Usage: "maximum number of concurrent downloads of release charts", - }, - cli.BoolFlag{ - Name: "skip-deps", - Usage: `skip running "helm repo update" and "helm dependency build"`, - }, - }, - Action: cmd.Action(func(a *app.App, c config.ConfigImpl) error { - return a.Lint(c) - }), - }, - { - Name: "fetch", - Usage: "fetch charts from state file", - Flags: []cli.Flag{ - cli.IntFlag{ - Name: "concurrency", - Value: 0, - Usage: "maximum number of concurrent downloads of release charts", - }, - cli.BoolFlag{ - Name: "skip-deps", - Usage: `skip running "helm repo update" and "helm dependency build"`, - }, - cli.StringFlag{ - Name: "output-dir", - Usage: "directory to store charts (default: temporary directory which is deleted when the command terminates)", - }, - }, - Action: cmd.Action(func(a *app.App, c config.ConfigImpl) error { - return a.Fetch(c) - }), - }, - { - Name: "sync", - Usage: "sync all resources from state file (repos, releases and chart deps)", - Flags: []cli.Flag{ - cli.StringSliceFlag{ - Name: "set", - Usage: "additional values to be merged into the command", - }, - cli.StringSliceFlag{ - Name: "values", - Usage: "additional value files to be merged into the command", - }, - cli.IntFlag{ - Name: "concurrency", - Value: 0, - Usage: "maximum number of concurrent helm processes to run, 0 is unlimited", - }, - cli.StringFlag{ - Name: "args", - 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"`, - }, - cli.BoolTFlag{ - Name: "skip-needs", - Usage: `do not automatically include releases from the target release's "needs" when --selector/-l flag is provided. Does nothing when when --selector/-l flag is not provided. Defaults to true when --include-needs or --include-transitive-needs is not provided`, - }, - cli.BoolFlag{ - Name: "include-needs", - Usage: `automatically include releases from the target release's "needs" when --selector/-l flag is provided. Does nothing when when --selector/-l flag is not provided`, - }, - cli.BoolFlag{ - Name: "include-transitive-needs", - Usage: `like --include-needs, but also includes transitive needs (needs of needs). Does nothing when when --selector/-l flag is not provided. Overrides exclusions of other selectors and conditions.`, - }, - cli.BoolFlag{ - Name: "validate", - Usage: `ADVANCED CONFIGURATION: When sync is going to involve helm-template as a part of the "chartify" process, it might fail due to missing .Capabilities. This flag makes instructs helmfile to pass --validate to helm-template so it populates .Capabilities and validates your manifests against the Kubernetes cluster you are currently pointing at. Note that this requiers access to a Kubernetes cluster to obtain information necessary for validating, like the list of available API versions`, - }, - cli.BoolFlag{ - Name: "wait", - Usage: `Override helmDefaults.wait setting "helm upgrade --install --wait"`, - }, - cli.BoolFlag{ - Name: "wait-for-jobs", - Usage: `Override helmDefaults.waitForJobs setting "helm upgrade --install --wait-for-jobs"`, - }, - }, - Action: cmd.Action(func(a *app.App, c config.ConfigImpl) error { - return a.Sync(c) - }), - }, - { - Name: "apply", - Usage: "apply all resources from state file only when there are changes", - Flags: []cli.Flag{ - cli.StringSliceFlag{ - Name: "set", - Usage: "additional values to be merged into the command", - }, - cli.StringSliceFlag{ - Name: "values", - Usage: "additional value files to be merged into the command", - }, - cli.IntFlag{ - Name: "concurrency", - Value: 0, - Usage: "maximum number of concurrent helm processes to run, 0 is unlimited", - }, - cli.BoolFlag{ - Name: "validate", - Usage: "validate your manifests against the Kubernetes cluster you are currently pointing at. Note that this requiers access to a Kubernetes cluster to obtain information necessary for validating, like the list of available API versions", - }, - cli.IntFlag{ - Name: "context", - Value: 0, - Usage: "output NUM lines of context around changes", - }, - cli.StringFlag{ - Name: "output", - Value: "", - Usage: "output format for diff plugin", - }, - cli.BoolFlag{ - Name: "detailed-exitcode", - Usage: "return a non-zero exit code 2 instead of 0 when there were changes detected AND the changes are synced successfully", - }, - cli.StringFlag{ - Name: "args", - Value: "", - Usage: "pass args to helm exec", - }, - cli.BoolFlag{ - Name: "retain-values-files", - Usage: "DEPRECATED: Use skip-cleanup instead", - }, - cli.BoolFlag{ - 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.BoolTFlag{ - Name: "skip-needs", - Usage: `do not automatically include releases from the target release's "needs" when --selector/-l flag is provided. Does nothing when when --selector/-l flag is not provided. Defaults to true when --include-needs or --include-transitive-needs is not provided`, - }, - cli.BoolFlag{ - Name: "include-needs", - Usage: `automatically include releases from the target release's "needs" when --selector/-l flag is provided. Does nothing when when --selector/-l flag is not provided`, - }, - cli.BoolFlag{ - Name: "include-transitive-needs", - Usage: `like --include-needs, but also includes transitive needs (needs of needs). Does nothing when when --selector/-l flag is not provided. Overrides exclusions of other selectors and conditions.`, - }, - 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", - }, - cli.BoolFlag{ - Name: "include-tests", - Usage: "enable the diffing of the helm test hooks", - }, - cli.StringSliceFlag{ - Name: "suppress", - Usage: "suppress specified Kubernetes objects in the diff output. Can be provided multiple times. For example: --suppress KeycloakClient --suppress VaultSecret", - }, - cli.BoolFlag{ - Name: "suppress-secrets", - Usage: "suppress secrets in the diff output. highly recommended to specify on CI/CD use-cases", - }, - cli.BoolFlag{ - Name: "show-secrets", - Usage: "do not redact secret values in the diff output. should be used for debug purpose only", - }, - cli.BoolFlag{ - Name: "suppress-diff", - Usage: "suppress diff in the output. Usable in new installs", - }, - cli.BoolFlag{ - 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"`, - }, - cli.BoolFlag{ - Name: "wait-for-jobs", - Usage: `Override helmDefaults.waitForJobs setting "helm upgrade --install --wait-for-jobs"`, - }, - }, - Action: cmd.Action(func(a *app.App, c config.ConfigImpl) error { - return a.Apply(c) - }), - }, - { - Name: "status", - Usage: "retrieve status of releases in state file", - Flags: []cli.Flag{ - cli.IntFlag{ - Name: "concurrency", - Value: 0, - Usage: "maximum number of concurrent helm processes to run, 0 is unlimited", - }, - cli.StringFlag{ - Name: "args", - Value: "", - Usage: "pass args to helm exec", - }, - }, - Action: cmd.Action(func(a *app.App, c config.ConfigImpl) error { - return a.Status(c) - }), - }, - { - Name: "delete", - Usage: "DEPRECATED: delete releases from state file (helm delete)", - Flags: []cli.Flag{ - cli.IntFlag{ - Name: "concurrency", - Value: 0, - Usage: "maximum number of concurrent helm processes to run, 0 is unlimited", - }, - cli.StringFlag{ - Name: "args", - Value: "", - Usage: "pass args to helm exec", - }, - cli.BoolFlag{ - Name: "purge", - Usage: "purge releases i.e. free release names and histories", - }, - cli.BoolFlag{ - Name: "skip-deps", - Usage: `skip running "helm repo update" and "helm dependency build"`, - }, - }, - Action: cmd.Action(func(a *app.App, c config.ConfigImpl) error { - return a.Delete(c) - }), - }, - { - Name: "destroy", - Usage: "deletes and then purges releases", - Flags: []cli.Flag{ - cli.IntFlag{ - Name: "concurrency", - Value: 0, - Usage: "maximum number of concurrent helm processes to run, 0 is unlimited", - }, - cli.StringFlag{ - Name: "args", - Value: "", - Usage: "pass args to helm exec", - }, - cli.BoolFlag{ - Name: "skip-deps", - Usage: `skip running "helm repo update" and "helm dependency build"`, - }, - }, - Action: cmd.Action(func(a *app.App, c config.ConfigImpl) error { - return a.Destroy(c) - }), - }, - { - Name: "test", - Usage: "test releases from state file (helm test)", - Flags: []cli.Flag{ - cli.BoolFlag{ - Name: "cleanup", - Usage: "delete test pods upon completion", - }, - cli.BoolFlag{ - Name: "logs", - Usage: "Dump the logs from test pods (this runs after all tests are complete, but before any cleanup)", - }, - cli.StringFlag{ - Name: "args", - Value: "", - Usage: "pass additional args to helm exec", - }, - cli.IntFlag{ - Name: "timeout", - Value: 300, - Usage: "maximum time for tests to run before being considered failed", - }, - cli.IntFlag{ - Name: "concurrency", - Value: 0, - Usage: "maximum number of concurrent helm processes to run, 0 is unlimited", - }, - cli.BoolFlag{ - Name: "skip-deps", - Usage: `skip running "helm repo update" and "helm dependency build"`, - }, - }, - Action: cmd.Action(func(a *app.App, c config.ConfigImpl) error { - return a.Test(c) - }), - }, - { - Name: "build", - Usage: "output compiled helmfile state(s) as YAML", - Flags: []cli.Flag{ - cli.BoolFlag{ - Name: "embed-values", - Usage: "Read all the values files for every release and embed into the output helmfile.yaml", - }, - }, - Action: cmd.Action(func(a *app.App, c config.ConfigImpl) error { - return a.PrintState(c) - }), - }, - { - Name: "list", - Usage: "list releases defined in state file", - Flags: []cli.Flag{ - cli.StringFlag{ - Name: "output", - Value: "", - Usage: "output releases list as a json string", - }, - cli.BoolFlag{ - Name: "keep-temp-dir", - Usage: "Keep temporary directory", - }, - }, - Action: cmd.Action(func(a *app.App, c config.ConfigImpl) error { - return a.ListReleases(c) - }), - }, - { - Name: "cache", - Usage: "cache management", - ArgsUsage: "[command]", - Subcommands: []cli.Command{ - { - Name: "info", - Usage: "cache info", - Action: cmd.Action(func(a *app.App, c config.ConfigImpl) error { - return a.ShowCacheDir(c) - }), - }, - { - Name: "cleanup", - Usage: "clean up cache directory", - Action: cmd.Action(func(a *app.App, c config.ConfigImpl) error { - return a.CleanCacheDir(c) - }), - }, - }, - }, - { - Name: "version", - Usage: "Show the version for Helmfile.", - ArgsUsage: "[command]", - Action: func(c *cli.Context) error { - cli.ShowVersion(c) - return nil - }, - }, - } - rootCmd.Commands = append(rootCmd.Commands, subCommands...) - err := rootCmd.Run(os.Args) if err != nil { fmt.Fprintf(os.Stderr, "%v\n", err)