mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-10 05:27:07 +08:00
vendor: bump k8s to v0.25.4
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
21
vendor/k8s.io/client-go/discovery/helper.go
generated
vendored
21
vendor/k8s.io/client-go/discovery/helper.go
generated
vendored
@ -19,12 +19,33 @@ package discovery
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
apimachineryversion "k8s.io/apimachinery/pkg/version"
|
||||
)
|
||||
|
||||
// IsResourceEnabled queries the server to determine if the resource specified is present on the server.
|
||||
// This is particularly helpful when writing a controller or an e2e test that requires a particular resource to function.
|
||||
func IsResourceEnabled(client DiscoveryInterface, resourceToCheck schema.GroupVersionResource) (bool, error) {
|
||||
// this is a single request. The ServerResourcesForGroupVersion handles the core v1 group as legacy.
|
||||
resourceList, err := client.ServerResourcesForGroupVersion(resourceToCheck.GroupVersion().String())
|
||||
if apierrors.IsNotFound(err) { // if the discovery endpoint isn't present, then the resource isn't present.
|
||||
return false, nil
|
||||
}
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
for _, actualResource := range resourceList.APIResources {
|
||||
if actualResource.Name == resourceToCheck.Resource {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
|
||||
return false, nil
|
||||
}
|
||||
|
||||
// MatchesServerVersion queries the server to compares the build version
|
||||
// (git hash) of the client with the server's build version. It returns an error
|
||||
// if it failed to contact the server or if the versions are not an exact match.
|
||||
|
Reference in New Issue
Block a user