func (r *Resources) CanonicalGroupVersionKind(gvk schema.GroupVersionKind) (schema.GroupVersionKind, error) {
	res, ok := r.registry[gvk]
	if !ok {
		return gvk, fmt.Errorf("server does not recognize gvk %s", gvk)
	}
	return res.canonical, nil
}
CanonicalGroupVersionKind provides the preferred/ canonical group version kind for the supplied input.
It takes aliases into account (e.g. extensions/Deployment same as apps/Deployment) for doing so.
package k8smeta
import (
	"fmt"
	"os"
	"sort"
	"strings"
	"sync"
	"github.com/pkg/errors"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/runtime/schema"
)
var defaultVerbs = []string{"create", "delete", "get", "list"}
type gvkInfo struct {
	canonical schema.GroupVersionKind  
	resource  metav1.APIResource       
}
type ResourceDiscovery interface {
	ServerGroups() (*metav1.APIGroupList, error)
	ServerResourcesForGroupVersion(groupVersion string) (*metav1.APIResourceList, error)
}
type Resources struct {
	disco    ResourceDiscovery
	registry map[schema.GroupVersionKind]*gvkInfo
}
type ResourceOpts struct {
	RequiredVerbs []string              
	WarnFn        func(...interface{})  
}
func (o *ResourceOpts) setDefaults() {
	if o.WarnFn == nil {
		o.WarnFn = func(args ...interface{}) {
			fmt.Fprintln(os.Stderr, args...)
		}
	}
	if len(o.RequiredVerbs) == 0 {
		o.RequiredVerbs = defaultVerbs
	}
}
func NewResources(disco ResourceDiscovery, opts ResourceOpts) (*Resources, error) {
	sm := &Resources{
		disco:    disco,
		registry: map[schema.GroupVersionKind]*gvkInfo{},
	}
	opts.setDefaults()
	if err := sm.init(opts); err != nil {
		return nil, err
	}
	return sm, nil
}
func (r *Resources) APIResource(gvk schema.GroupVersionKind) *metav1.APIResource {
	r0, ok := r.registry[gvk]
	if !ok {
		return nil
	}
	res := r0.resource
	return &res
}
func (r *Resources) CanonicalResources() map[schema.GroupKind]metav1.APIResource {
	canonical := map[schema.GroupVersionKind]bool{}
	for _, v := range r.registry {
		canonical[v.canonical] = true
	}
	ret := map[schema.GroupKind]metav1.APIResource{}
	for k := range canonical {
		r0 := r.registry[k]
		res := r0.resource
		res.Group = k.Group
		res.Version = k.Version
		res.Kind = k.Kind
		ret[k.GroupKind()] = res
	}
	return ret
}