clusterreader

package
v0.17.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2020 License: Apache-2.0 Imports: 10 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CachingClusterReader

type CachingClusterReader struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

CachingClusterReader is an implementation of the ObserverReader interface that will pre-fetch all resources needed before every sync loop. The resources needed are decided by finding all combinations of GroupVersionKind and namespace referenced by the provided identifiers. This list is then expanded to include any known generated resource types.

func NewCachingClusterReader

func NewCachingClusterReader(reader client.Reader, mapper meta.RESTMapper, identifiers []object.ObjMetadata) (*CachingClusterReader, error)

NewCachingClusterReader returns a new instance of the ClusterReader. The ClusterReader needs will use the clusterreader to fetch resources from the cluster, while the mapper is used to resolve the version for GroupKinds. The list of identifiers is needed so the ClusterReader can figure out which GroupKind and namespace combinations it needs to cache when the Sync function is called. We only want to fetch the resources that are actually needed.

func (*CachingClusterReader) Get

Get looks up the resource identified by the key and the object GVK in the cache. If the needed combination of GVK and namespace is not part of the cache, that is considered an error.

func (*CachingClusterReader) ListClusterScoped

func (c *CachingClusterReader) ListClusterScoped(ctx context.Context, list *unstructured.UnstructuredList, selector labels.Selector) error

ListClusterScoped lists all resource identifier by the GVK of the list and selector from the cache. If the needed combination of GVK and namespace (which for clusterscoped resources will always be the empty string) is not part of the cache, that is considered an error.

func (*CachingClusterReader) ListNamespaceScoped

func (c *CachingClusterReader) ListNamespaceScoped(_ context.Context, list *unstructured.UnstructuredList, namespace string, selector labels.Selector) error

ListNamespaceScoped lists all resource identifier by the GVK of the list, the namespace and the selector from the cache. If the needed combination of GVK and namespace is not part of the cache, that is considered an error.

func (*CachingClusterReader) Sync

Sync loops over the list of gkNamespace we know of, and uses list calls to fetch the resources. This information populates the cache.

type DirectClusterReader

type DirectClusterReader struct {
	Reader client.Reader
}

DirectClusterReader is an implementation of the ClusterReader that just delegates all calls directly to the underlying clusterreader. No caching.

func (*DirectClusterReader) Get

func (*DirectClusterReader) ListClusterScoped

func (n *DirectClusterReader) ListClusterScoped(ctx context.Context, list *unstructured.UnstructuredList, selector labels.Selector) error

func (*DirectClusterReader) ListNamespaceScoped

func (n *DirectClusterReader) ListNamespaceScoped(ctx context.Context, list *unstructured.UnstructuredList, namespace string, selector labels.Selector) error

func (*DirectClusterReader) Sync

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL