code: func (d *apiVersionsFromDiscovery) PreferredVersion() (schema.GroupVersion, error) {
  	d.mu.RLock()
  	if d.prefVersion != nil {
  		// if we've already got one, proceed with that
  		defer d.mu.RUnlock()
  		return *d.prefVersion, nil
  	}
  	d.mu.RUnlock()
  
  	d.mu.Lock()
  	defer d.mu.Unlock()
  
  	// double check, someone might have beaten us to it
  	if d.prefVersion != nil {
  		return *d.prefVersion, nil
  	}
  
  	// populate our cache
  	groupInfo, err := d.fetchVersions()
  	if err != nil {
  		return schema.GroupVersion{}, err
  	}
  	prefVersion, err := d.chooseVersion(groupInfo)
  	if err != nil {
  		return schema.GroupVersion{}, err
  	}
  
  	d.prefVersion = &prefVersion
  	return *d.prefVersion, nil
  }
docs: // PreferredVersion returns the current preferred version of the custom metrics api.
  // If none is specified, it will use the first known one.