Skip to content

Commit

Permalink
Merge pull request #2260 from bainsy88/issue_2259
Browse files Browse the repository at this point in the history
Allow docker client to negotiate the API version with the server
  • Loading branch information
mtrmac committed Jan 24, 2024
2 parents 7d48440 + 209aa59 commit 3e5b951
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
7 changes: 1 addition & 6 deletions docker/daemon/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -23,7 +18,7 @@ func newDockerClient(sys *types.SystemContext) (*dockerclient.Client, error) {

opts := []dockerclient.Opt{
dockerclient.WithHost(host),
dockerclient.WithVersion(defaultAPIVersion),
dockerclient.WithAPIVersionNegotiation(),
}

// We conditionalize building the TLS configuration only to TLS sockets:
Expand Down
2 changes: 0 additions & 2 deletions docker/daemon/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand All @@ -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())
}
Expand Down

0 comments on commit 3e5b951

Please sign in to comment.