dynamiccache

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2023 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Overview

taken from sigs.k8s.io/controller-runtime@v0.12.3/pkg/cache/internal/selector.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FieldIndexName

func FieldIndexName(field string) string

FieldIndexName constructs the name of the index over the given field, for use with an indexer.

func KeyToNamespacedKey

func KeyToNamespacedKey(ns string, baseKey string) string

KeyToNamespacedKey prefixes the given index key with a namespace for use in field selector indexes.

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

func NewCache

func NewCache(
	config *rest.Config,
	scheme *runtime.Scheme,
	mapper meta.RESTMapper,
	recorder metricsRecorder,
	opts ...CacheOption,
) *Cache

func (*Cache) Free

func (c *Cache) Free(
	ctx context.Context, owner client.Object,
) error

Free all watches associated with the given owner.

func (*Cache) Get

func (c *Cache) Get(
	ctx context.Context,
	key client.ObjectKey, out client.Object,
	opts ...client.GetOption,
) error

Get implements client.Reader.

func (*Cache) List

func (c *Cache) List(
	ctx context.Context,
	out client.ObjectList, opts ...client.ListOption,
) error

List implements client.Reader.

func (*Cache) OwnersForGKV

func (c *Cache) OwnersForGKV(gvk schema.GroupVersionKind) []OwnerReference

Returns all owners registered watching the given GroupVersionKind.

func (*Cache) Source

func (c *Cache) Source() source.Source

func (*Cache) Start

func (c *Cache) Start(context.Context) error

Start implements manager.Runnable. While this cache is not running workers itself, we use it to block registration of new event handlers in the cache source.

func (*Cache) String

func (c *Cache) String() string

For printing in startup log messages.

func (*Cache) Watch

func (c *Cache) Watch(
	ctx context.Context, owner client.Object, obj runtime.Object,
) error

Watch the given object type and associate the watch with the given owner.

type CacheNotStartedError

type CacheNotStartedError struct{}

CacheNotStartedError is returned when trying to read from a cache before starting a watch.

func (CacheNotStartedError) Error

func (CacheNotStartedError) Error() string

type CacheOption

type CacheOption interface {
	ApplyToCacheOptions(opts *CacheOptions)
}

CacheOption customizes an informer creation and cache behavior.

type CacheOptions

type CacheOptions struct {
	// Custom cache indexes.
	Indexers FieldIndexersByGVK
	// Selectors filter caches on the api server.
	Selectors SelectorsByGVK
	// Time between full cache resyncs.
	ResyncInterval time.Duration
}

CacheOptions holds all Cache configuration parameters.

func (*CacheOptions) Default

func (co *CacheOptions) Default()

type CacheReader

type CacheReader struct {
	// contains filtered or unexported fields
}

CacheReader wraps a cache.Index to implement the client.CacheReader interface for a single type.

func (*CacheReader) Get

Get checks the indexer for the object and writes a copy of it if found.

func (*CacheReader) List

List lists items out of the indexer and writes them to out.

type EnqueueWatchingObjects

type EnqueueWatchingObjects struct {
	WatcherRefGetter ownerRefGetter
	// WatcherType is the type of the Owner object to look for in OwnerReferences.  Only Group and Kind are compared.
	WatcherType runtime.Object
	// contains filtered or unexported fields
}

Enqueues all objects watching the object mentioned in the event, filtered by WatcherType.

func (*EnqueueWatchingObjects) Create

func (*EnqueueWatchingObjects) Delete

func (*EnqueueWatchingObjects) Generic

func (*EnqueueWatchingObjects) InjectScheme

func (e *EnqueueWatchingObjects) InjectScheme(s *runtime.Scheme) error

InjectScheme is called by the Controller to provide a singleton scheme to the EnqueueRequestForOwner.

func (*EnqueueWatchingObjects) Update

type FieldIndexer

type FieldIndexer struct {
	// Field name to refer to the index later.
	Field string
	// IndexFunc extracts the indexed values from objects.
	Indexer client.IndexerFunc
}

FieldIndexer adds a custom index to the cache.

type FieldIndexersByGVK

type FieldIndexersByGVK map[schema.GroupVersionKind][]FieldIndexer

FieldIndexers by GroupVersionKind.

func (FieldIndexersByGVK) ApplyToCacheOptions

func (fi FieldIndexersByGVK) ApplyToCacheOptions(opts *CacheOptions)

type InformerMap

type InformerMap struct {
	// contains filtered or unexported fields
}

InformerMap caches informers and enables to shut them down later.

func NewInformerMap

func NewInformerMap(
	config *rest.Config,
	scheme *runtime.Scheme,
	mapper apimetav1.RESTMapper,
	resync time.Duration,
	selectors SelectorsByGVK,
	indexers FieldIndexersByGVK,
) *InformerMap

func (*InformerMap) Delete

func (im *InformerMap) Delete(
	_ context.Context,
	gvk schema.GroupVersionKind,
) error

Delete shuts down an informer for the given GVK, if one is registered.

func (*InformerMap) Get

func (im *InformerMap) Get(
	ctx context.Context,
	gvk schema.GroupVersionKind,
	obj runtime.Object,
) (informer cache.SharedIndexInformer, reader client.Reader, err error)

Get returns a informer for the given GVK. If no informer is registered, a new Informer will be created.

type OwnerReference

type OwnerReference struct {
	schema.GroupKind
	UID       types.UID
	Name      string
	Namespace string
}

OwnerReference points to a single owner of a watch operation.

type ResyncInterval

type ResyncInterval time.Duration

Time between full cache resyncs. A 10 percent jitter will be added to the resync period between informers, so that all informers will not send list requests simultaneously.

type Selector

type Selector struct {
	Label labels.Selector
	Field fields.Selector
}

Selector specify the label/field selector to fill in ListOptions.

func (Selector) ApplyToList

func (s Selector) ApplyToList(listOpts *metav1.ListOptions)

ApplyToList fill in ListOptions LabelSelector and FieldSelector if needed.

type SelectorsByGVK

type SelectorsByGVK map[schema.GroupVersionKind]Selector

SelectorsByGVK associate a GroupVersionKind to a field/label selector.

func (SelectorsByGVK) ApplyToCacheOptions

func (s SelectorsByGVK) ApplyToCacheOptions(opts *CacheOptions)

defined here, so we don't have to change selector.go, taken from controller-runtime.

Jump to

Keyboard shortcuts

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