informer

package
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2024 License: Apache-2.0 Imports: 31 Imported by: 22

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCRDGVRSource added in v0.11.0

func NewCRDGVRSource(informer cache.SharedIndexInformer) (*crdGVRSource, error)

NewCRDGVRSource returns a GVRSource based on CRDs watched in the given informer.

Types

type ClusterGetter added in v0.20.0

type ClusterGetter[R runtime.Object, G Getter[R]] interface {
	Cluster(name logicalcluster.Name) G
}

ClusterGetter is a cluster-aware Getter API.

type ClusterLister added in v0.20.0

type ClusterLister[R runtime.Object, L Lister[R]] interface {
	Cluster(name logicalcluster.Name) L
}

ClusterLister is a cluster-aware Lister API.

type DiscoveringDynamicSharedInformerFactory added in v0.11.0

DiscoveringDynamicSharedInformerFactory is a factory for cluster-aware shared informers that discovers new types and informs on updates to resources of those types. It offers an additional `Cluster()` method that returns a new shared informer factory based on the main informer factory, but scoped for a given logical cluster.

func NewDiscoveringDynamicSharedInformerFactory added in v0.11.0

func NewDiscoveringDynamicSharedInformerFactory(
	dynamicClusterClient kcpdynamic.ClusterInterface,
	filterFunc func(obj interface{}) bool,
	tweakListOptions dynamicinformer.TweakListOptionsFunc,
	gvrSource GVRSource,
	indexers cache.Indexers,
) (*DiscoveringDynamicSharedInformerFactory, error)

NewDiscoveringDynamicSharedInformerFactory returns a factory for cluster-aware shared informers that discovers new types and informs on updates to resources of those types. It receives the GVR-related information by delegating to a GVRSource.

func (*DiscoveringDynamicSharedInformerFactory) Cluster added in v0.11.0

type FallbackGetFunc added in v0.20.0

type FallbackGetFunc[R runtime.Object] func(name string) (R, error)

FallbackGetFunc is a function that returns an instance of R from either local or global informer Listers based on a name.

func NewGetterWithFallback added in v0.20.0

func NewGetterWithFallback[R runtime.Object](localGetter, globalGetter Getter[R]) FallbackGetFunc[R]

NewGetterWithFallback creates a new FallbackGetFunc that gets an object of type R first looking in the local lister, then in the global lister if not found.

type FallbackListFunc added in v0.20.0

type FallbackListFunc[R runtime.Object] func(selector labels.Selector) ([]R, error)

FallbackListFunc is a function that returns []R from either local or global informer Listers based on a label selector.

func NewListerWithFallback added in v0.20.0

func NewListerWithFallback[R runtime.Object](localLister Lister[R], globalLister Lister[R]) FallbackListFunc[R]

NewListerWithFallback creates a new FallbackListFunc that looks up an object of type R first in the local lister, then in the global lister if no local results are found.

type GVREventHandler

type GVREventHandler interface {
	OnAdd(gvr schema.GroupVersionResource, obj interface{})
	OnUpdate(gvr schema.GroupVersionResource, oldObj, newObj interface{})
	OnDelete(gvr schema.GroupVersionResource, obj interface{})
}

GVREventHandler is an event handler that includes the GroupVersionResource of the resource being handled.

type GVREventHandlerFuncs

type GVREventHandlerFuncs struct {
	AddFunc    func(gvr schema.GroupVersionResource, obj interface{})
	UpdateFunc func(gvr schema.GroupVersionResource, oldObj, newObj interface{})
	DeleteFunc func(gvr schema.GroupVersionResource, obj interface{})
}

func (GVREventHandlerFuncs) OnAdd

func (g GVREventHandlerFuncs) OnAdd(gvr schema.GroupVersionResource, obj interface{})

func (GVREventHandlerFuncs) OnDelete

func (g GVREventHandlerFuncs) OnDelete(gvr schema.GroupVersionResource, obj interface{})

func (GVREventHandlerFuncs) OnUpdate

func (g GVREventHandlerFuncs) OnUpdate(gvr schema.GroupVersionResource, oldObj, newObj interface{})

type GVRPartialMetadata added in v0.11.0

type GVRPartialMetadata struct {
	Names apiextensionsv1.CustomResourceDefinitionNames
	Scope apiextensionsv1.ResourceScope
}

GVRPartialMetadata provides the required metadata about a GVR for which an informer should be started.

type GVRSource added in v0.11.0

type GVRSource interface {
	// GVRs returns the required metadata about all GVRs known by the GVRSource
	GVRs() map[schema.GroupVersionResource]GVRPartialMetadata

	// Ready returns true if the GVRSource is ready to return available GVRs.
	// For informer-based GVRSources (watching CRDs for example), it would return true if the underlying
	// informer is synced.
	Ready() bool

	// Subscribe returns a new channel to which the GVRSource writes whenever
	// its list of known GVRs has changed
	Subscribe() <-chan struct{}
}

GVRSource is a source of information about available GVRs, and provides a way to register for changes in the available GVRs (addition or removal) so that the list of informers can be updated.

type GenericDiscoveringDynamicSharedInformerFactory added in v0.11.0

type GenericDiscoveringDynamicSharedInformerFactory[Informer cache.SharedIndexInformer, Lister genericListerBase, GenericInformer genericInformerBase[Informer, Lister]] struct {
	// contains filtered or unexported fields
}

GenericDiscoveringDynamicSharedInformerFactory is a SharedInformerFactory that dynamically discovers new types and begins informing on them. It is a generic implementation for both logical-cluster-aware and logical-cluster-unaware (== single cluster, standard kube) informers.

func NewGenericDiscoveringDynamicSharedInformerFactory added in v0.11.0

func NewGenericDiscoveringDynamicSharedInformerFactory[Informer cache.SharedIndexInformer, Lister genericListerBase, GenericInformer genericInformerBase[Informer, Lister]](
	newInformer func(gvr schema.GroupVersionResource, resyncPeriod time.Duration, indexers cache.Indexers) GenericInformer,
	filterFunc func(obj interface{}) bool,
	gvrSource GVRSource,
	indexers cache.Indexers,
) (*GenericDiscoveringDynamicSharedInformerFactory[Informer, Lister, GenericInformer], error)

NewGenericDiscoveringDynamicSharedInformerFactory returns is an informer factory that dynamically discovers new types and begins informing on them. It is a generic implementation for both logical-cluster-aware and logical-cluster-unaware (== single cluster, standard kube) informers.

func NewScopedDiscoveringDynamicSharedInformerFactory added in v0.11.0

func NewScopedDiscoveringDynamicSharedInformerFactory(
	dynamicClient dynamic.Interface,
	filterFunc func(obj interface{}) bool,
	tweakListOptions dynamicinformer.TweakListOptionsFunc,
	gvrSource GVRSource,
	indexers cache.Indexers,
) (*GenericDiscoveringDynamicSharedInformerFactory[cache.SharedIndexInformer, cache.GenericLister, informers.GenericInformer], error)

NewScopedDiscoveringDynamicSharedInformerFactory returns a factory for cluster-unaware (standard Kube) shared informers that discovers new types and informs on updates to resources of those types. It receives the GVR-related information by delegating to a GVRSource.

func (*GenericDiscoveringDynamicSharedInformerFactory[Informer, Lister, GenericInformer]) AddEventHandler added in v0.11.0

func (d *GenericDiscoveringDynamicSharedInformerFactory[Informer, Lister, GenericInformer]) AddEventHandler(handler GVREventHandler)

func (*GenericDiscoveringDynamicSharedInformerFactory[Informer, Lister, GenericInformer]) ForResource added in v0.11.0

func (d *GenericDiscoveringDynamicSharedInformerFactory[Informer, Lister, GenericInformer]) ForResource(gvr schema.GroupVersionResource) (GenericInformer, error)

ForResource returns the GenericInformer for gvr, creating it if needed. The GenericInformer must be started by calling Start on the GenericDiscoveringDynamicSharedInformerFactory before the GenericInformer can be used.

func (*GenericDiscoveringDynamicSharedInformerFactory[Informer, Lister, GenericInformer]) Informers added in v0.11.0

func (d *GenericDiscoveringDynamicSharedInformerFactory[Informer, Lister, GenericInformer]) Informers() (informers map[schema.GroupVersionResource]GenericInformer, notSynced []schema.GroupVersionResource)

Informers returns a map of per-resource-type generic informers for all types that are known by this informer factory, and that are synced.

If any informers aren't synced, their GVRs are returned so that they can be checked and processed later.

func (*GenericDiscoveringDynamicSharedInformerFactory[Informer, Lister, GenericInformer]) RESTMapper added in v0.11.0

func (d *GenericDiscoveringDynamicSharedInformerFactory[Informer, Lister, GenericInformer]) RESTMapper() meta.ResettableRESTMapper

func (*GenericDiscoveringDynamicSharedInformerFactory[Informer, Lister, GenericInformer]) ServerGroupsAndResources added in v0.11.0

func (d *GenericDiscoveringDynamicSharedInformerFactory[Informer, Lister, GenericInformer]) ServerGroupsAndResources() ([]*metav1.APIGroup, []*metav1.APIResourceList, error)

func (*GenericDiscoveringDynamicSharedInformerFactory[Informer, Lister, GenericInformer]) ServerPreferredNamespacedResources added in v0.11.0

func (d *GenericDiscoveringDynamicSharedInformerFactory[Informer, Lister, GenericInformer]) ServerPreferredNamespacedResources() ([]*metav1.APIResourceList, error)

func (*GenericDiscoveringDynamicSharedInformerFactory[Informer, Lister, GenericInformer]) ServerPreferredResources added in v0.11.0

func (d *GenericDiscoveringDynamicSharedInformerFactory[Informer, Lister, GenericInformer]) ServerPreferredResources() ([]*metav1.APIResourceList, error)

func (*GenericDiscoveringDynamicSharedInformerFactory[Informer, Lister, GenericInformer]) ServerResourcesForGroupVersion added in v0.11.0

func (d *GenericDiscoveringDynamicSharedInformerFactory[Informer, Lister, GenericInformer]) ServerResourcesForGroupVersion(groupVersion string) (*metav1.APIResourceList, error)

func (*GenericDiscoveringDynamicSharedInformerFactory[Informer, Lister, GenericInformer]) Start added in v0.11.0

func (d *GenericDiscoveringDynamicSharedInformerFactory[Informer, Lister, GenericInformer]) Start(_ <-chan struct{})

Start starts any informers that have been created but not yet started. The passed in stop channel is ignored; instead, a new stop channel is created, so the factory can properly stop the informer if/when the API is removed. Like other shared informer factories, this call is non-blocking.

func (*GenericDiscoveringDynamicSharedInformerFactory[Informer, Lister, GenericInformer]) StartWorker added in v0.11.0

func (d *GenericDiscoveringDynamicSharedInformerFactory[Informer, Lister, GenericInformer]) StartWorker(ctx context.Context)

StartWorker starts the worker that waits for notifications that informer updates are needed. This call is blocking, stopping when ctx.Done() is closed.

func (*GenericDiscoveringDynamicSharedInformerFactory[Informer, Lister, GenericInformer]) Subscribe added in v0.11.0

func (d *GenericDiscoveringDynamicSharedInformerFactory[Informer, Lister, GenericInformer]) Subscribe(id string) <-chan struct{}

Subscribe registers for informer/discovery change notifications, returning a channel to which change notifications are sent.

func (*GenericDiscoveringDynamicSharedInformerFactory[Informer, Lister, GenericInformer]) Unsubscribe added in v0.11.0

func (d *GenericDiscoveringDynamicSharedInformerFactory[Informer, Lister, GenericInformer]) Unsubscribe(id string)

Unsubscribe removes the channel associated with id from future informer/discovery change notifications.

type Getter added in v0.20.0

type Getter[R runtime.Object] interface {
	Get(name string) (R, error)
}

Getter is a GetAPI call with generics.

type Lister added in v0.20.0

type Lister[R runtime.Object] interface {
	List(labels.Selector) ([]R, error)
}

Lister is a Lister API with generics.

type ScopedFallbackGetFunc added in v0.20.0

type ScopedFallbackGetFunc[R runtime.Object] func(clusterName logicalcluster.Name, name string) (R, error)

ScopedFallbackGetFunc is a function that returns an instance of R from either local or global cluster-scoped informer Listers based on a name.

func NewScopedGetterWithFallback added in v0.20.0

func NewScopedGetterWithFallback[R runtime.Object, G Getter[R]](localGetter, globalGetter ClusterGetter[R, G]) ScopedFallbackGetFunc[R]

NewScopedGetterWithFallback creates a new ScopedFallbackGetFunc that gets an object of type R within a given cluster path. The local lister is checked first, and if nothing is found, the global lister is checked.

Jump to

Keyboard shortcuts

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