@@ -10,6 +10,7 @@ import (
1010 "github.com/stackrox/roxie/internal/deployer"
1111 "github.com/stackrox/roxie/internal/env"
1212 "github.com/stackrox/roxie/internal/logger"
13+ "gopkg.in/yaml.v3"
1314)
1415
1516func newTeardownCmd (settings * deployer.Config ) * cobra.Command {
@@ -22,13 +23,23 @@ func newTeardownCmd(settings *deployer.Config) *cobra.Command {
2223 RunE : runTeardown ,
2324 }
2425
25- cmd .Flags ().Var (newConfigShortCut (settings , "bool" , func (yamlValue string , settings * deployer.Config ) error {
26- // FIXME: make it so that it doesn't require an arg.
27- settings .Central .Namespace = sharedNamespace
28- settings .SecuredCluster .Namespace = sharedNamespace
29- return nil
30- },
31- ), "single-namespace" , "Deploy all components in a single namespace ('stackrox')" )
26+ // --single-namespace[=true/false].
27+ flag := cmd .Flags ().VarPF (
28+ newConfigShortCut (
29+ settings , "bool" ,
30+ func (val string , settings * deployer.Config ) error {
31+ var valParsed bool
32+ if err := yaml .Unmarshal ([]byte (val ), & valParsed ); err != nil {
33+ return err
34+ }
35+ if valParsed {
36+ settings .Central .Namespace = sharedNamespace
37+ settings .SecuredCluster .Namespace = sharedNamespace
38+ }
39+ return nil
40+ },
41+ ), "single-namespace" , "" , "Deploy all components in a single namespace ('stackrox')" )
42+ flag .NoOptDefVal = "true"
3243
3344 return cmd
3445}
0 commit comments