Cleanup pkg/config/config.go (#287)
Signed-off-by: yxxhero <aiopsclub@163.com> Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
		
							parent
							
								
									cf94a4edb3
								
							
						
					
					
						commit
						94b7a6c128
					
				|  | @ -15,7 +15,7 @@ func NewApplyCmd(globalCfg *config.GlobalImpl) *cobra.Command { | ||||||
| 		Use:   "apply", | 		Use:   "apply", | ||||||
| 		Short: "Apply all resources from state file only when there are changes", | 		Short: "Apply all resources from state file only when there are changes", | ||||||
| 		RunE: func(cmd *cobra.Command, args []string) error { | 		RunE: func(cmd *cobra.Command, args []string) error { | ||||||
| 			err := config.NewUrfaveCliConfigImplIns(applyImpl.GlobalImpl) | 			err := config.NewCLIConfigImpl(applyImpl.GlobalImpl) | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				return err | 				return err | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
|  | @ -15,7 +15,7 @@ func NewBuildCmd(globalCfg *config.GlobalImpl) *cobra.Command { | ||||||
| 		Use:   "build", | 		Use:   "build", | ||||||
| 		Short: "Build all resources from state file only when there are changes", | 		Short: "Build all resources from state file only when there are changes", | ||||||
| 		RunE: func(cmd *cobra.Command, args []string) error { | 		RunE: func(cmd *cobra.Command, args []string) error { | ||||||
| 			err := config.NewUrfaveCliConfigImplIns(buildImpl.GlobalImpl) | 			err := config.NewCLIConfigImpl(buildImpl.GlobalImpl) | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				return err | 				return err | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
|  | @ -11,7 +11,7 @@ func NewCacheInfoSubcommand(cacheImpl *config.CacheImpl) *cobra.Command { | ||||||
| 		Use:   "info", | 		Use:   "info", | ||||||
| 		Short: "cache info", | 		Short: "cache info", | ||||||
| 		RunE: func(cmd *cobra.Command, args []string) error { | 		RunE: func(cmd *cobra.Command, args []string) error { | ||||||
| 			err := config.NewUrfaveCliConfigImplIns(cacheImpl.GlobalImpl) | 			err := config.NewCLIConfigImpl(cacheImpl.GlobalImpl) | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				return err | 				return err | ||||||
| 			} | 			} | ||||||
|  | @ -33,7 +33,7 @@ func NewCacheCleanupSubcommand(cacheImpl *config.CacheImpl) *cobra.Command { | ||||||
| 		Use:   "cleanup", | 		Use:   "cleanup", | ||||||
| 		Short: "clean up cache directory", | 		Short: "clean up cache directory", | ||||||
| 		RunE: func(cmd *cobra.Command, args []string) error { | 		RunE: func(cmd *cobra.Command, args []string) error { | ||||||
| 			err := config.NewUrfaveCliConfigImplIns(cacheImpl.GlobalImpl) | 			err := config.NewCLIConfigImpl(cacheImpl.GlobalImpl) | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				return err | 				return err | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
|  | @ -15,7 +15,7 @@ func NewChartsCmd(globalCfg *config.GlobalImpl) *cobra.Command { | ||||||
| 		Use:   "charts", | 		Use:   "charts", | ||||||
| 		Short: "DEPRECATED: sync releases from state file (helm upgrade --install)", | 		Short: "DEPRECATED: sync releases from state file (helm upgrade --install)", | ||||||
| 		RunE: func(cmd *cobra.Command, args []string) error { | 		RunE: func(cmd *cobra.Command, args []string) error { | ||||||
| 			err := config.NewUrfaveCliConfigImplIns(chartsImpl.GlobalImpl) | 			err := config.NewCLIConfigImpl(chartsImpl.GlobalImpl) | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				return err | 				return err | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
|  | @ -15,7 +15,7 @@ func NewDeleteCmd(globalCfg *config.GlobalImpl) *cobra.Command { | ||||||
| 		Use:   "delete", | 		Use:   "delete", | ||||||
| 		Short: "DEPRECATED: delete releases from state file (helm delete)", | 		Short: "DEPRECATED: delete releases from state file (helm delete)", | ||||||
| 		RunE: func(cmd *cobra.Command, args []string) error { | 		RunE: func(cmd *cobra.Command, args []string) error { | ||||||
| 			err := config.NewUrfaveCliConfigImplIns(deleteImpl.GlobalImpl) | 			err := config.NewCLIConfigImpl(deleteImpl.GlobalImpl) | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				return err | 				return err | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
|  | @ -15,7 +15,7 @@ func NewDepsCmd(globalCfg *config.GlobalImpl) *cobra.Command { | ||||||
| 		Use:   "deps", | 		Use:   "deps", | ||||||
| 		Short: "Update charts based on their requirements", | 		Short: "Update charts based on their requirements", | ||||||
| 		RunE: func(cmd *cobra.Command, args []string) error { | 		RunE: func(cmd *cobra.Command, args []string) error { | ||||||
| 			err := config.NewUrfaveCliConfigImplIns(depsImpl.GlobalImpl) | 			err := config.NewCLIConfigImpl(depsImpl.GlobalImpl) | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				return err | 				return err | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
|  | @ -15,7 +15,7 @@ func NewDestroyCmd(globalCfg *config.GlobalImpl) *cobra.Command { | ||||||
| 		Use:   "destroy", | 		Use:   "destroy", | ||||||
| 		Short: "Destroys and then purges releases", | 		Short: "Destroys and then purges releases", | ||||||
| 		RunE: func(cmd *cobra.Command, args []string) error { | 		RunE: func(cmd *cobra.Command, args []string) error { | ||||||
| 			err := config.NewUrfaveCliConfigImplIns(destroyImpl.GlobalImpl) | 			err := config.NewCLIConfigImpl(destroyImpl.GlobalImpl) | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				return err | 				return err | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
|  | @ -15,7 +15,7 @@ func NewDiffCmd(globalCfg *config.GlobalImpl) *cobra.Command { | ||||||
| 		Use:   "diff", | 		Use:   "diff", | ||||||
| 		Short: "Diff releases defined in state file", | 		Short: "Diff releases defined in state file", | ||||||
| 		RunE: func(cmd *cobra.Command, args []string) error { | 		RunE: func(cmd *cobra.Command, args []string) error { | ||||||
| 			err := config.NewUrfaveCliConfigImplIns(diffImpl.GlobalImpl) | 			err := config.NewCLIConfigImpl(diffImpl.GlobalImpl) | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				return err | 				return err | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
|  | @ -15,7 +15,7 @@ func NewFetchCmd(globalCfg *config.GlobalImpl) *cobra.Command { | ||||||
| 		Use:   "fetch", | 		Use:   "fetch", | ||||||
| 		Short: "Fetch charts from state file", | 		Short: "Fetch charts from state file", | ||||||
| 		RunE: func(cmd *cobra.Command, args []string) error { | 		RunE: func(cmd *cobra.Command, args []string) error { | ||||||
| 			err := config.NewUrfaveCliConfigImplIns(fetchImpl.GlobalImpl) | 			err := config.NewCLIConfigImpl(fetchImpl.GlobalImpl) | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				return err | 				return err | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
|  | @ -15,7 +15,7 @@ func NewLintCmd(globalCfg *config.GlobalImpl) *cobra.Command { | ||||||
| 		Use:   "lint", | 		Use:   "lint", | ||||||
| 		Short: "Lint charts from state file (helm lint)", | 		Short: "Lint charts from state file (helm lint)", | ||||||
| 		RunE: func(cmd *cobra.Command, args []string) error { | 		RunE: func(cmd *cobra.Command, args []string) error { | ||||||
| 			err := config.NewUrfaveCliConfigImplIns(lintImpl.GlobalImpl) | 			err := config.NewCLIConfigImpl(lintImpl.GlobalImpl) | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				return err | 				return err | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
|  | @ -15,7 +15,7 @@ func NewListCmd(globalCfg *config.GlobalImpl) *cobra.Command { | ||||||
| 		Use:   "list", | 		Use:   "list", | ||||||
| 		Short: "List releases defined in state file", | 		Short: "List releases defined in state file", | ||||||
| 		RunE: func(cmd *cobra.Command, args []string) error { | 		RunE: func(cmd *cobra.Command, args []string) error { | ||||||
| 			err := config.NewUrfaveCliConfigImplIns(listImpl.GlobalImpl) | 			err := config.NewCLIConfigImpl(listImpl.GlobalImpl) | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				return err | 				return err | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
|  | @ -15,7 +15,7 @@ func NewReposCmd(globalCfg *config.GlobalImpl) *cobra.Command { | ||||||
| 		Use:   "repos", | 		Use:   "repos", | ||||||
| 		Short: "Repos releases defined in state file", | 		Short: "Repos releases defined in state file", | ||||||
| 		RunE: func(cmd *cobra.Command, args []string) error { | 		RunE: func(cmd *cobra.Command, args []string) error { | ||||||
| 			err := config.NewUrfaveCliConfigImplIns(reposImpl.GlobalImpl) | 			err := config.NewCLIConfigImpl(reposImpl.GlobalImpl) | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				return err | 				return err | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
|  | @ -15,7 +15,7 @@ func NewStatusCmd(globalCfg *config.GlobalImpl) *cobra.Command { | ||||||
| 		Use:   "status", | 		Use:   "status", | ||||||
| 		Short: "Retrieve status of releases in state file", | 		Short: "Retrieve status of releases in state file", | ||||||
| 		RunE: func(cmd *cobra.Command, args []string) error { | 		RunE: func(cmd *cobra.Command, args []string) error { | ||||||
| 			err := config.NewUrfaveCliConfigImplIns(statusImpl.GlobalImpl) | 			err := config.NewCLIConfigImpl(statusImpl.GlobalImpl) | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				return err | 				return err | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
|  | @ -15,7 +15,7 @@ func NewSyncCmd(globalCfg *config.GlobalImpl) *cobra.Command { | ||||||
| 		Use:   "sync", | 		Use:   "sync", | ||||||
| 		Short: "Sync releases defined in state file", | 		Short: "Sync releases defined in state file", | ||||||
| 		RunE: func(cmd *cobra.Command, args []string) error { | 		RunE: func(cmd *cobra.Command, args []string) error { | ||||||
| 			err := config.NewUrfaveCliConfigImplIns(syncImpl.GlobalImpl) | 			err := config.NewCLIConfigImpl(syncImpl.GlobalImpl) | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				return err | 				return err | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
|  | @ -15,7 +15,7 @@ func NewTemplateCmd(globalCfg *config.GlobalImpl) *cobra.Command { | ||||||
| 		Use:   "template", | 		Use:   "template", | ||||||
| 		Short: "Template releases defined in state file", | 		Short: "Template releases defined in state file", | ||||||
| 		RunE: func(cmd *cobra.Command, args []string) error { | 		RunE: func(cmd *cobra.Command, args []string) error { | ||||||
| 			err := config.NewUrfaveCliConfigImplIns(templateImpl.GlobalImpl) | 			err := config.NewCLIConfigImpl(templateImpl.GlobalImpl) | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				return err | 				return err | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
|  | @ -15,7 +15,7 @@ func NewTestCmd(globalCfg *config.GlobalImpl) *cobra.Command { | ||||||
| 		Use:   "test", | 		Use:   "test", | ||||||
| 		Short: "Test charts from state file (helm test)", | 		Short: "Test charts from state file (helm test)", | ||||||
| 		RunE: func(cmd *cobra.Command, args []string) error { | 		RunE: func(cmd *cobra.Command, args []string) error { | ||||||
| 			err := config.NewUrfaveCliConfigImplIns(testImpl.GlobalImpl) | 			err := config.NewCLIConfigImpl(testImpl.GlobalImpl) | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				return err | 				return err | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
|  | @ -15,7 +15,7 @@ func NewWriteValuesCmd(globalCfg *config.GlobalImpl) *cobra.Command { | ||||||
| 		Use:   "write-values", | 		Use:   "write-values", | ||||||
| 		Short: "Write values files for releases. Similar to `helmfile template`, write values files instead of manifests.", | 		Short: "Write values files for releases. Similar to `helmfile template`, write values files instead of manifests.", | ||||||
| 		RunE: func(cmd *cobra.Command, args []string) error { | 		RunE: func(cmd *cobra.Command, args []string) error { | ||||||
| 			err := config.NewUrfaveCliConfigImplIns(writeValuesImpl.GlobalImpl) | 			err := config.NewCLIConfigImpl(writeValuesImpl.GlobalImpl) | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				return err | 				return err | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
|  | @ -1,57 +1,12 @@ | ||||||
| package config | package config | ||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
| 	"fmt" |  | ||||||
| 	"os" |  | ||||||
| 	"strings" | 	"strings" | ||||||
| 
 | 
 | ||||||
| 	"github.com/helmfile/helmfile/pkg/maputil" | 	"github.com/helmfile/helmfile/pkg/maputil" | ||||||
| 	"github.com/helmfile/helmfile/pkg/state" |  | ||||||
| 	"github.com/urfave/cli" |  | ||||||
| 	"go.uber.org/zap" |  | ||||||
| 	"golang.org/x/term" |  | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // nolint: golint
 | func NewCLIConfigImpl(g *GlobalImpl) error { | ||||||
| type ConfigImpl struct { |  | ||||||
| 	c *cli.Context |  | ||||||
| 
 |  | ||||||
| 	set map[string]interface{} |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func NewUrfaveCliConfigImpl(c *cli.Context) (ConfigImpl, error) { |  | ||||||
| 	if c.NArg() > 0 { |  | ||||||
| 		err := cli.ShowAppHelp(c) |  | ||||||
| 		if err != nil { |  | ||||||
| 			return ConfigImpl{}, err |  | ||||||
| 		} |  | ||||||
| 		return ConfigImpl{}, fmt.Errorf("err: extraneous arguments: %s", strings.Join(c.Args(), ", ")) |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	conf := ConfigImpl{ |  | ||||||
| 		c: c, |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	optsSet := c.GlobalStringSlice("state-values-set") |  | ||||||
| 	if len(optsSet) > 0 { |  | ||||||
| 		set := map[string]interface{}{} |  | ||||||
| 		for i := range optsSet { |  | ||||||
| 			ops := strings.Split(optsSet[i], ",") |  | ||||||
| 			for j := range ops { |  | ||||||
| 				op := strings.SplitN(ops[j], "=", 2) |  | ||||||
| 				k := maputil.ParseKey(op[0]) |  | ||||||
| 				v := op[1] |  | ||||||
| 
 |  | ||||||
| 				maputil.Set(set, k, v) |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 		conf.set = set |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	return conf, nil |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func NewUrfaveCliConfigImplIns(g *GlobalImpl) error { |  | ||||||
| 	optsSet := g.RawStateValuesSet() | 	optsSet := g.RawStateValuesSet() | ||||||
| 	if len(optsSet) > 0 { | 	if len(optsSet) > 0 { | ||||||
| 		set := map[string]interface{}{} | 		set := map[string]interface{}{} | ||||||
|  | @ -70,249 +25,3 @@ func NewUrfaveCliConfigImplIns(g *GlobalImpl) error { | ||||||
| 
 | 
 | ||||||
| 	return nil | 	return nil | ||||||
| } | } | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) Set() []string { |  | ||||||
| 	return c.c.StringSlice("set") |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) SkipRepos() bool { |  | ||||||
| 	return c.c.Bool("skip-repos") |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) Wait() bool { |  | ||||||
| 	return c.c.Bool("wait") |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) WaitForJobs() bool { |  | ||||||
| 	return c.c.Bool("wait-for-jobs") |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) Values() []string { |  | ||||||
| 	return c.c.StringSlice("values") |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) Args() string { |  | ||||||
| 	args := c.c.String("args") |  | ||||||
| 	enableHelmDebug := c.c.GlobalBool("debug") |  | ||||||
| 
 |  | ||||||
| 	if enableHelmDebug { |  | ||||||
| 		args = fmt.Sprintf("%s %s", args, "--debug") |  | ||||||
| 	} |  | ||||||
| 	return args |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) OutputDir() string { |  | ||||||
| 	return strings.TrimRight(c.c.String("output-dir"), fmt.Sprintf("%c", os.PathSeparator)) |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) OutputDirTemplate() string { |  | ||||||
| 	return c.c.String("output-dir-template") |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) OutputFileTemplate() string { |  | ||||||
| 	return c.c.String("output-file-template") |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) Validate() bool { |  | ||||||
| 	return c.c.Bool("validate") |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) Concurrency() int { |  | ||||||
| 	return c.c.Int("concurrency") |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) HasCommandName(name string) bool { |  | ||||||
| 	return c.c.Command.HasName(name) |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) SkipNeeds() bool { |  | ||||||
| 	if !c.IncludeNeeds() { |  | ||||||
| 		return c.c.Bool("skip-needs") |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	return false |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) IncludeNeeds() bool { |  | ||||||
| 	return c.c.Bool("include-needs") || c.IncludeTransitiveNeeds() |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) IncludeTransitiveNeeds() bool { |  | ||||||
| 	return c.c.Bool("include-transitive-needs") |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| // DiffConfig
 |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) SkipDeps() bool { |  | ||||||
| 	return c.c.Bool("skip-deps") |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) DetailedExitcode() bool { |  | ||||||
| 	return c.c.Bool("detailed-exitcode") |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) RetainValuesFiles() bool { |  | ||||||
| 	return c.c.Bool("retain-values-files") |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) IncludeTests() bool { |  | ||||||
| 	return c.c.Bool("include-tests") |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) Suppress() []string { |  | ||||||
| 	return c.c.StringSlice("suppress") |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) SuppressSecrets() bool { |  | ||||||
| 	return c.c.Bool("suppress-secrets") |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) ShowSecrets() bool { |  | ||||||
| 	return c.c.Bool("show-secrets") |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) SuppressDiff() bool { |  | ||||||
| 	return c.c.Bool("suppress-diff") |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| // DeleteConfig
 |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) Purge() bool { |  | ||||||
| 	return c.c.Bool("purge") |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| // TestConfig
 |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) Cleanup() bool { |  | ||||||
| 	return c.c.Bool("cleanup") |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) Logs() bool { |  | ||||||
| 	return c.c.Bool("logs") |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) Timeout() int { |  | ||||||
| 	if !c.c.IsSet("timeout") { |  | ||||||
| 		return state.EmptyTimeout |  | ||||||
| 	} |  | ||||||
| 	return c.c.Int("timeout") |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| // ListConfig
 |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) Output() string { |  | ||||||
| 	return c.c.String("output") |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) KeepTempDir() bool { |  | ||||||
| 	return c.c.Bool("keep-temp-dir") |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| // GlobalConfig
 |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) HelmBinary() string { |  | ||||||
| 	return c.c.GlobalString("helm-binary") |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) KubeContext() string { |  | ||||||
| 	return c.c.GlobalString("kube-context") |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) Namespace() string { |  | ||||||
| 	return c.c.GlobalString("namespace") |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) Chart() string { |  | ||||||
| 	return c.c.GlobalString("chart") |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) FileOrDir() string { |  | ||||||
| 	return c.c.GlobalString("file") |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) Selectors() []string { |  | ||||||
| 	return c.c.GlobalStringSlice("selector") |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) StateValuesSet() map[string]interface{} { |  | ||||||
| 	return c.set |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) StateValuesFiles() []string { |  | ||||||
| 	return c.c.GlobalStringSlice("state-values-file") |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) Interactive() bool { |  | ||||||
| 	return c.c.GlobalBool("interactive") |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) Color() bool { |  | ||||||
| 	if c := c.c.GlobalBool("color"); c { |  | ||||||
| 		return c |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	if c.NoColor() { |  | ||||||
| 		return false |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	// We replicate the helm-diff behavior in helmfile
 |  | ||||||
| 	// because when when helmfile calls helm-diff, helm-diff has no access to term and therefore
 |  | ||||||
| 	// we can't rely on helm-diff's ability to auto-detect term for color output.
 |  | ||||||
| 	// See https://github.com/roboll/helmfile/issues/2043
 |  | ||||||
| 
 |  | ||||||
| 	terminal := term.IsTerminal(int(os.Stdout.Fd())) |  | ||||||
| 	// https://github.com/databus23/helm-diff/issues/281
 |  | ||||||
| 	dumb := os.Getenv("TERM") == "dumb" |  | ||||||
| 	return terminal && !dumb |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) NoColor() bool { |  | ||||||
| 	return c.c.GlobalBool("no-color") |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) Context() int { |  | ||||||
| 	return c.c.Int("context") |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) DiffOutput() string { |  | ||||||
| 	return c.c.String("output") |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| 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") |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) EmbedValues() bool { |  | ||||||
| 	return c.c.Bool("embed-values") |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) IncludeCRDs() bool { |  | ||||||
| 	return c.c.Bool("include-crds") |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) SkipTests() bool { |  | ||||||
| 	return c.c.Bool("skip-tests") |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) Logger() *zap.SugaredLogger { |  | ||||||
| 	return c.c.App.Metadata["logger"].(*zap.SugaredLogger) |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func (c ConfigImpl) Env() string { |  | ||||||
| 	env := c.c.GlobalString("environment") |  | ||||||
| 	if env == "" { |  | ||||||
| 		env = os.Getenv("HELMFILE_ENVIRONMENT") |  | ||||||
| 		if env == "" { |  | ||||||
| 			env = state.DefaultEnv |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	return env |  | ||||||
| } |  | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue