mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
client: don't negotiate malformed responses
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -316,6 +316,12 @@ func (cli *Client) negotiateAPIVersion(pingVersion string) error {
|
|||||||
return cerrdefs.ErrInvalidArgument.WithMessage(fmt.Sprintf("API version %s is not supported by this client: the minimum supported API version is %s", pingVersion, MinAPIVersion))
|
return cerrdefs.ErrInvalidArgument.WithMessage(fmt.Sprintf("API version %s is not supported by this client: the minimum supported API version is %s", pingVersion, MinAPIVersion))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var err error
|
||||||
|
pingVersion, err = parseAPIVersion(pingVersion)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// if the client is not initialized with a version, start with the latest supported version
|
// if the client is not initialized with a version, start with the latest supported version
|
||||||
if cli.version == "" {
|
if cli.version == "" {
|
||||||
cli.version = MaxAPIVersion
|
cli.version = MaxAPIVersion
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ func TestPingSuccess(t *testing.T) {
|
|||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
assert.Check(t, is.Equal(true, ping.Experimental))
|
assert.Check(t, is.Equal(true, ping.Experimental))
|
||||||
assert.Check(t, is.Equal("awesome", ping.APIVersion))
|
assert.Check(t, is.Equal("awesome", ping.APIVersion))
|
||||||
|
assert.Check(t, is.Equal(MaxAPIVersion, client.version))
|
||||||
assert.Check(t, is.Equal(SwarmStatus{NodeState: "active", ControlAvailable: true}, *ping.SwarmStatus))
|
assert.Check(t, is.Equal(SwarmStatus{NodeState: "active", ControlAvailable: true}, *ping.SwarmStatus))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
6
vendor/github.com/moby/moby/client/client.go
generated
vendored
6
vendor/github.com/moby/moby/client/client.go
generated
vendored
@@ -316,6 +316,12 @@ func (cli *Client) negotiateAPIVersion(pingVersion string) error {
|
|||||||
return cerrdefs.ErrInvalidArgument.WithMessage(fmt.Sprintf("API version %s is not supported by this client: the minimum supported API version is %s", pingVersion, MinAPIVersion))
|
return cerrdefs.ErrInvalidArgument.WithMessage(fmt.Sprintf("API version %s is not supported by this client: the minimum supported API version is %s", pingVersion, MinAPIVersion))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var err error
|
||||||
|
pingVersion, err = parseAPIVersion(pingVersion)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// if the client is not initialized with a version, start with the latest supported version
|
// if the client is not initialized with a version, start with the latest supported version
|
||||||
if cli.version == "" {
|
if cli.version == "" {
|
||||||
cli.version = MaxAPIVersion
|
cli.version = MaxAPIVersion
|
||||||
|
|||||||
Reference in New Issue
Block a user