informers

package
v0.0.0-...-d7f927e Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PartialObjectMetadataStrip

func PartialObjectMetadataStrip(obj interface{}) (interface{}, error)

PartialObjectMetadataStrip removes the following fields from PartialObjectMetadata objects: * Annotations * Labels * ManagedFields * Finalizers * OwnerReferences.

If the passed object isn't of type *v1.PartialObjectMetadata, it is returned unmodified.

It matches the cache.TransformFunc type and can be used by informers watching PartialObjectMetadata objects to reduce memory consumption. See https://pkg.go.dev/k8s.io/client-go@v0.29.1/tools/cache#TransformFunc for details.

Types

type FactoriesForNamespaces

type FactoriesForNamespaces interface {
	ForResource(namespace string, resource schema.GroupVersionResource) (InformLister, error)
	Namespaces() sets.Set[string]
}

FactoriesForNamespaces is a way to combine several shared informers into a single struct with unified listing power.

func NewKubeInformerFactories

func NewKubeInformerFactories(
	allowNamespaces, denyNamespaces map[string]struct{},
	kubeClient kubernetes.Interface,
	defaultResync time.Duration,
	tweakListOptions func(*metav1.ListOptions),
) FactoriesForNamespaces

NewKubeInformerFactories creates factories for kube resources for the given allowed, and denied namespaces these parameters being mutually exclusive. kubeClient, defaultResync, and tweakListOptions are being passed to the underlying informer factory.

func NewMetadataInformerFactory

func NewMetadataInformerFactory(
	allowNamespaces, denyNamespaces map[string]struct{},
	mdClient metadata.Interface,
	defaultResync time.Duration,
	tweakListOptions func(*metav1.ListOptions),
) FactoriesForNamespaces

NewMetadataInformerFactory creates metadatainformer factory for kube resources for the given allowed, and denied namespaces (these parameters being mutually exclusive). mdClient, defaultResync, and tweakListOptions are passed to the underlying informer factory. factories.

func NewMonitoringInformerFactories

func NewMonitoringInformerFactories(
	allowNamespaces, denyNamespaces map[string]struct{},
	monitoringClient monitoring.Interface,
	defaultResync time.Duration,
	tweakListOptions func(*metav1.ListOptions),
) FactoriesForNamespaces

NewMonitoringInformerFactories creates factories for monitoring resources for the given allowed, and denied namespaces these parameters being mutually exclusive. monitoringClient, defaultResync, and tweakListOptions are being passed to the underlying informer factory.

type ForResource

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

ForResource contains a slice of InformLister for a concrete resource type, one per namespace.

func NewInformersForResource

func NewInformersForResource(ifs FactoriesForNamespaces, resource schema.GroupVersionResource) (*ForResource, error)

NewInformersForResource returns a composite informer exposing the most basic set of operations needed from informers and listers. It does not implement a formal interface, but exposes a minimal set of methods from underlying slice of cache.SharedIndexInformers and cache.GenericListers.

It takes a namespace aware informer factory, wrapped in a FactoriesForNamespaces interface that is able to instantiate an informer for a given namespace.

func NewInformersForResourceWithTransform

func NewInformersForResourceWithTransform(ifs FactoriesForNamespaces, resource schema.GroupVersionResource, handler cache.TransformFunc) (*ForResource, error)

func (*ForResource) AddEventHandler

func (w *ForResource) AddEventHandler(handler cache.ResourceEventHandler)

AddEventHandler registers the given handler to all wrapped informers.

func (*ForResource) Get

func (w *ForResource) Get(name string) (runtime.Object, error)

Get invokes all wrapped informers and returns the first found runtime object. It returns the first ocured error.

func (*ForResource) GetInformers

func (w *ForResource) GetInformers() []InformLister

GetInformers returns all wrapped informers.

func (*ForResource) HasSynced

func (w *ForResource) HasSynced() bool

HasSynced returns true if all underlying informers have synced, else false.

func (*ForResource) ListAll

func (w *ForResource) ListAll(selector labels.Selector, appendFn cache.AppendFunc) error

ListAll invokes the ListAll method for all wrapped informers passing the same selector and appendFn.

func (*ForResource) ListAllByNamespace

func (w *ForResource) ListAllByNamespace(namespace string, selector labels.Selector, appendFn cache.AppendFunc) error

ListAllByNamespace invokes all wrapped informers passing the same appendFn. While wrapped informers are usually namespace aware, it is still important to iterate over all of them as some informers might wrap k8s.io/apimachinery/pkg/apis/meta/v1.NamespaceAll.

func (*ForResource) Start

func (w *ForResource) Start(stopCh <-chan struct{})

Start starts all underlying informers, passing the given stop channel to each of them.

type InformLister

type InformLister interface {
	Informer() cache.SharedIndexInformer
	Lister() cache.GenericLister
}

InformLister is the interface that both exposes a shared index informer and a generic lister. Usually generated clients declare this interface as "GenericInformer".

Jump to

Keyboard shortcuts

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