UPSTREAM: 62234: Handle partial group and resource responses consistently
@@ -144,8 +144,11 @@ func NewRESTMapper(groupResources []*APIGroupResources, versionInterfaces meta.V
func GetAPIGroupResources(cl DiscoveryInterface) ([]*APIGroupResources, error) {
apiGroups, err := cl.ServerGroups()
if err != nil {
+ if apiGroups == nil || len(apiGroups.Groups) == 0 {
return nil, err
}
+ // TODO track the errors and update callers to handle partial errors.
+ }
var result []*APIGroupResources
for _, group := range apiGroups.Groups {
groupResources := &APIGroupResources{
@@ -157,8 +160,10 @@ func GetAPIGroupResources(cl DiscoveryInterface) ([]*APIGroupResources, error) {
if err != nil {
// continue as best we can
// TODO track the errors and update callers to handle partial errors.
+ if resources == nil || len(resources.APIResources) == 0 {
continue
}
+ }
groupResources.VersionedResources[version.Version] = resources.APIResources
}
result = append(result, groupResources)
