@@ -8,16 +8,11 @@ import (
88 "github.com/uselagoon/machinery/api/schema"
99
1010 "github.com/spf13/cobra"
11- "github.com/spf13/pflag"
1211 "github.com/uselagoon/lagoon-cli/pkg/output"
1312 "github.com/uselagoon/machinery/api/lagoon"
1413 lclient "github.com/uselagoon/machinery/api/lagoon/client"
1514)
1615
17- // @TODO re-enable this at some point if more environment based commands are made available
18- var environmentAutoIdle uint
19- var environmentAutoIdleProvided bool
20-
2116var deleteEnvCmd = & cobra.Command {
2217 Use : "environment" ,
2318 Aliases : []string {"e" },
@@ -105,8 +100,11 @@ var updateEnvironmentCmd = &cobra.Command{
105100 if err != nil {
106101 return err
107102 }
108-
109- cmd .Flags ().Visit (checkFlags )
103+ autoIdle , err := cmd .Flags ().GetBool ("auto-idle" )
104+ if err != nil {
105+ return err
106+ }
107+ autoIdleProvided := cmd .Flags ().Lookup ("auto-idle" ).Changed
110108
111109 if err := requiredInputCheck ("Project name" , cmdProjectName , "Environment name" , cmdProjectEnvironment ); err != nil {
112110 return err
@@ -144,8 +142,8 @@ var updateEnvironmentCmd = &cobra.Command{
144142 DeployTitle : nullStrCheck (deployTitle ),
145143 Openshift : nullUintCheck (deploytarget ),
146144 }
147- if environmentAutoIdleProvided {
148- environmentFlags .AutoIdle = & environmentAutoIdle
145+ if autoIdleProvided {
146+ environmentFlags .AutoIdle = nullBoolToUint ( autoIdle )
149147 }
150148 if environmentType != "" {
151149 envType := schema .EnvType (strings .ToUpper (environmentType ))
@@ -179,12 +177,6 @@ var updateEnvironmentCmd = &cobra.Command{
179177 },
180178}
181179
182- func checkFlags (f * pflag.Flag ) {
183- if f .Name == "auto-idle" {
184- environmentAutoIdleProvided = true
185- }
186- }
187-
188180var listBackupsCmd = & cobra.Command {
189181 Use : "backups" ,
190182 Aliases : []string {"b" },
@@ -320,7 +312,7 @@ func init() {
320312 updateEnvironmentCmd .Flags ().String ("namespace" , "" , "Update the namespace for the selected environment" )
321313 updateEnvironmentCmd .Flags ().String ("route" , "" , "Update the route for the selected environment" )
322314 updateEnvironmentCmd .Flags ().String ("routes" , "" , "Update the routes for the selected environment" )
323- updateEnvironmentCmd .Flags ().UintVarP ( & environmentAutoIdle , "auto-idle" , "a" , 1 , "Auto idle setting of the environment" )
315+ updateEnvironmentCmd .Flags ().BoolP ( "auto-idle" , "a" , false , "Auto idle setting of the environment. Set to enable, --auto-idle=false to disable " )
324316 updateEnvironmentCmd .Flags ().UintP ("deploytarget" , "d" , 0 , "Reference to Deploytarget(Kubernetes) this Environment should be deployed to" )
325317 updateEnvironmentCmd .Flags ().String ("environment-type" , "" , "Update the environment type - production | development" )
326318 updateEnvironmentCmd .Flags ().String ("deploy-type" , "" , "Update the deploy type - branch | pullrequest | promote" )
0 commit comments