From 18eee1fa47476010f958e2aed73d1bf309ff4a2c Mon Sep 17 00:00:00 2001 From: yxxhero <11087727+yxxhero@users.noreply.github.com> Date: Sun, 18 Sep 2022 17:47:40 +0800 Subject: [PATCH] move interactive option to global (#370) Fixes #366 Signed-off-by: yxxhero --- cmd/apply.go | 1 - cmd/delete.go | 1 - cmd/destroy.go | 1 - cmd/root.go | 1 + cmd/sync.go | 1 - pkg/config/apply.go | 7 ------- pkg/config/delete.go | 7 ------- pkg/config/destroy.go | 7 ------- pkg/config/global.go | 7 +++++++ pkg/config/sync.go | 7 ------- 10 files changed, 8 insertions(+), 32 deletions(-) diff --git a/cmd/apply.go b/cmd/apply.go index 03f10302..b38bde40 100644 --- a/cmd/apply.go +++ b/cmd/apply.go @@ -54,7 +54,6 @@ func NewApplyCmd(globalCfg *config.GlobalImpl) *cobra.Command { f.BoolVar(&applyOptions.NoHooks, "no-hooks", false, "do not diff changes made by hooks.") f.BoolVar(&applyOptions.SuppressDiff, "suppress-diff", false, "suppress diff in the output. Usable in new installs") f.BoolVar(&applyOptions.SkipDeps, "skip-deps", false, `skip running "helm repo update" and "helm dependency build"`) - f.BoolVarP(&applyOptions.Interactive, "interactive", "i", false, "Request confirmation before attempting to modify clusters") f.BoolVar(&applyOptions.Wait, "wait", false, `Override helmDefaults.wait setting "helm upgrade --install --wait"`) f.BoolVar(&applyOptions.WaitForJobs, "wait-for-jobs", false, `Override helmDefaults.waitForJobs setting "helm upgrade --install --wait-for-jobs"`) diff --git a/cmd/delete.go b/cmd/delete.go index 867d205d..09d4c105 100644 --- a/cmd/delete.go +++ b/cmd/delete.go @@ -35,7 +35,6 @@ func NewDeleteCmd(globalCfg *config.GlobalImpl) *cobra.Command { f.IntVar(&deleteOptions.Concurrency, "concurrency", 0, "maximum number of concurrent helm processes to run, 0 is unlimited") f.BoolVar(&deleteOptions.Purge, "purge", false, "purge releases i.e. free release names and histories") f.BoolVar(&deleteOptions.SkipDeps, "skip-deps", false, `skip running "helm repo update" and "helm dependency build"`) - f.BoolVarP(&deleteOptions.Interactive, "interactive", "i", false, "Request confirmation before attempting to modify clusters") return cmd } diff --git a/cmd/destroy.go b/cmd/destroy.go index eaf24c73..c2ba93d7 100644 --- a/cmd/destroy.go +++ b/cmd/destroy.go @@ -34,7 +34,6 @@ func NewDestroyCmd(globalCfg *config.GlobalImpl) *cobra.Command { f.StringVar(&destroyOptions.Args, "args", "", "pass args to helm exec") f.IntVar(&destroyOptions.Concurrency, "concurrency", 0, "maximum number of concurrent helm processes to run, 0 is unlimited") f.BoolVar(&destroyOptions.SkipDeps, "skip-deps", false, `skip running "helm repo update" and "helm dependency build"`) - f.BoolVarP(&destroyOptions.Interactive, "interactive", "i", false, "Request confirmation before attempting to modify clusters") return cmd } diff --git a/cmd/root.go b/cmd/root.go index defcda0e..a395579c 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -116,6 +116,7 @@ The name of a release can be used as a label: "--selector name=myrelease"`) fs.BoolVar(&globalOptions.AllowNoMatchingRelease, "allow-no-matching-release", false, `Do not exit with an error code if the provided selector has no matching releases.`) fs.BoolVar(&globalOptions.EnableLiveOutput, "enable-live-output", globalOptions.EnableLiveOutput, `Show live output from the Helm binary Stdout/Stderr into Helmfile own Stdout/Stderr. It only applies for the Helm CLI commands, Stdout/Stderr for Hooks are still displayed only when it's execution finishes.`) + fs.BoolVarP(&globalOptions.Interactive, "interactive", "i", false, "Request confirmation before attempting to modify clusters") // avoid 'pflag: help requested' error (#251) fs.BoolP("help", "h", false, "help for helmfile") } diff --git a/cmd/sync.go b/cmd/sync.go index a1d4d4fc..63431a48 100644 --- a/cmd/sync.go +++ b/cmd/sync.go @@ -43,7 +43,6 @@ func NewSyncCmd(globalCfg *config.GlobalImpl) *cobra.Command { f.BoolVar(&syncOptions.SkipDeps, "skip-deps", false, `skip running "helm repo update" and "helm dependency build"`) f.BoolVar(&syncOptions.Wait, "wait", false, `Override helmDefaults.wait setting "helm upgrade --install --wait"`) f.BoolVar(&syncOptions.WaitForJobs, "wait-for-jobs", false, `Override helmDefaults.waitForJobs setting "helm upgrade --install --wait-for-jobs"`) - f.BoolVarP(&syncOptions.Interactive, "interactive", "i", false, "Request confirmation before attempting to modify clusters") return cmd } diff --git a/pkg/config/apply.go b/pkg/config/apply.go index a94303e9..a3a48106 100644 --- a/pkg/config/apply.go +++ b/pkg/config/apply.go @@ -52,8 +52,6 @@ type ApplyOptions struct { Wait bool // WaitForJobs is true if the helm command should wait for the jobs to be completed WaitForJobs bool - // Interactive is true if the user should be prompted for input. - Interactive bool } // NewApply creates a new Apply @@ -204,8 +202,3 @@ func (a *ApplyImpl) Wait() bool { func (a *ApplyImpl) WaitForJobs() bool { return a.ApplyOptions.WaitForJobs } - -// Interactive returns the Interactive. -func (a *ApplyImpl) Interactive() bool { - return a.ApplyOptions.Interactive -} diff --git a/pkg/config/delete.go b/pkg/config/delete.go index fcb4fcd3..3778512f 100644 --- a/pkg/config/delete.go +++ b/pkg/config/delete.go @@ -10,8 +10,6 @@ type DeleteOptions struct { Purge bool // SkipDeps is the skip deps flag SkipDeps bool - // Interactive is true if the user should be prompted for input. - Interactive bool } // NewDeleteOptions creates a new Apply @@ -52,8 +50,3 @@ func (c *DeleteImpl) Purge() bool { func (c *DeleteImpl) SkipDeps() bool { return c.DeleteOptions.SkipDeps } - -// Interactive returns the Interactive -func (c *DeleteImpl) Interactive() bool { - return c.DeleteOptions.Interactive -} diff --git a/pkg/config/destroy.go b/pkg/config/destroy.go index 41ab6eea..5cfbaf26 100644 --- a/pkg/config/destroy.go +++ b/pkg/config/destroy.go @@ -8,8 +8,6 @@ type DestroyOptions struct { Concurrency int // SkipDeps is the skip deps flag SkipDeps bool - // Interactive is true if the user should be prompted for input. - Interactive bool } // NewDestroyOptions creates a new Apply @@ -45,8 +43,3 @@ func (c *DestroyImpl) Args() string { func (c *DestroyImpl) SkipDeps() bool { return c.DestroyOptions.SkipDeps } - -// Interactive returns the Interactive -func (c *DestroyImpl) Interactive() bool { - return c.DestroyOptions.Interactive -} diff --git a/pkg/config/global.go b/pkg/config/global.go index 7e902836..174db85b 100644 --- a/pkg/config/global.go +++ b/pkg/config/global.go @@ -46,6 +46,8 @@ type GlobalOptions struct { logger *zap.SugaredLogger // EnableLiveOutput enables live output from the Helm binary stdout/stderr into Helmfile own stdout/stderr EnableLiveOutput bool + // Interactive is true if the user should be prompted for input. + Interactive bool } // Logger returns the logger to use. @@ -179,3 +181,8 @@ func (g *GlobalImpl) ValidateConfig() error { } return nil } + +// Interactive returns the Interactive +func (g *GlobalImpl) Interactive() bool { + return g.GlobalOptions.Interactive +} diff --git a/pkg/config/sync.go b/pkg/config/sync.go index 0a9178f5..bf228877 100644 --- a/pkg/config/sync.go +++ b/pkg/config/sync.go @@ -26,8 +26,6 @@ type SyncOptions struct { Wait bool // WaitForJobs is the wait for jobs flag WaitForJobs bool - // Interactive is true if the user should be prompted for input. - Interactive bool } // NewSyncOptions creates a new Apply @@ -112,8 +110,3 @@ func (t *SyncImpl) Wait() bool { func (t *SyncImpl) WaitForJobs() bool { return t.SyncOptions.WaitForJobs } - -// Interactive returns the Interactive -func (t *SyncImpl) Interactive() bool { - return t.SyncOptions.Interactive -}