Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1701 from endocode/dongsu/fleetctl-fix-get-endpoint
Browse files Browse the repository at this point in the history
fleetctl: take experimentalAPI into account in getClient
  • Loading branch information
Dongsu Park committed Nov 10, 2016
2 parents 86d0384 + 85d1d29 commit 20a3e96
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions fleetctl/fleetctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,20 +313,7 @@ func getClientAPI(cCmd *cobra.Command) client.API {

// getClient initializes a client of fleet based on CLI flags
func getClient(cCmd *cobra.Command) (client.API, error) {
// The user explicitly set --experimental-api=false, so it trumps the
// --driver flag. This behavior exists for backwards-compatibilty.
experimentalAPI, _ := cmdFleet.PersistentFlags().GetBool("experimental-api")
endPoint, _ := cmdFleet.PersistentFlags().GetString("endpoint")
clientDriver, _ := cmdFleet.PersistentFlags().GetString("driver")
if !experimentalAPI {
// Additionally, if the user set --experimental-api=false and did
// not change the value of --endpoint, they likely want to use the
// old default value.
if endPoint == defaultEndpoint {
endPoint = "http://127.0.0.1:2379,http://127.0.0.1:4001"
}
return getRegistryClient(cCmd)
}

switch clientDriver {
case clientDriverAPI:
Expand Down Expand Up @@ -431,6 +418,22 @@ func getHTTPClient(cCmd *cobra.Command) (client.API, error) {
return client.NewHTTPClient(&hc, *ep)
}

func getEndpoint() string {
// The user explicitly set --experimental-api=false, so it trumps the
// --driver flag. This behavior exists for backwards-compatibilty.
experimentalAPI, _ := cmdFleet.PersistentFlags().GetBool("experimental-api")
endPoint, _ := cmdFleet.PersistentFlags().GetString("endpoint")
if !experimentalAPI {
// Additionally, if the user set --experimental-api=false and did
// not change the value of --endpoint, they likely want to use the
// old default value.
if endPoint == defaultEndpoint {
endPoint = "http://127.0.0.1:2379,http://127.0.0.1:4001"
}
}
return endPoint
}

func getRegistryClient(cCmd *cobra.Command) (client.API, error) {
var dial func(string, string) (net.Conn, error)
SSHUserName, _ := cmdFleet.PersistentFlags().GetString("ssh-username")
Expand Down Expand Up @@ -463,9 +466,8 @@ func getRegistryClient(cCmd *cobra.Command) (client.API, error) {
TLSClientConfig: tlsConfig,
}

endPoint, _ := cmdFleet.PersistentFlags().GetString("endpoint")
eCfg := etcd.Config{
Endpoints: strings.Split(endPoint, ","),
Endpoints: strings.Split(getEndpoint(), ","),
Transport: trans,
HeaderTimeoutPerRequest: getRequestTimeoutFlag(cCmd),
}
Expand Down

0 comments on commit 20a3e96

Please sign in to comment.