tracker

package
v0.0.0-...-f3ab560 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 14 Imported by: 302

Documentation

Overview

Package tracker defines a utility to enable Reconcilers to trigger reconciliations when objects that are cross-referenced change, so that the level-based reconciliation can react to the change. The prototypical cross-reference in Kubernetes is corev1.ObjectReference.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interface

type Interface interface {
	// Track tells us that "obj" is tracking changes to the
	// referenced object.
	//
	// Deprecated: use TrackReference.
	Track(ref corev1.ObjectReference, obj interface{}) error

	// Track tells us that "obj" is tracking changes to the
	// referenced object.
	TrackReference(ref Reference, obj interface{}) error

	// OnChanged is a callback to register with the InformerFactory
	// so that we are notified for appropriate object changes.
	OnChanged(obj interface{})

	// GetObservers returns the names of all observers for the given
	// object.
	GetObservers(obj interface{}) []types.NamespacedName

	// OnDeletedObserver is a callback to register with the InformerFactory
	// so that we are notified for deletions of a watching parent to
	// remove the respective tracking.
	OnDeletedObserver(obj interface{})
}

Interface defines the interface through which an object can register that it is tracking another object by reference.

func New

func New(callback func(types.NamespacedName), lease time.Duration) Interface

New returns an implementation of Interface that lets a Reconciler register a particular resource as watching an ObjectReference for a particular lease duration. This watch must be refreshed periodically (e.g. by a controller resync) or it will expire.

When OnChanged is called by the informer for a particular GroupVersionKind, the provided callback is called with the "key" of each object actively watching the changed object.

type Reference

type Reference struct {
	// API version of the referent.
	// +optional
	APIVersion string `json:"apiVersion,omitempty"`

	// Kind of the referent.
	// +optional
	Kind string `json:"kind,omitempty"`

	// Namespace of the referent.
	// +optional
	Namespace string `json:"namespace,omitempty"`

	// Name of the referent.
	// Mutually exclusive with Selector.
	// +optional
	Name string `json:"name,omitempty"`

	// Selector of the referents.
	// Mutually exclusive with Name.
	// +optional
	Selector *metav1.LabelSelector `json:"selector,omitempty"`
}

Reference is modeled after corev1.ObjectReference, but omits fields unsupported by the tracker, and permits us to extend things in divergent ways.

func (*Reference) DeepCopy

func (in *Reference) DeepCopy() *Reference

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Reference.

func (*Reference) DeepCopyInto

func (in *Reference) DeepCopyInto(out *Reference)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*Reference) GroupVersionKind

func (ref *Reference) GroupVersionKind() schema.GroupVersionKind

GroupVersionKind returns the GroupVersion of the object referenced.

func (*Reference) ObjectReference

func (ref *Reference) ObjectReference() corev1.ObjectReference

ObjectReference returns the tracker Reference as an ObjectReference.

func (*Reference) Validate

func (ref *Reference) Validate(ctx context.Context) *apis.FieldError

func (*Reference) ValidateObjectReference

func (ref *Reference) ValidateObjectReference(ctx context.Context) *apis.FieldError

ValidateObjectReference validates that the Reference uses a subset suitable for translation to a corev1.ObjectReference. This helper is intended to simplify validating a particular (narrow) use of tracker.Reference.

Jump to

Keyboard shortcuts

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