client: make WithAPIVersion, WithAPIVersionFromEnv order-independent

Environment-variables are expected to override config / defaults, so
make sure that the DOCKER_API_VERSION env-var always takes priority.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2025-11-14 12:39:08 +01:00
parent a5c7f3f9c8
commit 53764de815
7 changed files with 111 additions and 4 deletions

View File

@@ -89,6 +89,10 @@ func (cli *Client) Ping(ctx context.Context, options PingOptions) (PingResult, e
}
if cli.negotiated.Load() && !options.ForceNegotiate {
// API version was already negotiated or manually set.
//
// We check cli.negotiated again under lock, to account for race
// conditions with the check at the start of this function.
return ping, nil
}