func (d *memCacheClient) ServerGroupsAndResources() ([]*metav1.APIGroup, []*metav1.APIResourceList, error) {
	return discovery.ServerGroupsAndResources(d)
}
ServerGroupsAndResources returns the groups and supported resources for all groups and versions.
package clients
import (
	"errors"
	"fmt"
	"sync"
	"syscall"
	openapi_v2 "github.com/googleapis/gnostic/openapiv2"
	logger "github.com/pulumi/pulumi/sdk/v3/go/common/util/logging"
	errorsutil "k8s.io/apimachinery/pkg/api/errors"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/version"
	"k8s.io/client-go/discovery"
	"k8s.io/client-go/discovery/cached/memory"
	restclient "k8s.io/client-go/rest"
)
type cacheEntry struct {
	resourceList *metav1.APIResourceList
	err          error
}
type memCacheClient struct {
	delegate discovery.DiscoveryInterface
	lock                   sync.RWMutex
	schema                 *openapi_v2.Document
	groupToServerResources map[string]*cacheEntry
	groupList              *metav1.APIGroupList
	cacheValid             bool
}
var _ discovery.CachedDiscoveryInterface = &memCacheClient{}
func isTransientConnectionError(err error) bool {
	var errno syscall.Errno
	if errors.As(err, &errno) {
		return errno == syscall.ECONNREFUSED || errno == syscall.ECONNRESET
	}
	return false
}
func isTransientError(err error) bool {
	if isTransientConnectionError(err) {
		return true
	}
	if t, ok := err.(errorsutil.APIStatus); ok && t.Status().Code >= 500 {
		return true
	}
	return errorsutil.IsTooManyRequests(err)
}
func (d *memCacheClient) ServerResourcesForGroupVersion(groupVersion string) (*metav1.APIResourceList, error) {
	d.lock.Lock()
	defer d.lock.Unlock()
	if !d.cacheValid {
		if err := d.refreshLocked(); err != nil {
			return nil, err
		}
	}
	cachedVal, ok := d.groupToServerResources[groupVersion]
	if !ok {
		return nil, memory.ErrCacheNotFound
	}
	if cachedVal.err != nil && isTransientError(cachedVal.err) {
		r, err := d.serverResourcesForGroupVersion(groupVersion)
		if err != nil {
			logger.V(9).Infof("couldn't get resource list for %v: %v", groupVersion, err)
		}
		cachedVal = &cacheEntry{r, err}
		d.groupToServerResources[groupVersion] = cachedVal
	}
	return cachedVal.resourceList, cachedVal.err
}
func (d *memCacheClient) ServerResources() ([]*metav1.APIResourceList, error) {
	return discovery.ServerResources(d)
}