feat: add/expose cli flags (#771)

* feat: add/expose cli flags

Signed-off-by: Hans Song <hans.m.song@gmail.com>

* fix tests

Signed-off-by: Hans Song <hans.m.song@gmail.com>

* remove skipdeps from subcommand options

Signed-off-by: Hans Song <hans.m.song@gmail.com>

* remove skip-deps from subcommand flags

Signed-off-by: Hans Song <hans.m.song@gmail.com>

* remove SkipDeps from subcommand implementations

Signed-off-by: Hans Song <hans.m.song@gmail.com>

* update doco with new flags

Signed-off-by: Hans Song <hans.m.song@gmail.com>

---------

Signed-off-by: Hans Song <hans.m.song@gmail.com>
This commit is contained in:
Hans Song 2023-04-02 16:53:52 +10:00 committed by GitHub
parent fe1eba60db
commit 1d0ba72b47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 98 additions and 103 deletions

View File

@ -59,7 +59,6 @@ func NewApplyCmd(globalCfg *config.GlobalImpl) *cobra.Command {
f.BoolVar(&applyOptions.ShowSecrets, "show-secrets", false, "do not redact secret values in the diff output. should be used for debug purpose only") f.BoolVar(&applyOptions.ShowSecrets, "show-secrets", false, "do not redact secret values in the diff output. should be used for debug purpose only")
f.BoolVar(&applyOptions.NoHooks, "no-hooks", false, "do not diff changes made by hooks.") 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.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.BoolVar(&applyOptions.Wait, "wait", false, `Override helmDefaults.wait setting "helm upgrade --install --wait"`) 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"`) f.BoolVar(&applyOptions.WaitForJobs, "wait-for-jobs", false, `Override helmDefaults.waitForJobs setting "helm upgrade --install --wait-for-jobs"`)
f.BoolVar(&applyOptions.ReuseValues, "reuse-values", false, `Override helmDefaults.reuseValues "helm upgrade --install --reuse-values"`) f.BoolVar(&applyOptions.ReuseValues, "reuse-values", false, `Override helmDefaults.reuseValues "helm upgrade --install --reuse-values"`)

View File

@ -35,7 +35,6 @@ func NewDeleteCmd(globalCfg *config.GlobalImpl) *cobra.Command {
f.StringVar(&globalCfg.GlobalOptions.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.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.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.BoolVar(&deleteOptions.SkipCharts, "skip-charts", false, "don't prepare charts when deleting releases") f.BoolVar(&deleteOptions.SkipCharts, "skip-charts", false, "don't prepare charts when deleting releases")
return cmd return cmd

View File

@ -33,7 +33,6 @@ func NewDestroyCmd(globalCfg *config.GlobalImpl) *cobra.Command {
f := cmd.Flags() f := cmd.Flags()
f.StringVar(&globalCfg.GlobalOptions.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.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.BoolVar(&destroyOptions.SkipCharts, "skip-charts", false, "don't prepare charts when destroying releases") f.BoolVar(&destroyOptions.SkipCharts, "skip-charts", false, "don't prepare charts when destroying releases")
return cmd return cmd

View File

@ -40,7 +40,6 @@ func NewDiffCmd(globalCfg *config.GlobalImpl) *cobra.Command {
f.BoolVar(&diffOptions.IncludeTests, "include-tests", false, "enable the diffing of the helm test hooks") f.BoolVar(&diffOptions.IncludeTests, "include-tests", false, "enable the diffing of the helm test hooks")
f.BoolVar(&diffOptions.IncludeNeeds, "include-needs", false, `automatically include releases from the target release's "needs" when --selector/-l flag is provided. Does nothing when --selector/-l flag is not provided`) f.BoolVar(&diffOptions.IncludeNeeds, "include-needs", false, `automatically include releases from the target release's "needs" when --selector/-l flag is provided. Does nothing when --selector/-l flag is not provided`)
f.BoolVar(&diffOptions.IncludeTransitiveNeeds, "include-transitive-needs", false, `like --include-needs, but also includes transitive needs (needs of needs). Does nothing when --selector/-l flag is not provided. Overrides exclusions of other selectors and conditions.`) f.BoolVar(&diffOptions.IncludeTransitiveNeeds, "include-transitive-needs", false, `like --include-needs, but also includes transitive needs (needs of needs). Does nothing when --selector/-l flag is not provided. Overrides exclusions of other selectors and conditions.`)
f.BoolVar(&diffOptions.SkipDeps, "skip-deps", false, `skip running "helm repo update" and "helm dependency build"`)
f.BoolVar(&diffOptions.SkipDiffOnInstall, "skip-diff-on-install", false, "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") f.BoolVar(&diffOptions.SkipDiffOnInstall, "skip-diff-on-install", false, "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")
f.BoolVar(&diffOptions.ShowSecrets, "show-secrets", false, "do not redact secret values in the output. should be used for debug purpose only") f.BoolVar(&diffOptions.ShowSecrets, "show-secrets", false, "do not redact secret values in the output. should be used for debug purpose only")
f.BoolVar(&diffOptions.NoHooks, "no-hooks", false, "do not diff changes made by hooks.") f.BoolVar(&diffOptions.NoHooks, "no-hooks", false, "do not diff changes made by hooks.")

View File

@ -33,7 +33,6 @@ func NewFetchCmd(globalCfg *config.GlobalImpl) *cobra.Command {
f := cmd.Flags() f := cmd.Flags()
f.IntVar(&fetchOptions.Concurrency, "concurrency", 0, "maximum number of concurrent helm processes to run, 0 is unlimited") f.IntVar(&fetchOptions.Concurrency, "concurrency", 0, "maximum number of concurrent helm processes to run, 0 is unlimited")
f.BoolVar(&fetchOptions.SkipDeps, "skip-deps", false, `skip running "helm repo update" and "helm dependency build"`)
f.StringVar(&fetchOptions.OutputDir, "output-dir", "", "directory to store charts (default: temporary directory which is deleted when the command terminates)") f.StringVar(&fetchOptions.OutputDir, "output-dir", "", "directory to store charts (default: temporary directory which is deleted when the command terminates)")
f.StringVar(&fetchOptions.OutputDirTemplate, "output-dir-template", state.DefaultFetchOutputDirTemplate, "go text template for generating the output directory") f.StringVar(&fetchOptions.OutputDirTemplate, "output-dir-template", state.DefaultFetchOutputDirTemplate, "go text template for generating the output directory")

View File

@ -32,7 +32,6 @@ func NewLintCmd(globalCfg *config.GlobalImpl) *cobra.Command {
f := cmd.Flags() f := cmd.Flags()
f.IntVar(&lintOptions.Concurrency, "concurrency", 0, "maximum number of concurrent helm processes to run, 0 is unlimited") 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(&globalCfg.GlobalOptions.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 helm command --set flag") f.StringArrayVar(&lintOptions.Set, "set", nil, "additional values to be merged into the helm command --set flag")
f.StringArrayVar(&lintOptions.Values, "values", nil, "additional value files to be merged into the helm command --values flag") f.StringArrayVar(&lintOptions.Values, "values", nil, "additional value files to be merged into the helm command --values flag")

View File

@ -119,6 +119,8 @@ func setGlobalOptionsForRootCmd(fs *pflag.FlagSet, globalOptions *config.GlobalO
fs.StringVarP(&globalOptions.Environment, "environment", "e", "", `specify the environment name. defaults to "default"`) fs.StringVarP(&globalOptions.Environment, "environment", "e", "", `specify the environment name. defaults to "default"`)
fs.StringArrayVar(&globalOptions.StateValuesSet, "state-values-set", nil, "set state values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2). Used to override .Values within the helmfile template (not values template).") fs.StringArrayVar(&globalOptions.StateValuesSet, "state-values-set", nil, "set state values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2). Used to override .Values within the helmfile template (not values template).")
fs.StringArrayVar(&globalOptions.StateValuesFile, "state-values-file", nil, "specify state values in a YAML file. Used to override .Values within the helmfile template (not values template).") fs.StringArrayVar(&globalOptions.StateValuesFile, "state-values-file", nil, "specify state values in a YAML file. Used to override .Values within the helmfile template (not values template).")
fs.BoolVar(&globalOptions.SkipDeps, "skip-deps", false, `skip running "helm repo update" and "helm dependency build"`)
fs.BoolVar(&globalOptions.DisableForceUpdate, "disable-force-update", false, `do not force helm repos to update when executing "helm repo add"`)
fs.BoolVarP(&globalOptions.Quiet, "quiet", "q", false, "Silence output. Equivalent to log-level warn") fs.BoolVarP(&globalOptions.Quiet, "quiet", "q", false, "Silence output. Equivalent to log-level warn")
fs.StringVar(&globalOptions.KubeContext, "kube-context", "", "Set kubectl context. Uses current context by default") fs.StringVar(&globalOptions.KubeContext, "kube-context", "", "Set kubectl context. Uses current context by default")
fs.BoolVar(&globalOptions.Debug, "debug", false, "Enable verbose output for Helm and set log-level to debug, this disables --quiet/-q effect") fs.BoolVar(&globalOptions.Debug, "debug", false, "Enable verbose output for Helm and set log-level to debug, this disables --quiet/-q effect")

View File

@ -40,7 +40,6 @@ func NewSyncCmd(globalCfg *config.GlobalImpl) *cobra.Command {
f.BoolVar(&syncOptions.SkipCRDs, "skip-crds", false, "if set, no CRDs will be installed on sync. By default, CRDs are installed if not already present") f.BoolVar(&syncOptions.SkipCRDs, "skip-crds", false, "if set, no CRDs will be installed on sync. By default, CRDs are installed if not already present")
f.BoolVar(&syncOptions.IncludeNeeds, "include-needs", false, `automatically include releases from the target release's "needs" when --selector/-l flag is provided. Does nothing when --selector/-l flag is not provided`) f.BoolVar(&syncOptions.IncludeNeeds, "include-needs", false, `automatically include releases from the target release's "needs" when --selector/-l flag is provided. Does nothing when --selector/-l flag is not provided`)
f.BoolVar(&syncOptions.IncludeTransitiveNeeds, "include-transitive-needs", false, `like --include-needs, but also includes transitive needs (needs of needs). Does nothing when --selector/-l flag is not provided. Overrides exclusions of other selectors and conditions.`) f.BoolVar(&syncOptions.IncludeTransitiveNeeds, "include-transitive-needs", false, `like --include-needs, but also includes transitive needs (needs of needs). Does nothing when --selector/-l flag is not provided. Overrides exclusions of other selectors and conditions.`)
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.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.BoolVar(&syncOptions.WaitForJobs, "wait-for-jobs", false, `Override helmDefaults.waitForJobs setting "helm upgrade --install --wait-for-jobs"`)
f.BoolVar(&syncOptions.ReuseValues, "reuse-values", false, `Override helmDefaults.reuseValues "helm upgrade --install --reuse-values"`) f.BoolVar(&syncOptions.ReuseValues, "reuse-values", false, `Override helmDefaults.reuseValues "helm upgrade --install --reuse-values"`)

View File

@ -43,7 +43,6 @@ func NewTemplateCmd(globalCfg *config.GlobalImpl) *cobra.Command {
f.BoolVar(&templateOptions.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`) f.BoolVar(&templateOptions.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`)
f.BoolVar(&templateOptions.IncludeNeeds, "include-needs", false, `automatically include releases from the target release's "needs" when --selector/-l flag is provided. Does nothing when --selector/-l flag is not provided`) f.BoolVar(&templateOptions.IncludeNeeds, "include-needs", false, `automatically include releases from the target release's "needs" when --selector/-l flag is provided. Does nothing when --selector/-l flag is not provided`)
f.BoolVar(&templateOptions.IncludeTransitiveNeeds, "include-transitive-needs", false, `like --include-needs, but also includes transitive needs (needs of needs). Does nothing when --selector/-l flag is not provided. Overrides exclusions of other selectors and conditions.`) f.BoolVar(&templateOptions.IncludeTransitiveNeeds, "include-transitive-needs", false, `like --include-needs, but also includes transitive needs (needs of needs). Does nothing when --selector/-l flag is not provided. Overrides exclusions of other selectors and conditions.`)
f.BoolVar(&templateOptions.SkipDeps, "skip-deps", false, `skip running "helm repo update" and "helm dependency build"`)
f.BoolVar(&templateOptions.SkipCleanup, "skip-cleanup", false, "Stop cleaning up temporary values generated by helmfile and helm-secrets. Useful for debugging. Don't use in production for security") f.BoolVar(&templateOptions.SkipCleanup, "skip-cleanup", false, "Stop cleaning up temporary values generated by helmfile and helm-secrets. Useful for debugging. Don't use in production for security")
f.StringVar(&templateOptions.PostRenderer, "post-renderer", "", `pass --post-renderer to "helm template" or "helm upgrade --install"`) f.StringVar(&templateOptions.PostRenderer, "post-renderer", "", `pass --post-renderer to "helm template" or "helm upgrade --install"`)

View File

@ -33,7 +33,6 @@ func NewTestCmd(globalCfg *config.GlobalImpl) *cobra.Command {
f := cmd.Flags() f := cmd.Flags()
f.IntVar(&testOptions.Concurrency, "concurrency", 0, "maximum number of concurrent helm processes to run, 0 is unlimited") f.IntVar(&testOptions.Concurrency, "concurrency", 0, "maximum number of concurrent helm processes to run, 0 is unlimited")
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.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.BoolVar(&testOptions.Logs, "logs", false, "Dump the logs from test pods (this runs after all tests are complete, but before any cleanup)")
f.StringVar(&globalCfg.GlobalOptions.Args, "args", "", "pass args to helm exec") f.StringVar(&globalCfg.GlobalOptions.Args, "args", "", "pass args to helm exec")

View File

@ -32,7 +32,6 @@ func NewWriteValuesCmd(globalCfg *config.GlobalImpl) *cobra.Command {
f := cmd.Flags() f := cmd.Flags()
f.IntVar(&writeValuesOptions.Concurrency, "concurrency", 0, "maximum number of concurrent helm processes to run, 0 is unlimited") f.IntVar(&writeValuesOptions.Concurrency, "concurrency", 0, "maximum number of concurrent helm processes to run, 0 is unlimited")
f.BoolVar(&writeValuesOptions.SkipDeps, "skip-deps", false, `skip running "helm repo update" and "helm dependency build"`)
f.StringArrayVar(&writeValuesOptions.Set, "set", nil, "additional values to be merged into the helm command --set flag") f.StringArrayVar(&writeValuesOptions.Set, "set", nil, "additional values to be merged into the helm command --set flag")
f.StringArrayVar(&writeValuesOptions.Values, "values", nil, "additional value files to be merged into the helm command --values flag") f.StringArrayVar(&writeValuesOptions.Values, "values", nil, "additional value files to be merged into the helm command --values flag")
f.StringVar(&writeValuesOptions.OutputFileTemplate, "output-file-template", "", "go text template for generating the output file. Default: {{ .State.BaseName }}-{{ .State.AbsPathSHA1 }}/{{ .Release.Name}}.yaml") f.StringVar(&writeValuesOptions.OutputFileTemplate, "output-file-template", "", "go text template for generating the output file. Default: {{ .State.BaseName }}-{{ .State.AbsPathSHA1 }}/{{ .Release.Name}}.yaml")

View File

@ -537,6 +537,7 @@ Flags:
-c, --chart string Set chart. Uses the chart set in release by default, and is available in template as {{ .Chart }} -c, --chart string Set chart. Uses the chart set in release by default, and is available in template as {{ .Chart }}
--color Output with color --color Output with color
--debug Enable verbose output for Helm and set log-level to debug, this disables --quiet/-q effect --debug Enable verbose output for Helm and set log-level to debug, this disables --quiet/-q effect
--disable-force-update do not force helm repos to update when executing "helm repo add"
--enable-live-output Show live output from the Helm binary Stdout/Stderr into Helmfile own Stdout/Stderr. --enable-live-output 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. It only applies for the Helm CLI commands, Stdout/Stderr for Hooks are still displayed only when it's execution finishes.
-e, --environment string specify the environment name. defaults to "default" -e, --environment string specify the environment name. defaults to "default"
@ -553,6 +554,7 @@ Flags:
A release must match all labels in a group in order to be used. Multiple groups can be specified at once. A release must match all labels in a group in order to be used. Multiple groups can be specified at once.
"--selector tier=frontend,tier!=proxy --selector tier=backend" will match all frontend, non-proxy releases AND all backend releases. "--selector tier=frontend,tier!=proxy --selector tier=backend" will match all frontend, non-proxy releases AND all backend releases.
The name of a release can be used as a label: "--selector name=myrelease" The name of a release can be used as a label: "--selector name=myrelease"
--skip-deps skip running "helm repo update" and "helm dependency build"
--state-values-file stringArray specify state values in a YAML file. Used to override .Values within the helmfile template (not values template). --state-values-file stringArray specify state values in a YAML file. Used to override .Values within the helmfile template (not values template).
--state-values-set stringArray set state values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2). Used to override .Values within the helmfile template (not values template). --state-values-set stringArray set state values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2). Used to override .Values within the helmfile template (not values template).
-v, --version version for helmfile -v, --version version for helmfile

View File

@ -29,6 +29,7 @@ type App struct {
OverrideKubeContext string OverrideKubeContext string
OverrideHelmBinary string OverrideHelmBinary string
EnableLiveOutput bool EnableLiveOutput bool
DisableForceUpdate bool
Logger *zap.SugaredLogger Logger *zap.SugaredLogger
Env string Env string
@ -66,6 +67,7 @@ func New(conf ConfigProvider) *App {
OverrideKubeContext: conf.KubeContext(), OverrideKubeContext: conf.KubeContext(),
OverrideHelmBinary: conf.HelmBinary(), OverrideHelmBinary: conf.HelmBinary(),
EnableLiveOutput: conf.EnableLiveOutput(), EnableLiveOutput: conf.EnableLiveOutput(),
DisableForceUpdate: conf.DisableForceUpdate(),
Logger: conf.Logger(), Logger: conf.Logger(),
Env: conf.Env(), Env: conf.Env(),
Namespace: conf.Namespace(), Namespace: conf.Namespace(),
@ -784,7 +786,7 @@ func (a *App) getHelm(st *state.HelmState) helmexec.Interface {
key := createHelmKey(bin, kubectx) key := createHelmKey(bin, kubectx)
if _, ok := a.helms[key]; !ok { if _, ok := a.helms[key]; !ok {
a.helms[key] = helmexec.New(bin, a.EnableLiveOutput, a.Logger, kubectx, &helmexec.ShellRunner{ a.helms[key] = helmexec.New(bin, helmexec.HelmExecOptions{EnableLiveOutput: a.EnableLiveOutput, DisableForceUpdate: a.DisableForceUpdate}, a.Logger, kubectx, &helmexec.ShellRunner{
Logger: a.Logger, Logger: a.Logger,
}) })
} }

View File

@ -2396,7 +2396,7 @@ func (mock *mockRunner) Execute(cmd string, args []string, env map[string]string
} }
func MockExecer(logger *zap.SugaredLogger, kubeContext string) helmexec.Interface { func MockExecer(logger *zap.SugaredLogger, kubeContext string) helmexec.Interface {
execer := helmexec.New("helm", false, logger, kubeContext, &mockRunner{}) execer := helmexec.New("helm", helmexec.HelmExecOptions{}, logger, kubeContext, &mockRunner{})
return execer return execer
} }
@ -2446,6 +2446,9 @@ func (helm *mockHelmExec) SetHelmBinary(bin string) {
func (helm *mockHelmExec) SetEnableLiveOutput(enableLiveOutput bool) { func (helm *mockHelmExec) SetEnableLiveOutput(enableLiveOutput bool) {
} }
func (helm *mockHelmExec) SetDisableForceUpdate(forceUpdate bool) {
}
func (helm *mockHelmExec) AddRepo(name, repository, cafile, certfile, keyfile, username, password string, managed string, passCredentials string, skipTLSVerify string) error { func (helm *mockHelmExec) AddRepo(name, repository, cafile, certfile, keyfile, username, password string, managed string, passCredentials string, skipTLSVerify string) error {
helm.repos = append(helm.repos, mockRepo{Name: name}) helm.repos = append(helm.repos, mockRepo{Name: name})
return nil return nil

View File

@ -6,6 +6,8 @@ type ConfigProvider interface {
Args() string Args() string
HelmBinary() string HelmBinary() string
EnableLiveOutput() bool EnableLiveOutput() bool
DisableForceUpdate() bool
SkipDeps() bool
FileOrDir() string FileOrDir() string
KubeContext() string KubeContext() string

View File

@ -163,7 +163,7 @@ func (h *HelmfileInit) WhetherContinue(ask string) error {
func (h *HelmfileInit) CheckHelmPlugins() error { func (h *HelmfileInit) CheckHelmPlugins() error {
settings := cli.New() settings := cli.New()
helm := helmexec.New(h.helmBinary, false, h.logger, "", h.runner) helm := helmexec.New(h.helmBinary, helmexec.HelmExecOptions{}, h.logger, "", h.runner)
for _, p := range helmPlugins { for _, p := range helmPlugins {
pluginVersion, err := helmexec.GetPluginVersion(p.name, settings.PluginsDirectory) pluginVersion, err := helmexec.GetPluginVersion(p.name, settings.PluginsDirectory)
if err != nil { if err != nil {

View File

@ -53,6 +53,9 @@ func (helm *noCallHelmExec) SetHelmBinary(bin string) {
func (helm *noCallHelmExec) SetEnableLiveOutput(enableLiveOutput bool) { func (helm *noCallHelmExec) SetEnableLiveOutput(enableLiveOutput bool) {
helm.doPanic() helm.doPanic()
} }
func (helm *noCallHelmExec) SetDisableForceUpdate(forceUpdate bool) {
helm.doPanic()
}
func (helm *noCallHelmExec) AddRepo(name, repository, cafile, certfile, keyfile, username, password string, managed string, passCredentials string, skipTLSVerify string) error { func (helm *noCallHelmExec) AddRepo(name, repository, cafile, certfile, keyfile, username, password string, managed string, passCredentials string, skipTLSVerify string) error {
helm.doPanic() helm.doPanic()

View File

@ -39,14 +39,12 @@ type ApplyOptions struct {
Suppress []string Suppress []string
// SuppressSecrets is true if the secrets should be suppressed // SuppressSecrets is true if the secrets should be suppressed
SuppressSecrets bool SuppressSecrets bool
// SuppressDiff is true if the diff should be suppressed // ShowSecrets is true if the secrets should be shown
ShowSecrets bool ShowSecrets bool
// NoHooks skips checking for hooks // NoHooks skips checking for hooks
NoHooks bool NoHooks bool
// SkipDeps is true if the running "helm repo update" and "helm dependency build" should be skipped // SuppressDiff is true if the diff should be suppressed
SuppressDiff bool SuppressDiff bool
// ShowSecrets is true if the secrets should be shown
SkipDeps bool
// Wait is true if the helm command should wait for the release to be deployed // Wait is true if the helm command should wait for the release to be deployed
Wait bool Wait bool
// WaitForJobs is true if the helm command should wait for the jobs to be completed // WaitForJobs is true if the helm command should wait for the jobs to be completed
@ -144,11 +142,6 @@ func (a *ApplyImpl) SkipCleanup() bool {
return a.ApplyOptions.SkipCleanup return a.ApplyOptions.SkipCleanup
} }
// SkipDeps returns the skip deps.
func (a *ApplyImpl) SkipDeps() bool {
return a.ApplyOptions.SkipDeps
}
// SkipDiffOnInstall returns the skip diff on install. // SkipDiffOnInstall returns the skip diff on install.
func (a *ApplyImpl) SkipDiffOnInstall() bool { func (a *ApplyImpl) SkipDiffOnInstall() bool {
return a.ApplyOptions.SkipDiffOnInstall return a.ApplyOptions.SkipDiffOnInstall

View File

@ -7,8 +7,6 @@ type DeleteOptions struct {
Concurrency int Concurrency int
// Purge is the purge flag // Purge is the purge flag
Purge bool Purge bool
// SkipDeps is the skip deps flag
SkipDeps bool
// SkipCharts makes Delete skip `withPreparedCharts` // SkipCharts makes Delete skip `withPreparedCharts`
SkipCharts bool SkipCharts bool
} }
@ -42,11 +40,6 @@ func (c *DeleteImpl) Purge() bool {
return c.DeleteOptions.Purge return c.DeleteOptions.Purge
} }
// SkipDeps returns the skip deps
func (c *DeleteImpl) SkipDeps() bool {
return c.DeleteOptions.SkipDeps
}
// SkipCharts returns skipCharts flag // SkipCharts returns skipCharts flag
func (c *DeleteImpl) SkipCharts() bool { func (c *DeleteImpl) SkipCharts() bool {
return c.DeleteOptions.SkipCharts return c.DeleteOptions.SkipCharts

View File

@ -4,8 +4,6 @@ package config
type DestroyOptions struct { type DestroyOptions struct {
// Concurrency is the maximum number of concurrent helm processes to run, 0 is unlimited // Concurrency is the maximum number of concurrent helm processes to run, 0 is unlimited
Concurrency int Concurrency int
// SkipDeps is the skip deps flag
SkipDeps bool
// SkipCharts makes Destroy skip `withPreparedCharts` // SkipCharts makes Destroy skip `withPreparedCharts`
SkipCharts bool SkipCharts bool
} }
@ -34,11 +32,6 @@ func (c *DestroyImpl) Concurrency() int {
return c.DestroyOptions.Concurrency return c.DestroyOptions.Concurrency
} }
// SkipDeps returns the skip deps
func (c *DestroyImpl) SkipDeps() bool {
return c.DestroyOptions.SkipDeps
}
// SkipCharts returns skipCharts flag // SkipCharts returns skipCharts flag
func (c *DestroyImpl) SkipCharts() bool { func (c *DestroyImpl) SkipCharts() bool {
return c.DestroyOptions.SkipCharts return c.DestroyOptions.SkipCharts

View File

@ -6,8 +6,6 @@ type DiffOptions struct {
Set []string Set []string
// Values is the values flag // Values is the values flag
Values []string Values []string
// SkipDeps is the skip deps flag
SkipDeps bool
// DetailedExitcode is the detailed exit code // DetailedExitcode is the detailed exit code
DetailedExitcode bool DetailedExitcode bool
// IncludeTests is the include tests flag // IncludeTests is the include tests flag
@ -83,11 +81,6 @@ func (t *DiffImpl) Set() []string {
return t.DiffOptions.Set return t.DiffOptions.Set
} }
// SkipDeps returns the skip deps
func (t *DiffImpl) SkipDeps() bool {
return t.DiffOptions.SkipDeps
}
// SkipNeeds returns the skip needs // SkipNeeds returns the skip needs
func (t *DiffImpl) SkipNeeds() bool { func (t *DiffImpl) SkipNeeds() bool {
if !t.IncludeNeeds() { if !t.IncludeNeeds() {

View File

@ -4,8 +4,6 @@ package config
type FetchOptions struct { type FetchOptions struct {
// Concurrency is the maximum number of concurrent helm processes to run, 0 is unlimited // Concurrency is the maximum number of concurrent helm processes to run, 0 is unlimited
Concurrency int Concurrency int
// SkipDeps is the skip deps flag
SkipDeps bool
// OutputDir is the output directory // OutputDir is the output directory
OutputDir string OutputDir string
// OutputDirTemplate is the go template to generate the path of output directory // OutputDirTemplate is the go template to generate the path of output directory
@ -36,11 +34,6 @@ func (c *FetchImpl) Concurrency() int {
return c.FetchOptions.Concurrency return c.FetchOptions.Concurrency
} }
// SkipDeps returns the skip deps
func (c *FetchImpl) SkipDeps() bool {
return c.FetchOptions.SkipDeps
}
// OutputDir returns the args // OutputDir returns the args
func (c *FetchImpl) OutputDir() string { func (c *FetchImpl) OutputDir() string {
return c.FetchOptions.OutputDir return c.FetchOptions.OutputDir

View File

@ -23,6 +23,10 @@ type GlobalOptions struct {
StateValuesSet []string StateValuesSet []string
// StateValuesFiles is a list of state values files to use. // StateValuesFiles is a list of state values files to use.
StateValuesFile []string StateValuesFile []string
// SkipDeps is true if the running "helm repo update" and "helm dependency build" should be skipped
SkipDeps bool
// DisableForceUpdate is true if force updating repos is not desirable when executing "helm repo add"
DisableForceUpdate bool
// Quiet is true if the output should be quiet. // Quiet is true if the output should be quiet.
Quiet bool Quiet bool
// KubeContext is the name of the kubectl context to use. // KubeContext is the name of the kubectl context to use.
@ -132,6 +136,16 @@ func (g *GlobalImpl) EnableLiveOutput() bool {
return g.GlobalOptions.EnableLiveOutput return g.GlobalOptions.EnableLiveOutput
} }
// SkipDeps return if running "helm repo update" and "helm dependency build" should be skipped
func (g *GlobalImpl) SkipDeps() bool {
return g.GlobalOptions.SkipDeps
}
// DisableForceUpdate return when to disable forcing updates to repos upon adding
func (g *GlobalImpl) DisableForceUpdate() bool {
return g.GlobalOptions.DisableForceUpdate
}
// Logger returns the logger // Logger returns the logger
func (g *GlobalImpl) Logger() *zap.SugaredLogger { func (g *GlobalImpl) Logger() *zap.SugaredLogger {
return g.GlobalOptions.logger return g.GlobalOptions.logger

View File

@ -4,8 +4,6 @@ package config
type LintOptions struct { type LintOptions struct {
// Concurrency is the maximum number of concurrent helm processes to run, 0 is unlimited // Concurrency is the maximum number of concurrent helm processes to run, 0 is unlimited
Concurrency int Concurrency int
// SkipDeps is the skip deps flag
SkipDeps bool
// Set is the set flags to pass to helm lint // Set is the set flags to pass to helm lint
Set []string Set []string
// Values is the values flags to pass to helm lint // Values is the values flags to pass to helm lint
@ -43,11 +41,6 @@ func (l *LintImpl) Concurrency() int {
return l.LintOptions.Concurrency return l.LintOptions.Concurrency
} }
// SkipDeps returns the skip deps
func (l *LintImpl) SkipDeps() bool {
return l.LintOptions.SkipDeps
}
// Set returns the Set // Set returns the Set
func (l *LintImpl) Set() []string { func (l *LintImpl) Set() []string {
return l.LintOptions.Set return l.LintOptions.Set

View File

@ -16,8 +16,6 @@ type SyncOptions struct {
IncludeNeeds bool IncludeNeeds bool
// IncludeTransitiveNeeds is the include transitive needs flag // IncludeTransitiveNeeds is the include transitive needs flag
IncludeTransitiveNeeds bool IncludeTransitiveNeeds bool
// SkipDeps is the skip deps flag
SkipDeps bool
// SkipCrds is the skip crds flag // SkipCrds is the skip crds flag
SkipCRDs bool SkipCRDs bool
// Wait is the wait flag // Wait is the wait flag
@ -71,11 +69,6 @@ func (t *SyncImpl) Set() []string {
return t.SyncOptions.Set return t.SyncOptions.Set
} }
// SkipDeps returns the skip deps
func (t *SyncImpl) SkipDeps() bool {
return t.SyncOptions.SkipDeps
}
// SkipNeeds returns the skip needs // SkipNeeds returns the skip needs
func (t *SyncImpl) SkipNeeds() bool { func (t *SyncImpl) SkipNeeds() bool {
if !t.IncludeNeeds() { if !t.IncludeNeeds() {

View File

@ -30,8 +30,6 @@ type TemplateOptions struct {
IncludeNeeds bool IncludeNeeds bool
// IncludeTransitiveNeeds is the include transitive needs flag // IncludeTransitiveNeeds is the include transitive needs flag
IncludeTransitiveNeeds bool IncludeTransitiveNeeds bool
// SkipDeps is the skip deps flag
SkipDeps bool
// SkipCleanup is the skip cleanup flag // SkipCleanup is the skip cleanup flag
SkipCleanup bool SkipCleanup bool
// Propagate '--post-renderer' to helmv3 template and helm install // Propagate '--post-renderer' to helmv3 template and helm install
@ -97,11 +95,6 @@ func (t *TemplateImpl) SkipCleanup() bool {
return t.TemplateOptions.SkipCleanup return t.TemplateOptions.SkipCleanup
} }
// SkipDeps returns the skip deps
func (t *TemplateImpl) SkipDeps() bool {
return t.TemplateOptions.SkipDeps
}
// SkipNeeds returns the skip needs // SkipNeeds returns the skip needs
func (t *TemplateImpl) SkipNeeds() bool { func (t *TemplateImpl) SkipNeeds() bool {
if !t.IncludeNeeds() { if !t.IncludeNeeds() {

View File

@ -10,8 +10,6 @@ import (
type TestOptions struct { type TestOptions struct {
// Concurrency is the maximum number of concurrent helm processes to run, 0 is unlimited // Concurrency is the maximum number of concurrent helm processes to run, 0 is unlimited
Concurrency int Concurrency int
// SkipDeps is the skip deps flag
SkipDeps bool
// Cleanup is the cleanup flag // Cleanup is the cleanup flag
Cleanup bool Cleanup bool
// Logs is the logs flagj // Logs is the logs flagj
@ -45,11 +43,6 @@ func (t *TestImpl) Concurrency() int {
return t.TestOptions.Concurrency return t.TestOptions.Concurrency
} }
// SkipDeps returns the skip deps
func (t *TestImpl) SkipDeps() bool {
return t.TestOptions.SkipDeps
}
// Cleanup returns the cleanup // Cleanup returns the cleanup
func (t *TestImpl) Cleanup() bool { func (t *TestImpl) Cleanup() bool {
return t.TestOptions.Cleanup return t.TestOptions.Cleanup

View File

@ -4,8 +4,6 @@ package config
type WriteValuesOptions struct { type WriteValuesOptions struct {
// Concurrency is the maximum number of concurrent helm processes to run, 0 is unlimited // Concurrency is the maximum number of concurrent helm processes to run, 0 is unlimited
Concurrency int Concurrency int
// SkipDeps is the skip deps flag
SkipDeps bool
// Set is the set flags to pass to helm write values // Set is the set flags to pass to helm write values
Set []string Set []string
// Values is the values flags to pass to helm write values // Values is the values flags to pass to helm write values
@ -38,11 +36,6 @@ func (c *WriteValuesImpl) Concurrency() int {
return c.WriteValuesOptions.Concurrency return c.WriteValuesOptions.Concurrency
} }
// SkipDeps returns the skip deps
func (c *WriteValuesImpl) SkipDeps() bool {
return c.WriteValuesOptions.SkipDeps
}
// Set returns the Set // Set returns the Set
func (c *WriteValuesImpl) Set() []string { func (c *WriteValuesImpl) Set() []string {
return c.WriteValuesOptions.Set return c.WriteValuesOptions.Set

View File

@ -92,6 +92,8 @@ func (helm *Helm) SetHelmBinary(bin string) {
} }
func (helm *Helm) SetEnableLiveOutput(enableLiveOutput bool) { func (helm *Helm) SetEnableLiveOutput(enableLiveOutput bool) {
} }
func (helm *Helm) SetDisableForceUpdate(forceUpdate bool) {
}
func (helm *Helm) AddRepo(name, repository, cafile, certfile, keyfile, username, password string, managed string, passCredentials string, skipTLSVerify string) error { func (helm *Helm) AddRepo(name, repository, cafile, certfile, keyfile, username, password string, managed string, passCredentials string, skipTLSVerify string) error {
helm.Repo = []string{name, repository, cafile, certfile, keyfile, username, password, managed, passCredentials, skipTLSVerify} helm.Repo = []string{name, repository, cafile, certfile, keyfile, username, password, managed, passCredentials, skipTLSVerify}
return nil return nil

View File

@ -28,9 +28,14 @@ type decryptedSecret struct {
err error err error
} }
type HelmExecOptions struct {
EnableLiveOutput bool
DisableForceUpdate bool
}
type execer struct { type execer struct {
helmBinary string helmBinary string
enableLiveOutput bool options HelmExecOptions
version *semver.Version version *semver.Version
runner Runner runner Runner
logger *zap.SugaredLogger logger *zap.SugaredLogger
@ -110,7 +115,7 @@ func redactedURL(chart string) string {
} }
// New for running helm commands // New for running helm commands
func New(helmBinary string, enableLiveOutput bool, logger *zap.SugaredLogger, kubeContext string, runner Runner) *execer { func New(helmBinary string, options HelmExecOptions, logger *zap.SugaredLogger, kubeContext string, runner Runner) *execer {
// TODO: proper error handling // TODO: proper error handling
version, err := GetHelmVersion(helmBinary, runner) version, err := GetHelmVersion(helmBinary, runner)
if err != nil { if err != nil {
@ -118,7 +123,7 @@ func New(helmBinary string, enableLiveOutput bool, logger *zap.SugaredLogger, ku
} }
return &execer{ return &execer{
helmBinary: helmBinary, helmBinary: helmBinary,
enableLiveOutput: enableLiveOutput, options: options,
version: version, version: version,
logger: logger, logger: logger,
kubeContext: kubeContext, kubeContext: kubeContext,
@ -136,7 +141,11 @@ func (helm *execer) SetHelmBinary(bin string) {
} }
func (helm *execer) SetEnableLiveOutput(enableLiveOutput bool) { func (helm *execer) SetEnableLiveOutput(enableLiveOutput bool) {
helm.enableLiveOutput = enableLiveOutput helm.options.EnableLiveOutput = enableLiveOutput
}
func (helm *execer) SetDisableForceUpdate(forceUpdate bool) {
helm.options.DisableForceUpdate = forceUpdate
} }
func (helm *execer) AddRepo(name, repository, cafile, certfile, keyfile, username, password string, managed string, passCredentials string, skipTLSVerify string) error { func (helm *execer) AddRepo(name, repository, cafile, certfile, keyfile, username, password string, managed string, passCredentials string, skipTLSVerify string) error {
@ -156,7 +165,7 @@ func (helm *execer) AddRepo(name, repository, cafile, certfile, keyfile, usernam
// See https://github.com/helm/helm/pull/8777 // See https://github.com/helm/helm/pull/8777
if cons, err := semver.NewConstraint(">= 3.3.2"); err == nil { if cons, err := semver.NewConstraint(">= 3.3.2"); err == nil {
if cons.Check(helm.version) { if !helm.options.DisableForceUpdate && cons.Check(helm.version) {
args = append(args, "--force-update") args = append(args, "--force-update")
} }
} else { } else {
@ -525,7 +534,7 @@ func (helm *execer) exec(args []string, env map[string]string, overrideEnableLiv
} }
cmd := fmt.Sprintf("exec: %s %s", helm.helmBinary, strings.Join(cmdargs, " ")) cmd := fmt.Sprintf("exec: %s %s", helm.helmBinary, strings.Join(cmdargs, " "))
helm.logger.Debug(cmd) helm.logger.Debug(cmd)
enableLiveOutput := helm.enableLiveOutput enableLiveOutput := helm.options.EnableLiveOutput
if overrideEnableLiveOutput != nil { if overrideEnableLiveOutput != nil {
enableLiveOutput = *overrideEnableLiveOutput enableLiveOutput = *overrideEnableLiveOutput
} }

View File

@ -36,7 +36,7 @@ func (mock *mockRunner) Execute(cmd string, args []string, env map[string]string
} }
func MockExecer(logger *zap.SugaredLogger, kubeContext string) *execer { func MockExecer(logger *zap.SugaredLogger, kubeContext string) *execer {
execer := New("helm", false, logger, kubeContext, &mockRunner{}) execer := New("helm", HelmExecOptions{}, logger, kubeContext, &mockRunner{})
return execer return execer
} }
@ -85,12 +85,23 @@ func Test_SetHelmBinary(t *testing.T) {
func Test_SetEnableLiveOutput(t *testing.T) { func Test_SetEnableLiveOutput(t *testing.T) {
helm := MockExecer(NewLogger(os.Stdout, "info"), "dev") helm := MockExecer(NewLogger(os.Stdout, "info"), "dev")
if helm.enableLiveOutput { if helm.options.EnableLiveOutput {
t.Error("helmexec.enableLiveOutput should not be enabled by default") t.Error("helmexec.options.EnableLiveOutput should not be enabled by default")
} }
helm.SetEnableLiveOutput(true) helm.SetEnableLiveOutput(true)
if !helm.enableLiveOutput { if !helm.options.EnableLiveOutput {
t.Errorf("helmexec.SetEnableLiveOutput() - actual = %t expect = true", helm.enableLiveOutput) t.Errorf("helmexec.SetEnableLiveOutput() - actual = %t expect = true", helm.options.EnableLiveOutput)
}
}
func Test_SetDisableForceUpdate(t *testing.T) {
helm := MockExecer(NewLogger(os.Stdout, "info"), "dev")
if helm.options.DisableForceUpdate {
t.Error("helmexec.options.ForceUpdate should not be enabled by default")
}
helm.SetDisableForceUpdate(true)
if !helm.options.DisableForceUpdate {
t.Errorf("helmexec.SetDisableForceUpdate() - actual = %t expect = true", helm.options.DisableForceUpdate)
} }
} }
@ -117,6 +128,30 @@ exec: helm --kube-context dev repo add myRepo https://repo.example.com/ --force-
} }
} }
func Test_AddRepo_Helm_3_3_2_NoForceUpdate(t *testing.T) {
var buffer bytes.Buffer
logger := NewLogger(&buffer, "debug")
helm := &execer{
helmBinary: "helm",
options: HelmExecOptions{DisableForceUpdate: true},
version: semver.MustParse("3.3.2"),
logger: logger,
kubeContext: "dev",
runner: &mockRunner{},
}
err := helm.AddRepo("myRepo", "https://repo.example.com/", "", "cert.pem", "key.pem", "", "", "", "", "")
expected := `Adding repo myRepo https://repo.example.com/
exec: helm --kube-context dev repo add myRepo https://repo.example.com/ --cert-file cert.pem --key-file key.pem
`
if err != nil {
t.Errorf("unexpected error: %v", err)
}
if buffer.String() != expected {
t.Errorf("helmexec.AddRepo()\nactual = %v\nexpect = %v", buffer.String(), expected)
}
}
func Test_AddRepo(t *testing.T) { func Test_AddRepo(t *testing.T) {
var buffer bytes.Buffer var buffer bytes.Buffer
logger := NewLogger(&buffer, "debug") logger := NewLogger(&buffer, "debug")
@ -322,7 +357,7 @@ func Test_BuildDeps(t *testing.T) {
var buffer bytes.Buffer var buffer bytes.Buffer
logger := NewLogger(&buffer, "debug") logger := NewLogger(&buffer, "debug")
helm3Runner := mockRunner{output: []byte("v3.2.4+ge29ce2a")} helm3Runner := mockRunner{output: []byte("v3.2.4+ge29ce2a")}
helm := New("helm", false, logger, "dev", &helm3Runner) helm := New("helm", HelmExecOptions{}, logger, "dev", &helm3Runner)
err := helm.BuildDeps("foo", "./chart/foo", []string{"--skip-refresh"}...) err := helm.BuildDeps("foo", "./chart/foo", []string{"--skip-refresh"}...)
expected := `Building dependency release=foo, chart=./chart/foo expected := `Building dependency release=foo, chart=./chart/foo
exec: helm --kube-context dev dependency build ./chart/foo --skip-refresh exec: helm --kube-context dev dependency build ./chart/foo --skip-refresh
@ -364,7 +399,7 @@ v3.2.4+ge29ce2a
buffer.Reset() buffer.Reset()
helm2Runner := mockRunner{output: []byte("Client: v2.16.1+ge13bc94")} helm2Runner := mockRunner{output: []byte("Client: v2.16.1+ge13bc94")}
helm = New("helm", false, logger, "dev", &helm2Runner) helm = New("helm", HelmExecOptions{}, logger, "dev", &helm2Runner)
err = helm.BuildDeps("foo", "./chart/foo") err = helm.BuildDeps("foo", "./chart/foo")
expected = `Building dependency release=foo, chart=./chart/foo expected = `Building dependency release=foo, chart=./chart/foo
exec: helm --kube-context dev dependency build ./chart/foo exec: helm --kube-context dev dependency build ./chart/foo
@ -870,13 +905,13 @@ exec: helm --kube-context dev template release https://example_user:example_pass
func Test_IsHelm3(t *testing.T) { func Test_IsHelm3(t *testing.T) {
helm2Runner := mockRunner{output: []byte("Client: v2.16.0+ge13bc94\n")} helm2Runner := mockRunner{output: []byte("Client: v2.16.0+ge13bc94\n")}
helm := New("helm", false, NewLogger(os.Stdout, "info"), "dev", &helm2Runner) helm := New("helm", HelmExecOptions{}, NewLogger(os.Stdout, "info"), "dev", &helm2Runner)
if helm.IsHelm3() { if helm.IsHelm3() {
t.Error("helmexec.IsHelm3() - Detected Helm 3 with Helm 2 version") t.Error("helmexec.IsHelm3() - Detected Helm 3 with Helm 2 version")
} }
helm3Runner := mockRunner{output: []byte("v3.0.0+ge29ce2a\n")} helm3Runner := mockRunner{output: []byte("v3.0.0+ge29ce2a\n")}
helm = New("helm", false, NewLogger(os.Stdout, "info"), "dev", &helm3Runner) helm = New("helm", HelmExecOptions{}, NewLogger(os.Stdout, "info"), "dev", &helm3Runner)
if !helm.IsHelm3() { if !helm.IsHelm3() {
t.Error("helmexec.IsHelm3() - Failed to detect Helm 3") t.Error("helmexec.IsHelm3() - Failed to detect Helm 3")
} }
@ -907,14 +942,14 @@ func Test_GetPluginVersion(t *testing.T) {
func Test_GetVersion(t *testing.T) { func Test_GetVersion(t *testing.T) {
helm2Runner := mockRunner{output: []byte("Client: v2.16.1+ge13bc94\n")} helm2Runner := mockRunner{output: []byte("Client: v2.16.1+ge13bc94\n")}
helm := New("helm", false, NewLogger(os.Stdout, "info"), "dev", &helm2Runner) helm := New("helm", HelmExecOptions{}, NewLogger(os.Stdout, "info"), "dev", &helm2Runner)
ver := helm.GetVersion() ver := helm.GetVersion()
if ver.Major != 2 || ver.Minor != 16 || ver.Patch != 1 { if ver.Major != 2 || ver.Minor != 16 || ver.Patch != 1 {
t.Errorf("helmexec.GetVersion - did not detect correct Helm2 version; it was: %+v", ver) t.Errorf("helmexec.GetVersion - did not detect correct Helm2 version; it was: %+v", ver)
} }
helm3Runner := mockRunner{output: []byte("v3.2.4+ge29ce2a\n")} helm3Runner := mockRunner{output: []byte("v3.2.4+ge29ce2a\n")}
helm = New("helm", false, NewLogger(os.Stdout, "info"), "dev", &helm3Runner) helm = New("helm", HelmExecOptions{}, NewLogger(os.Stdout, "info"), "dev", &helm3Runner)
ver = helm.GetVersion() ver = helm.GetVersion()
if ver.Major != 3 || ver.Minor != 2 || ver.Patch != 4 { if ver.Major != 3 || ver.Minor != 2 || ver.Patch != 4 {
t.Errorf("helmexec.GetVersion - did not detect correct Helm3 version; it was: %+v", ver) t.Errorf("helmexec.GetVersion - did not detect correct Helm3 version; it was: %+v", ver)
@ -923,7 +958,7 @@ func Test_GetVersion(t *testing.T) {
func Test_IsVersionAtLeast(t *testing.T) { func Test_IsVersionAtLeast(t *testing.T) {
helm2Runner := mockRunner{output: []byte("Client: v2.16.1+ge13bc94\n")} helm2Runner := mockRunner{output: []byte("Client: v2.16.1+ge13bc94\n")}
helm := New("helm", false, NewLogger(os.Stdout, "info"), "dev", &helm2Runner) helm := New("helm", HelmExecOptions{}, NewLogger(os.Stdout, "info"), "dev", &helm2Runner)
if !helm.IsVersionAtLeast("2.1.0") { if !helm.IsVersionAtLeast("2.1.0") {
t.Error("helmexec.IsVersionAtLeast - 2.16.1 not atleast 2.1") t.Error("helmexec.IsVersionAtLeast - 2.16.1 not atleast 2.1")
} }

View File

@ -14,6 +14,7 @@ type Interface interface {
SetExtraArgs(args ...string) SetExtraArgs(args ...string)
SetHelmBinary(bin string) SetHelmBinary(bin string)
SetEnableLiveOutput(enableLiveOutput bool) SetEnableLiveOutput(enableLiveOutput bool)
SetDisableForceUpdate(forceUpdate bool)
AddRepo(name, repository, cafile, certfile, keyfile, username, password string, managed string, passCredentials string, skipTLSVerify string) error AddRepo(name, repository, cafile, certfile, keyfile, username, password string, managed string, passCredentials string, skipTLSVerify string) error
UpdateRepo() error UpdateRepo() error