func IsAPIGroupSupported(discoveryCli discovery.DiscoveryInterface, group string) (bool, error) {
	apiGroupList, err := discoveryCli.ServerGroups()
	if err != nil {
		return false, err
	}
	for _, apiGroup := range apiGroupList.Groups {
		if apiGroup.Name == group {
			return true, nil
		}
	}
	return false, nil
}
IsAPIGroupSupported checks if given group is supported by the cluster.
package discovery
import (
	"k8s.io/apimachinery/pkg/runtime/schema"
	"k8s.io/client-go/discovery"
)
func IsAPIGroupVersionSupported(discoveryCli discovery.DiscoveryInterface, groupVersion string) (bool, error) {
	gv, err := schema.ParseGroupVersion(groupVersion)
	if err != nil {
		return false, err
	}
	apiGroupList, err := discoveryCli.ServerGroups()
	if err != nil {
		return false, err
	}
	for _, apiGroup := range apiGroupList.Groups {
		if apiGroup.Name != gv.Group {
			continue
		}
		for _, version := range apiGroup.Versions {
			if version.GroupVersion == gv.String() {
				return true, nil
			}
		}
	}
	return false, nil
}