controller-runtimesigs.k8s.io/controller-runtime/pkg/cache/internal Index | Files

package internal

import "sigs.k8s.io/controller-runtime/pkg/cache/internal"

Index

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 {
	// Informer is the cached informer
	Informer cache.SharedIndexInformer

	// CacheReader wraps Informer and implements the CacheReader interface for a single type
	Reader CacheReader
	// contains filtered or unexported fields
}

Cache contains the cached data for an Cache.

func (*Cache) Start

func (c *Cache) Start(stop <-chan struct{})

Start starts the informer managed by a MapEntry. Blocks until the informer stops. The informer can be stopped either individually (via the entry's stop channel) or globally via the provided stop argument.

type CacheReader

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

CacheReader wraps a cache.Index to implement the client.Reader 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 GetOptions

type GetOptions struct {
	// BlockUntilSynced controls if the informer retrieval will block until the informer is synced. Defaults to `true`.
	BlockUntilSynced *bool
}

GetOptions provides configuration to customize the behavior when getting an informer.

type Informers

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

Informers create and caches Informers for (runtime.Object, schema.GroupVersionKind) pairs. It uses a standard parameter codec constructed based on the given generated Scheme.

func NewInformers

func NewInformers(config *rest.Config, options *InformersOpts) *Informers

NewInformers creates a new InformersMap that can create informers under the hood.

func (*Informers) Get

Get will create a new Informer and add it to the map of specificInformersMap if none exists. Returns the Informer from the map.

func (*Informers) Peek

func (ip *Informers) Peek(gvk schema.GroupVersionKind, obj runtime.Object) (res *Cache, started bool, ok bool)

Peek attempts to get the informer for the GVK, but does not start one if one does not exist.

func (*Informers) Remove

func (ip *Informers) Remove(gvk schema.GroupVersionKind, obj runtime.Object)

Remove removes an informer entry and stops it if it was running.

func (*Informers) Start

func (ip *Informers) Start(ctx context.Context) error

Start calls Run on each of the informers and sets started to true. Blocks on the context. It doesn't return start because it can't return an error, and it's not a runnable directly.

func (*Informers) WaitForCacheSync

func (ip *Informers) WaitForCacheSync(ctx context.Context) bool

WaitForCacheSync waits until all the caches have been started and synced.

type InformersOpts

type InformersOpts struct {
	HTTPClient            *http.Client
	Scheme                *runtime.Scheme
	Mapper                meta.RESTMapper
	ResyncPeriod          time.Duration
	Namespace             string
	NewInformer           func(cache.ListerWatcher, runtime.Object, time.Duration, cache.Indexers) cache.SharedIndexInformer
	Selector              Selector
	Transform             cache.TransformFunc
	UnsafeDisableDeepCopy bool
	EnableWatchBookmarks  bool
	WatchErrorHandler     cache.WatchErrorHandler
}

InformersOpts configures an InformerMap.

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.

Source Files

cache_reader.go informers.go selector.go

Version
v0.20.4 (latest)
Published
Mar 24, 2025
Platform
linux/amd64
Imports
25 packages
Last checked
2 days ago

Tools for package owners.