code: func convertToDiscoveryAPIGroup(apiServices []*apiregistrationapi.APIService) *metav1.APIGroup {
  	apiServicesByGroup := apiregistrationapi.SortedByGroupAndVersion(apiServices)[0]
  
  	var discoveryGroup *metav1.APIGroup
  
  	for _, apiService := range apiServicesByGroup {
  		// the first APIService which is valid becomes the default
  		if discoveryGroup == nil {
  			discoveryGroup = &metav1.APIGroup{
  				Name: apiService.Spec.Group,
  				PreferredVersion: metav1.GroupVersionForDiscovery{
  					GroupVersion: apiService.Spec.Group + "/" + apiService.Spec.Version,
  					Version:      apiService.Spec.Version,
  				},
  			}
  		}
  
  		discoveryGroup.Versions = append(discoveryGroup.Versions,
  			metav1.GroupVersionForDiscovery{
  				GroupVersion: apiService.Spec.Group + "/" + apiService.Spec.Version,
  				Version:      apiService.Spec.Version,
  			},
  		)
  	}
  
  	return discoveryGroup
  }
docs: // convertToDiscoveryAPIGroup takes apiservices in a single group and returns a discovery compatible object.
  // if none of the services are available, it will return nil.