17 lines
		
	
	
		
			522 B
		
	
	
	
		
			Go
		
	
	
	
			
		
		
	
	
			17 lines
		
	
	
		
			522 B
		
	
	
	
		
			Go
		
	
	
	
package restmapper
 | 
						|
 | 
						|
import (
 | 
						|
	"k8s.io/apimachinery/pkg/api/meta"
 | 
						|
	"k8s.io/apimachinery/pkg/runtime/schema"
 | 
						|
)
 | 
						|
 | 
						|
// GetGroupVersionResource is a helper to map GVK(schema.GroupVersionKind) to GVR(schema.GroupVersionResource).
 | 
						|
func GetGroupVersionResource(restMapper meta.RESTMapper, gvk schema.GroupVersionKind) (schema.GroupVersionResource, error) {
 | 
						|
	restMapping, err := restMapper.RESTMapping(gvk.GroupKind(), gvk.Version)
 | 
						|
	if err != nil {
 | 
						|
		return schema.GroupVersionResource{}, err
 | 
						|
	}
 | 
						|
 | 
						|
	return restMapping.Resource, nil
 | 
						|
}
 |