client: simplify logic for manual vs auto API versions

When manually setting the API version to use, automatic API version
negotiation should no longer be performed. Instead of keeping track
of these options individually, we can mark negotiation to have happend
if either the version was set manually, or if API version negotiation
took place.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2025-11-14 15:30:47 +01:00
parent d9ee22d1ab
commit 4e2e2cde7e
7 changed files with 61 additions and 45 deletions

View File

@@ -38,8 +38,6 @@ type clientConfig struct {
userAgent *string
// custom HTTP headers configured by users.
customHTTPHeaders map[string]string
// manualOverride is set to true when the version was set by users.
manualOverride bool
// manualAPIVersion contains the API version set by users. This field
// will only be non-empty if a valid-formed version was set through
@@ -278,7 +276,6 @@ func WithAPIVersion(version string) Opt {
return fmt.Errorf("invalid API version (%s): %w", version, err)
}
c.manualAPIVersion = ver
c.manualOverride = true
}
return nil
}
@@ -311,7 +308,6 @@ func WithAPIVersionFromEnv() Opt {
return fmt.Errorf("invalid API version (%s): %w", version, err)
}
c.envAPIVersion = ver
c.manualOverride = true
}
return nil
}