From b13370f0790c12fbaed84cfcafbd05cc44a93aa0 Mon Sep 17 00:00:00 2001 From: jack-baines Date: Mon, 22 Jan 2024 13:24:48 +0000 Subject: [PATCH 1/2] Allow docker client to negotiate the API version with the server rather than hardcoding Signed-off-by: jack-baines --- docker/daemon/client.go | 6 ------ docker/daemon/client_test.go | 2 -- go.sum | 2 -- 3 files changed, 10 deletions(-) diff --git a/docker/daemon/client.go b/docker/daemon/client.go index 2c245f54f9..48f931118e 100644 --- a/docker/daemon/client.go +++ b/docker/daemon/client.go @@ -9,11 +9,6 @@ import ( "github.com/docker/go-connections/tlsconfig" ) -const ( - // The default API version to be used in case none is explicitly specified - defaultAPIVersion = "1.22" -) - // NewDockerClient initializes a new API client based on the passed SystemContext. func newDockerClient(sys *types.SystemContext) (*dockerclient.Client, error) { host := dockerclient.DefaultDockerHost @@ -23,7 +18,6 @@ func newDockerClient(sys *types.SystemContext) (*dockerclient.Client, error) { opts := []dockerclient.Opt{ dockerclient.WithHost(host), - dockerclient.WithVersion(defaultAPIVersion), } // We conditionalize building the TLS configuration only to TLS sockets: diff --git a/docker/daemon/client_test.go b/docker/daemon/client_test.go index 161747f750..021e24d13d 100644 --- a/docker/daemon/client_test.go +++ b/docker/daemon/client_test.go @@ -18,7 +18,6 @@ func TestDockerClientFromNilSystemContext(t *testing.T) { assert.NotNil(t, client, "A Docker client reference should have been returned") assert.Equal(t, dockerclient.DefaultDockerHost, client.DaemonHost(), "The default docker host should have been used") - assert.Equal(t, defaultAPIVersion, client.ClientVersion(), "The default api version should have been used") assert.NoError(t, client.Close()) } @@ -39,7 +38,6 @@ func TestDockerClientFromCertContext(t *testing.T) { assert.NotNil(t, client, "A Docker client reference should have been returned") assert.Equal(t, host, client.DaemonHost()) - assert.Equal(t, "1.22", client.ClientVersion()) assert.NoError(t, client.Close()) } diff --git a/go.sum b/go.sum index b91e7bb022..4fa236b31f 100644 --- a/go.sum +++ b/go.sum @@ -67,8 +67,6 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/distribution/reference v0.5.0 h1:/FUIFXtfc/x2gpa5/VGfiGLuOIdYa1t65IKK2OFGvA0= github.com/distribution/reference v0.5.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= -github.com/docker/cli v24.0.7+incompatible h1:wa/nIwYFW7BVTGa7SWPVyyXU9lgORqUb1xfI36MSkFg= -github.com/docker/cli v24.0.7+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/cli v25.0.0+incompatible h1:zaimaQdnX7fYWFqzN88exE9LDEvRslexpFowZBX6GoQ= github.com/docker/cli v25.0.0+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk= From 0552bcc9b50d24fda91033420832939159d525e7 Mon Sep 17 00:00:00 2001 From: jack-baines Date: Wed, 24 Jan 2024 09:41:51 +0000 Subject: [PATCH 2/2] Call WithAPIVersionNegotiation to enable version negoatiation Signed-off-by: jack-baines --- docker/daemon/client.go | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/daemon/client.go b/docker/daemon/client.go index 48f931118e..354af2140f 100644 --- a/docker/daemon/client.go +++ b/docker/daemon/client.go @@ -18,6 +18,7 @@ func newDockerClient(sys *types.SystemContext) (*dockerclient.Client, error) { opts := []dockerclient.Opt{ dockerclient.WithHost(host), + dockerclient.WithAPIVersionNegotiation(), } // We conditionalize building the TLS configuration only to TLS sockets: