code: func GetAPIGroupResources(cl discovery.DiscoveryInterface) ([]*APIGroupResources, error) {
  	gs, rs, err := cl.ServerGroupsAndResources()
  	if rs == nil || gs == nil {
  		return nil, err
  		// TODO track the errors and update callers to handle partial errors.
  	}
  	rsm := map[string]*metav1.APIResourceList{}
  	for _, r := range rs {
  		rsm[r.GroupVersion] = r
  	}
  
  	var result []*APIGroupResources
  	for _, group := range gs {
  		groupResources := &APIGroupResources{
  			Group:              *group,
  			VersionedResources: make(map[string][]metav1.APIResource),
  		}
  		for _, version := range group.Versions {
  			resources, ok := rsm[version.GroupVersion]
  			if !ok {
  				continue
  			}
  			groupResources.VersionedResources[version.Version] = resources.APIResources
  		}
  		result = append(result, groupResources)
  	}
  	return result, nil
  }
docs: // GetAPIGroupResources uses the provided discovery client to gather
  // discovery information and populate a slice of APIGroupResources.