fix --debug flag

Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
yxxhero 2022-10-25 08:24:23 +08:00
parent 9d28e28086
commit f8a297bbac
30 changed files with 28 additions and 132 deletions

View File

@ -39,7 +39,7 @@ func NewApplyCmd(globalCfg *config.GlobalImpl) *cobra.Command {
f.IntVar(&applyOptions.Context, "context", 0, "output NUM lines of context around changes")
f.StringVar(&applyOptions.Output, "output", "", "output format for diff plugin")
f.BoolVar(&applyOptions.DetailedExitcode, "detailed-exitcode", false, "return a non-zero exit code 2 instead of 0 when there were changes detected AND the changes are synced successfully")
f.StringVar(&applyOptions.Args, "args", "", "pass args to helm exec")
f.StringVar(&globalCfg.GlobalOptions.Args, "args", "", "pass args to helm exec")
f.BoolVar(&applyOptions.RetainValuesFiles, "retain-values-files", false, "DEPRECATED: Use skip-cleanup instead")
// mark retain-values-files as deprecated, but keep it for backward compatibility, will be removed in the future
_ = f.MarkDeprecated("retain-values-files", "Use skip-cleanup instead")

View File

@ -31,7 +31,7 @@ func NewChartsCmd(globalCfg *config.GlobalImpl) *cobra.Command {
}
f := cmd.Flags()
f.StringVar(&chartsOptions.Args, "args", "", "pass args to helm exec")
f.StringVar(&globalCfg.GlobalOptions.Args, "args", "", "pass args to helm exec")
f.StringArrayVar(&chartsOptions.Set, "set", nil, "additional values to be merged into the command")
f.StringArrayVar(&chartsOptions.Values, "values", nil, "additional value files to be merged into the command")
f.IntVar(&chartsOptions.Concurrency, "concurrency", 0, "maximum number of concurrent helm processes to run, 0 is unlimited")

View File

@ -31,7 +31,7 @@ func NewDeleteCmd(globalCfg *config.GlobalImpl) *cobra.Command {
}
f := cmd.Flags()
f.StringVar(&deleteOptions.Args, "args", "", "pass args to helm exec")
f.StringVar(&globalCfg.GlobalOptions.Args, "args", "", "pass args to helm exec")
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"`)

View File

@ -31,7 +31,7 @@ func NewDepsCmd(globalCfg *config.GlobalImpl) *cobra.Command {
}
f := cmd.Flags()
f.StringVar(&depsOptions.Args, "args", "", "pass args to helm exec")
f.StringVar(&globalCfg.GlobalOptions.Args, "args", "", "pass args to helm exec")
f.BoolVar(&depsOptions.SkipRepos, "skip-repos", false, `skip running "helm repo update" and "helm dependency build"`)
f.IntVar(&depsOptions.Concurrency, "concurrency", 0, "maximum number of concurrent helm processes to run, 0 is unlimited")

View File

@ -31,7 +31,7 @@ func NewDestroyCmd(globalCfg *config.GlobalImpl) *cobra.Command {
}
f := cmd.Flags()
f.StringVar(&destroyOptions.Args, "args", "", "pass args to helm exec")
f.StringVar(&globalCfg.GlobalOptions.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"`)

View File

@ -31,7 +31,7 @@ func NewDiffCmd(globalCfg *config.GlobalImpl) *cobra.Command {
}
f := cmd.Flags()
f.StringVar(&diffOptions.Args, "args", "", "pass args to helm diff")
f.StringVar(&globalCfg.GlobalOptions.Args, "args", "", "pass args to helm diff")
f.StringArrayVar(&diffOptions.Set, "set", nil, "additional values to be merged into the command")
f.StringArrayVar(&diffOptions.Values, "values", nil, "additional value files to be merged into the command")
f.IntVar(&diffOptions.Concurrency, "concurrency", 0, "maximum number of concurrent helm processes to run, 0 is unlimited")

View File

@ -33,7 +33,7 @@ func NewLintCmd(globalCfg *config.GlobalImpl) *cobra.Command {
f := cmd.Flags()
f.IntVar(&lintOptions.Concurrency, "concurrency", 0, "maximum number of concurrent helm processes to run, 0 is unlimited")
f.BoolVar(&lintOptions.SkipDeps, "skip-deps", false, `skip running "helm repo update" and "helm dependency build"`)
f.StringVar(&lintOptions.Args, "args", "", "pass args to helm exec")
f.StringVar(&globalCfg.GlobalOptions.Args, "args", "", "pass args to helm exec")
f.StringArrayVar(&lintOptions.Set, "set", nil, "additional values to be merged into the command")
f.StringArrayVar(&lintOptions.Values, "values", nil, "additional value files to be merged into the command")
f.BoolVar(&lintOptions.SkipNeeds, "skip-needs", true, `do not automatically include releases from the target release's "needs" when --selector/-l flag is provided. Does nothing when --selector/-l flag is not provided. Defaults to true when --include-needs or --include-transitive-needs is not provided`)

View File

@ -31,7 +31,7 @@ func NewReposCmd(globalCfg *config.GlobalImpl) *cobra.Command {
}
f := cmd.Flags()
f.StringVar(&reposOptions.Args, "args", "", "pass args to helm exec")
f.StringVar(&globalCfg.GlobalOptions.Args, "args", "", "pass args to helm exec")
return cmd
}

View File

@ -31,7 +31,7 @@ func NewStatusCmd(globalCfg *config.GlobalImpl) *cobra.Command {
}
f := cmd.Flags()
f.StringVar(&statusOptions.Args, "args", "", "pass args to helm exec")
f.StringVar(&globalCfg.GlobalOptions.Args, "args", "", "pass args to helm exec")
f.IntVar(&statusOptions.Concurrency, "concurrency", 0, "maximum number of concurrent helm processes to run, 0 is unlimited")
return cmd

View File

@ -31,7 +31,7 @@ func NewSyncCmd(globalCfg *config.GlobalImpl) *cobra.Command {
}
f := cmd.Flags()
f.StringVar(&syncOptions.Args, "args", "", "pass args to helm sync")
f.StringVar(&globalCfg.GlobalOptions.Args, "args", "", "pass args to helm sync")
f.StringArrayVar(&syncOptions.Set, "set", nil, "additional values to be merged into the command")
f.StringArrayVar(&syncOptions.Values, "values", nil, "additional value files to be merged into the command")
f.IntVar(&syncOptions.Concurrency, "concurrency", 0, "maximum number of concurrent helm processes to run, 0 is unlimited")

View File

@ -31,7 +31,7 @@ func NewTemplateCmd(globalCfg *config.GlobalImpl) *cobra.Command {
}
f := cmd.Flags()
f.StringVar(&templateOptions.Args, "args", "", "pass args to helm template")
f.StringVar(&globalCfg.GlobalOptions.Args, "args", "", "pass args to helm template")
f.StringArrayVar(&templateOptions.Set, "set", nil, "additional values to be merged into the command")
f.StringArrayVar(&templateOptions.Values, "values", nil, "additional value files to be merged into the command")
f.StringVar(&templateOptions.OutputDir, "output-dir", "", "output directory to pass to helm template (helm template --output-dir)")

View File

@ -36,7 +36,7 @@ func NewTestCmd(globalCfg *config.GlobalImpl) *cobra.Command {
f.BoolVar(&testOptions.SkipDeps, "skip-deps", false, `skip running "helm repo update" and "helm dependency build"`)
f.BoolVar(&testOptions.Cleanup, "cleanup", false, "delete test pods upon completion")
f.BoolVar(&testOptions.Logs, "logs", false, "Dump the logs from test pods (this runs after all tests are complete, but before any cleanup)")
f.StringVar(&testOptions.Args, "args", "", "pass args to helm exec")
f.StringVar(&globalCfg.GlobalOptions.Args, "args", "", "pass args to helm exec")
f.IntVar(&testOptions.Timeout, "timeout", 300, "maximum time for tests to run before being considered failed")
return cmd

View File

@ -1,7 +1,5 @@
package config
import "fmt"
// ApplyOptoons is the options for the apply command
type ApplyOptions struct {
// Set is a list of key value pairs to be merged into the command
@ -18,8 +16,6 @@ type ApplyOptions struct {
Output string
// DetailedExitcode is true if the exit code should be 2 instead of 0 if there were changes detected and the changes were synced successfully
DetailedExitcode bool
// Args is the arguments to pass to helm exec
Args string
// DEPRECATED: Use skip-cleanup instead
RetainValuesFiles bool
// SkipCleanup is true if the cleanup of temporary values files should be skipped
@ -80,18 +76,6 @@ func (a *ApplyImpl) Set() []string {
return a.ApplyOptions.Set
}
// Args returns the args.
func (a *ApplyImpl) Args() string {
args := a.ApplyOptions.Args
enableHelmDebug := a.GlobalImpl.Debug
if enableHelmDebug {
args = fmt.Sprintf("%s %s", args, "--debug")
}
return args
}
// Concurrency returns the concurrency.
func (a *ApplyImpl) Concurrency() int {
return a.ApplyOptions.Concurrency

View File

@ -25,11 +25,6 @@ func NewBuildImpl(g *GlobalImpl, b *BuildOptions) *BuildImpl {
}
}
// Args returns the args.
func (b *BuildImpl) Args() string {
return ""
}
// EmbedValues returns the embed values.
func (b *BuildImpl) EmbedValues() bool {
return b.BuildOptions.EmbedValues

View File

@ -21,8 +21,3 @@ func NewCacheImpl(g *GlobalImpl, b *CacheOptions) *CacheImpl {
CacheOptions: b,
}
}
// Args returns the args.
func (b *CacheImpl) Args() string {
return ""
}

View File

@ -2,8 +2,6 @@ package config
// ChartsOptions is the options for the build command
type ChartsOptions struct {
// Args is the args to pass to helm exec
Args string
// Set is the additional values to be merged into the command
Set []string
// Values is the additional value files to be merged into the command
@ -36,11 +34,6 @@ func (c *ChartsImpl) Concurrency() int {
return c.ChartsOptions.Concurrency
}
// Args returns the args
func (c *ChartsImpl) Args() string {
return c.ChartsOptions.Args
}
// IncludeTransitiveNeeds returns the includeTransitiveNeeds
func (c *ChartsImpl) IncludeTransitiveNeeds() bool {
return false

View File

@ -2,8 +2,6 @@ package config
// DeleteOptions is the options for the build command
type DeleteOptions struct {
// Args is the args to pass to helm exec
Args string
// Concurrency is the maximum number of concurrent helm processes to run, 0 is unlimited
Concurrency int
// Purge is the purge flag
@ -36,11 +34,6 @@ func (c *DeleteImpl) Concurrency() int {
return c.DeleteOptions.Concurrency
}
// Args returns the args
func (c *DeleteImpl) Args() string {
return c.DeleteOptions.Args
}
// Purge returns the purge
func (c *DeleteImpl) Purge() bool {
return c.DeleteOptions.Purge

View File

@ -2,8 +2,6 @@ package config
// DepsOptions is the options for the build command
type DepsOptions struct {
// Args is the args to pass to helm exec
Args string
// SkipRepos is the skip repos flag
SkipRepos bool
// Concurrency is the maximum number of concurrent helm processes to run
@ -29,11 +27,6 @@ func NewDepsImpl(g *GlobalImpl, b *DepsOptions) *DepsImpl {
}
}
// Args returns the args
func (d *DepsImpl) Args() string {
return d.DepsOptions.Args
}
// SkipRepos returns the skip deps
func (d *DepsImpl) SkipRepos() bool {
return d.DepsOptions.SkipRepos

View File

@ -2,8 +2,6 @@ package config
// DestroyOptions is the options for the build command
type DestroyOptions struct {
// Args is the args to pass to helm exec
Args string
// Concurrency is the maximum number of concurrent helm processes to run, 0 is unlimited
Concurrency int
// SkipDeps is the skip deps flag
@ -34,11 +32,6 @@ func (c *DestroyImpl) Concurrency() int {
return c.DestroyOptions.Concurrency
}
// Args returns the args
func (c *DestroyImpl) Args() string {
return c.DestroyOptions.Args
}
// SkipDeps returns the skip deps
func (c *DestroyImpl) SkipDeps() bool {
return c.DestroyOptions.SkipDeps

View File

@ -2,8 +2,6 @@ package config
// DiffOptions is the options for the build command
type DiffOptions struct {
// Args is the args to pass to helm template
Args string
// Set is the set flag
Set []string
// Values is the values flag
@ -61,11 +59,6 @@ func NewDiffImpl(g *GlobalImpl, t *DiffOptions) *DiffImpl {
}
}
// Args returns the args
func (t *DiffImpl) Args() string {
return t.DiffOptions.Args
}
// Concurrency returns the concurrency
func (t *DiffImpl) Concurrency() int {
return t.DiffOptions.Concurrency

View File

@ -39,11 +39,6 @@ func (c *FetchImpl) SkipDeps() bool {
return c.FetchOptions.SkipDeps
}
// Args returns the args
func (c *FetchImpl) Args() string {
return ""
}
// OutputDir returns the args
func (c *FetchImpl) OutputDir() string {
return c.FetchOptions.OutputDir

View File

@ -2,6 +2,7 @@ package config
import (
"errors"
"fmt"
"os"
"go.uber.org/zap"
@ -48,6 +49,8 @@ type GlobalOptions struct {
EnableLiveOutput bool
// Interactive is true if the user should be prompted for input.
Interactive bool
// Args is the list of arguments to pass to the Helm binary.
Args string
}
// Logger returns the logger to use.
@ -186,3 +189,15 @@ func (g *GlobalImpl) ValidateConfig() error {
func (g *GlobalImpl) Interactive() bool {
return g.GlobalOptions.Interactive
}
// Args returns the args to use for helm
func (g *GlobalImpl) Args() string {
args := g.GlobalOptions.Args
enableHelmDebug := g.GlobalOptions.Debug
if enableHelmDebug {
args = fmt.Sprintf("%s %s", args, "--debug")
}
return args
}

View File

@ -6,8 +6,6 @@ type LintOptions struct {
Concurrency int
// SkipDeps is the skip deps flag
SkipDeps bool
// Args is the args to pass to helm lint
Args string
// Set is the set flags to pass to helm lint
Set []string
// Values is the values flags to pass to helm lint
@ -50,11 +48,6 @@ func (l *LintImpl) SkipDeps() bool {
return l.LintOptions.SkipDeps
}
// Args returns the args
func (l *LintImpl) Args() string {
return l.LintOptions.Args
}
// Set returns the Set
func (l *LintImpl) Set() []string {
return l.LintOptions.Set

View File

@ -29,11 +29,6 @@ func NewListImpl(g *GlobalImpl, b *ListOptions) *ListImpl {
}
}
// Args returns the args
func (c *ListImpl) Args() string {
return ""
}
// Output returns the output
func (c *ListImpl) Output() string {
return c.ListOptions.Output

View File

@ -1,10 +1,7 @@
package config
// ReposOptions is the options for the build command
type ReposOptions struct {
// Args is the args
Args string
}
type ReposOptions struct{}
// NewReposOptions creates a new Apply
func NewReposOptions() *ReposOptions {
@ -25,11 +22,6 @@ func NewReposImpl(g *GlobalImpl, b *ReposOptions) *ReposImpl {
}
}
// Args returns the args
func (r *ReposImpl) Args() string {
return r.ReposOptions.Args
}
// IncludeTransitiveNeeds returns the include transitive needs
func (r *ReposImpl) IncludeTransitiveNeeds() bool {
return false

View File

@ -2,8 +2,6 @@ package config
// StatusOptions is the options for the build command
type StatusOptions struct {
// Args is the args
Args string
// Concurrency is the concurrent flag
Concurrency int
}
@ -27,11 +25,6 @@ func NewStatusImpl(g *GlobalImpl, b *StatusOptions) *StatusImpl {
}
}
// Args returns the args
func (s *StatusImpl) Args() string {
return s.StatusOptions.Args
}
// IncludeTransitiveNeeds returns the include transitive needs
func (s *StatusImpl) IncludeTransitiveNeeds() bool {
return false

View File

@ -2,8 +2,6 @@ package config
// SyncOptions is the options for the build command
type SyncOptions struct {
// Args is the args to pass to helm template
Args string
// Set is the set flag
Set []string
// Values is the values flag
@ -49,11 +47,6 @@ func NewSyncImpl(g *GlobalImpl, t *SyncOptions) *SyncImpl {
}
}
// Args returns the args
func (t *SyncImpl) Args() string {
return t.SyncOptions.Args
}
// Concurrency returns the concurrency
func (t *SyncImpl) Concurrency() int {
return t.SyncOptions.Concurrency

View File

@ -8,8 +8,6 @@ import (
// TemplateOptions is the options for the build command
type TemplateOptions struct {
// Args is the args to pass to helm template
Args string
// Set is the set flag
Set []string
// Values is the values flag
@ -57,11 +55,6 @@ func NewTemplateImpl(g *GlobalImpl, t *TemplateOptions) *TemplateImpl {
}
}
// Args returns the args
func (t *TemplateImpl) Args() string {
return t.TemplateOptions.Args
}
// Concurrency returns the concurrency
func (t *TemplateImpl) Concurrency() int {
return t.TemplateOptions.Concurrency

View File

@ -12,8 +12,6 @@ type TestOptions struct {
Concurrency int
// SkipDeps is the skip deps flag
SkipDeps bool
// Args is the args to pass to helm lint
Args string
// Cleanup is the cleanup flag
Cleanup bool
// Logs is the logs flagj
@ -52,11 +50,6 @@ func (t *TestImpl) SkipDeps() bool {
return t.TestOptions.SkipDeps
}
// Args returns the args
func (t *TestImpl) Args() string {
return t.TestOptions.Args
}
// Cleanup returns the cleanup
func (t *TestImpl) Cleanup() bool {
return t.TestOptions.Cleanup

View File

@ -67,8 +67,3 @@ func (c *WriteValuesImpl) IncludeTransitiveNeeds() bool {
func (c *WriteValuesImpl) OutputFileTemplate() string {
return c.WriteValuesOptions.OutputFileTemplate
}
// Args returns the args
func (c *WriteValuesImpl) Args() string {
return ""
}