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>
| ... | ... |
@@ -260,8 +260,13 @@ func (cli *Client) NegotiateAPIVersionPing(p types.Ping) {
|
| 260 | 260 |
p.APIVersion = "1.24" |
| 261 | 261 |
} |
| 262 | 262 |
|
| 263 |
- // if server version is lower than the current cli, downgrade |
|
| 264 |
- if versions.LessThan(p.APIVersion, cli.ClientVersion()) {
|
|
| 263 |
+ // if the client is not initialized with a version, start with the latest supported version |
|
| 264 |
+ if cli.version == "" {
|
|
| 265 |
+ cli.version = api.DefaultVersion |
|
| 266 |
+ } |
|
| 267 |
+ |
|
| 268 |
+ // if server version is lower than the maximum version supported by the Client, downgrade |
|
| 269 |
+ if versions.LessThan(p.APIVersion, api.DefaultVersion) {
|
|
| 265 | 270 |
cli.version = p.APIVersion |
| 266 | 271 |
} |
| 267 | 272 |
} |