@@ -313,20 +313,7 @@ func getClientAPI(cCmd *cobra.Command) client.API {
313
313
314
314
// getClient initializes a client of fleet based on CLI flags
315
315
func 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" )
320
316
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
- }
330
317
331
318
switch clientDriver {
332
319
case clientDriverAPI :
@@ -431,6 +418,22 @@ func getHTTPClient(cCmd *cobra.Command) (client.API, error) {
431
418
return client .NewHTTPClient (& hc , * ep )
432
419
}
433
420
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
+
434
437
func getRegistryClient (cCmd * cobra.Command ) (client.API , error ) {
435
438
var dial func (string , string ) (net.Conn , error )
436
439
SSHUserName , _ := cmdFleet .PersistentFlags ().GetString ("ssh-username" )
@@ -463,9 +466,8 @@ func getRegistryClient(cCmd *cobra.Command) (client.API, error) {
463
466
TLSClientConfig : tlsConfig ,
464
467
}
465
468
466
- endPoint , _ := cmdFleet .PersistentFlags ().GetString ("endpoint" )
467
469
eCfg := etcd.Config {
468
- Endpoints : strings .Split (endPoint , "," ),
470
+ Endpoints : strings .Split (getEndpoint () , "," ),
469
471
Transport : trans ,
470
472
HeaderTimeoutPerRequest : getRequestTimeoutFlag (cCmd ),
471
473
}
0 commit comments