Add GroupDiscoveryFailedErrorGroups helper method

Kubernetes-commit: 733f63c6c423565b8cecf3f3db8e9d81e48b1311
This commit is contained in:
Jordan Liggitt
2023-05-15 09:23:54 -04:00
committed by Kubernetes Publisher
parent b8a03ab933
commit daed746fdc

View File

@@ -19,6 +19,7 @@ package discovery
import (
"context"
"encoding/json"
goerrors "errors"
"fmt"
"mime"
"net/http"
@@ -422,6 +423,16 @@ func IsGroupDiscoveryFailedError(err error) bool {
return err != nil && ok
}
// GroupDiscoveryFailedErrorGroups returns true if the error is an ErrGroupDiscoveryFailed error,
// along with the map of group versions that failed discovery.
func GroupDiscoveryFailedErrorGroups(err error) (map[schema.GroupVersion]error, bool) {
var groupDiscoveryError *ErrGroupDiscoveryFailed
if err != nil && goerrors.As(err, &groupDiscoveryError) {
return groupDiscoveryError.Groups, true
}
return nil, false
}
func ServerGroupsAndResources(d DiscoveryInterface) ([]*metav1.APIGroup, []*metav1.APIResourceList, error) {
var sgs *metav1.APIGroupList
var resources []*metav1.APIResourceList