From e4d6b1d1ca3725d6a9cf7ca4e1341446af090aa9 Mon Sep 17 00:00:00 2001 From: Eneko Fernandez Date: Thu, 7 Dec 2023 11:03:43 +0100 Subject: [PATCH] using none instead of empty string --- cmd/gitops/app/bootstrap/cmd.go | 2 +- pkg/bootstrap/steps/components_extra.go | 10 +++++----- pkg/bootstrap/steps/components_extra_test.go | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd/gitops/app/bootstrap/cmd.go b/cmd/gitops/app/bootstrap/cmd.go index 402a93674b..ffb6aa016b 100644 --- a/cmd/gitops/app/bootstrap/cmd.go +++ b/cmd/gitops/app/bootstrap/cmd.go @@ -88,7 +88,7 @@ func Command(opts *config.Options) *cobra.Command { } cmd.Flags().StringVarP(&flags.version, "version", "v", "", "version of Weave GitOps Enterprise (should be from the latest 3 versions)") - cmd.Flags().StringSliceVar(&flags.componentsExtra, "components-extra", nil, "extra components to be installed. Supported components: policy-agent, tf-controller") + cmd.Flags().StringSliceVar(&flags.componentsExtra, "components-extra", nil, "extra components to be installed. Supported components: none, policy-agent, tf-controller") cmd.PersistentFlags().BoolVarP(&flags.silent, "silent", "s", false, "non-interactive session: it will not ask questions but rather to use default values to complete the introduced flags") cmd.PersistentFlags().BoolVarP(&flags.bootstrapFlux, "bootstrap-flux", "", false, "flags that you want to bootstrap Flux in case is not detected") cmd.PersistentFlags().StringVarP(&flags.gitUsername, "git-username", "", "", "git username used in https authentication type") diff --git a/pkg/bootstrap/steps/components_extra.go b/pkg/bootstrap/steps/components_extra.go index 261527f144..2cc5d6d2b7 100644 --- a/pkg/bootstrap/steps/components_extra.go +++ b/pkg/bootstrap/steps/components_extra.go @@ -13,12 +13,13 @@ const ( ) const ( + none = "none" policyAgentController = "policy-agent" tfController = "tf-controller" ) var ComponentsExtra = []string{ - "", + none, policyAgentController, tfController, } @@ -59,7 +60,7 @@ func NewInstallExtraComponentsStep(config ComponentsExtraConfig, silent bool) Bo Type: multiSelectionChoice, Msg: componentsExtraMsg, Values: ComponentsExtra, - DefaultValue: "", + DefaultValue: none, } if len(config.Requested) < 1 && !silent { @@ -84,6 +85,8 @@ func installExtraComponents(input []StepInput, c *Config) ([]StepOutput, error) } for _, controller := range c.ComponentsExtra.Requested { switch controller { + case none: + return []StepOutput{}, nil case policyAgentController: agentStep := NewInstallPolicyAgentStep(*c) _, err := agentStep.Execute(c) @@ -96,9 +99,6 @@ func installExtraComponents(input []StepInput, c *Config) ([]StepOutput, error) if err != nil { return []StepOutput{}, fmt.Errorf("can't install tf controller: %v", err) } - case "": - c.Logger.Successf("selected none extra components") - return []StepOutput{}, nil default: return []StepOutput{}, fmt.Errorf("unsupported component selected: %s", controller) } diff --git a/pkg/bootstrap/steps/components_extra_test.go b/pkg/bootstrap/steps/components_extra_test.go index b1b8b06b64..d8f912396a 100644 --- a/pkg/bootstrap/steps/components_extra_test.go +++ b/pkg/bootstrap/steps/components_extra_test.go @@ -24,7 +24,7 @@ func TestNewInstallExtraComponents(t *testing.T) { Type: multiSelectionChoice, Msg: componentsExtraMsg, Values: ComponentsExtra, - DefaultValue: "", + DefaultValue: none, }, }, Step: installExtraComponents, @@ -94,7 +94,7 @@ func TestInstallExtraComponents(t *testing.T) { Name: inComponentsExtra, Type: multiSelectionChoice, Msg: componentsExtraMsg, - Value: "", + Value: none, }, }, },