mirror of
https://github.com/kubernetes/client-go.git
synced 2025-09-23 03:57:07 +00:00
manually sync with k8s.io/kubernetest at 17375fc59fff39135af63bd1750bb07c36ef873b, k8s.io/apimachinery at d90aa2c8531f13b0ca734845934c10dcb6a56ca7
This commit is contained in:
@@ -23,8 +23,6 @@ import (
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
apimachineryversion "k8s.io/apimachinery/pkg/version"
|
||||
// Import solely to initialize client auth plugins.
|
||||
_ "k8s.io/client-go/plugin/pkg/client/auth"
|
||||
)
|
||||
|
||||
// MatchesServerVersion queries the server to compares the build version
|
||||
@@ -49,6 +47,9 @@ func MatchesServerVersion(clientVersion apimachineryversion.Info, client Discove
|
||||
// preference.
|
||||
// - If version is provided and the server does not support it,
|
||||
// return an error.
|
||||
// TODO negotiation should be reserved for cases where we need a version for a given group. In those cases, it should return an ordered list of
|
||||
// server preferences. From that list, a separate function can match from an ordered list of client versions.
|
||||
// This is not what the function has ever done before, but it makes more logical sense.
|
||||
func NegotiateVersion(client DiscoveryInterface, requiredGV *schema.GroupVersion, clientRegisteredGVs []schema.GroupVersion) (*schema.GroupVersion, error) {
|
||||
clientVersions := sets.String{}
|
||||
for _, gv := range clientRegisteredGVs {
|
||||
@@ -104,8 +105,8 @@ func NegotiateVersion(client DiscoveryInterface, requiredGV *schema.GroupVersion
|
||||
return &clientRegisteredGVs[0], nil
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("failed to negotiate an api version; server supports: %v, client supports: %v",
|
||||
serverVersions, clientVersions)
|
||||
// fall back to an empty GroupVersion. Most client commands no longer respect a GroupVersion anyway
|
||||
return &schema.GroupVersion{}, nil
|
||||
}
|
||||
|
||||
// GroupVersionResources converts APIResourceLists to the GroupVersionResources.
|
||||
|
Reference in New Issue
Block a user