@@ -313,20 +313,7 @@ func getClientAPI(cCmd *cobra.Command) client.API {
313313
314314// getClient initializes a client of fleet based on CLI flags
315315func getClient (cCmd * cobra.Command ) (client.API , error ) {
316- // The user explicitly set --experimental-api=false, so it trumps the
317- // --driver flag. This behavior exists for backwards-compatibilty.
318- experimentalAPI , _ := cmdFleet .PersistentFlags ().GetBool ("experimental-api" )
319- endPoint , _ := cmdFleet .PersistentFlags ().GetString ("endpoint" )
320316 clientDriver , _ := cmdFleet .PersistentFlags ().GetString ("driver" )
321- if ! experimentalAPI {
322- // Additionally, if the user set --experimental-api=false and did
323- // not change the value of --endpoint, they likely want to use the
324- // old default value.
325- if endPoint == defaultEndpoint {
326- endPoint = "http://127.0.0.1:2379,http://127.0.0.1:4001"
327- }
328- return getRegistryClient (cCmd )
329- }
330317
331318 switch clientDriver {
332319 case clientDriverAPI :
@@ -431,6 +418,22 @@ func getHTTPClient(cCmd *cobra.Command) (client.API, error) {
431418 return client .NewHTTPClient (& hc , * ep )
432419}
433420
421+ func getEndpoint () string {
422+ // The user explicitly set --experimental-api=false, so it trumps the
423+ // --driver flag. This behavior exists for backwards-compatibilty.
424+ experimentalAPI , _ := cmdFleet .PersistentFlags ().GetBool ("experimental-api" )
425+ endPoint , _ := cmdFleet .PersistentFlags ().GetString ("endpoint" )
426+ if ! experimentalAPI {
427+ // Additionally, if the user set --experimental-api=false and did
428+ // not change the value of --endpoint, they likely want to use the
429+ // old default value.
430+ if endPoint == defaultEndpoint {
431+ endPoint = "http://127.0.0.1:2379,http://127.0.0.1:4001"
432+ }
433+ }
434+ return endPoint
435+ }
436+
434437func getRegistryClient (cCmd * cobra.Command ) (client.API , error ) {
435438 var dial func (string , string ) (net.Conn , error )
436439 SSHUserName , _ := cmdFleet .PersistentFlags ().GetString ("ssh-username" )
@@ -463,9 +466,8 @@ func getRegistryClient(cCmd *cobra.Command) (client.API, error) {
463466 TLSClientConfig : tlsConfig ,
464467 }
465468
466- endPoint , _ := cmdFleet .PersistentFlags ().GetString ("endpoint" )
467469 eCfg := etcd.Config {
468- Endpoints : strings .Split (endPoint , "," ),
470+ Endpoints : strings .Split (getEndpoint () , "," ),
469471 Transport : trans ,
470472 HeaderTimeoutPerRequest : getRequestTimeoutFlag (cCmd ),
471473 }
0 commit comments