Explorar o código

Always perform version-negotiation

If a client is initialized without a specific
version set, version negotiation would not be
functional.

This patch changes the behavior to always
perform version negotation (if called), in
which case the "current" (maximum supported
API version) is used as a default.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn %!s(int64=8) %!d(string=hai) anos
pai
achega
5975dc4b4b
Modificáronse 1 ficheiros con 7 adicións e 2 borrados
  1. 7 2
      client/client.go

+ 7 - 2
client/client.go

@@ -260,8 +260,13 @@ func (cli *Client) NegotiateAPIVersionPing(p types.Ping) {
 		p.APIVersion = "1.24"
 		p.APIVersion = "1.24"
 	}
 	}
 
 
-	// if server version is lower than the current cli, downgrade
-	if versions.LessThan(p.APIVersion, cli.ClientVersion()) {
+	// if the client is not initialized with a version, start with the latest supported version
+	if cli.version == "" {
+		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) {
 		cli.version = p.APIVersion
 		cli.version = p.APIVersion
 	}
 	}
 }
 }