From a13cdc241b782a10d42aa31dfad8ebae17c70f20 Mon Sep 17 00:00:00 2001 From: Christopher Crone Date: Wed, 13 Sep 2017 11:30:10 +0200 Subject: [PATCH] Set client version instead of negotiating it Signed-off-by: Christopher Crone Upstream-commit: 85431566a81792e3612df3b6b858f7b0c3506883 Component: engine --- .../engine/integration-cli/request/request.go | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/components/engine/integration-cli/request/request.go b/components/engine/integration-cli/request/request.go index 495a1b0eae..f22b08d768 100644 --- a/components/engine/integration-cli/request/request.go +++ b/components/engine/integration-cli/request/request.go @@ -18,7 +18,6 @@ import ( "time" "github.com/docker/docker/api" - "github.com/docker/docker/api/types" dclient "github.com/docker/docker/client" "github.com/docker/docker/opts" "github.com/docker/docker/pkg/ioutils" @@ -328,10 +327,31 @@ func DaemonHost() string { // NewEnvClientWithVersion returns a docker client with a specified version. // See: github.com/docker/docker/client `NewEnvClient()` func NewEnvClientWithVersion(version string) (*dclient.Client, error) { - cli, err := dclient.NewEnvClient() + if version == "" { + return nil, errors.New("version not specified") + } + + var httpClient *http.Client + if os.Getenv("DOCKER_CERT_PATH") != "" { + tlsConfig, err := getTLSConfig() + if err != nil { + return nil, err + } + httpClient = &http.Client{ + Transport: &http.Transport{ + TLSClientConfig: tlsConfig, + }, + } + } + + host := os.Getenv("DOCKER_HOST") + if host == "" { + host = dclient.DefaultDockerHost + } + + cli, err := dclient.NewClient(host, version, httpClient, nil) if err != nil { - return nil, err + return cli, err } - cli.NegotiateAPIVersionPing(types.Ping{APIVersion: version}) return cli, nil }