Merge pull request #330 from thaJeztah/17.09-backport-cli-version

[17.09] Fix version comparison when negotiating the the API version
This commit is contained in:
Andrew Hsu
2017-11-30 13:58:42 -08:00
committed by GitHub
4 changed files with 15 additions and 5 deletions
+2 -2
View File
@@ -266,8 +266,8 @@ func (cli *Client) NegotiateAPIVersionPing(p types.Ping) {
cli.version = api.DefaultVersion
}
// if server version is lower than the maximum version supported by the Client, downgrade
if versions.LessThan(p.APIVersion, api.DefaultVersion) {
// if server version is lower than the client version, downgrade
if versions.LessThan(p.APIVersion, cli.version) {
cli.version = p.APIVersion
}
}
+8
View File
@@ -245,6 +245,14 @@ func TestNegotiateAPIVersion(t *testing.T) {
// test downgrade
client.NegotiateAPIVersionPing(ping)
assert.Equal(t, expected, client.version)
// set the client version to something older, and verify that we keep the
// original setting.
expected = "1.20"
client.version = expected
client.NegotiateAPIVersionPing(ping)
assert.Equal(t, expected, client.version)
}
// TestNegotiateAPIVersionOverride asserts that we honor