tracker

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2024 License: Apache-2.0 Imports: 13 Imported by: 2

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.

Imported from https://github.com/knative/pkg/tree/db8a35330281c41c7e8e90df6059c23a36af0643/tracker liberated from Knative runtime dependencies and evolved to better fit controller-runtime patterns.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Key deprecated

type Key struct {
	GroupKind      schema.GroupKind
	NamespacedName types.NamespacedName
}

Deprecated: use Reference

func NewKey deprecated

func NewKey(gvk schema.GroupVersionKind, namespacedName types.NamespacedName) Key

Deprecated: use Reference

type Reference

type Reference struct {
	// APIGroup of the referent.
	// +optional
	APIGroup string

	// Kind of the referent.
	// +optional
	Kind string

	// Namespace of the referent.
	// +optional
	Namespace string

	// Name of the referent.
	// Mutually exclusive with Selector.
	// +optional
	Name string

	// Selector of the referents.
	// Mutually exclusive with Name.
	// +optional
	Selector labels.Selector
}

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

APIVersion is reduce to APIGroup as the version of a tracked object is irrelevant.

type Tracker

type Tracker interface {
	// TrackReference tells us that "obj" is tracking changes to the
	// referenced object.
	TrackReference(ref Reference, obj client.Object) error

	// TrackObject tells us that "obj" is tracking changes to the
	// referenced object.
	TrackObject(ref client.Object, obj client.Object) error

	// GetObservers returns the names of all observers for the given
	// object.
	GetObservers(obj client.Object) ([]types.NamespacedName, error)
}

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

func New

func New(scheme *runtime.Scheme, lease time.Duration) Tracker

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.

Jump to

Keyboard shortcuts

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