controller

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: Apache-2.0, BSD-2-Clause, MIT, + 1 more Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(mgr manager.Manager, args AddArgs) error

Add creates a new controller and adds it to the given manager using the given args.

func DefaultPredicates

func DefaultPredicates() []predicate.Predicate

DefaultPredicates returns the default predicates for a reconciler.

func MapFuncFromMapper added in v0.9.0

func MapFuncFromMapper(mapper Mapper) handler.MapFunc

MapFuncFromMapper returns handler.MapFunc that uses the given mapper to map the given object to the object key of a different object and returns a reconcile.Request for that key if it's not empty.

func NewOwnedObjectPredicate added in v0.9.0

func NewOwnedObjectPredicate(ownerType client.Object, reader client.Reader, ownerMapper Mapper, finalizer string, logger logr.Logger) predicate.Predicate

NewOwnedObjectPredicate creates a new predicate that filters only relevant owned object events, such as creating or updating an object without an owner or with an owner that is being deleted, or deleting an object with an owner that is not being deleted.

func NewReconciler

func NewReconciler(actuator Actuator, controllerName, finalizerName string, typ client.Object, shouldEnsureDeleted bool, logger logr.Logger) reconcile.Reconciler

NewReconciler creates a new generic Reconciler.

Types

type Actuator

type Actuator interface {
	// CreateOrUpdate reconciles object creation or update.
	CreateOrUpdate(context.Context, client.Object) (time.Duration, error)
	// Delete reconciles object deletion.
	Delete(context.Context, client.Object) (time.Duration, error)
	// ShouldFinalize returns true if the object should be finalized.
	ShouldFinalize(context.Context, client.Object) (bool, error)
}

Actuator acts upon objects being reconciled by a Reconciler.

type AddArgs

type AddArgs struct {
	// Actuator is an actuator.
	Actuator Actuator
	// ControllerName is the name of the controller.
	ControllerName string
	// FinalizerName is the finalizer name.
	FinalizerName string
	// ControllerOptions are the controller options to use when creating a controller.
	// The Reconciler field is always overridden with a reconciler created from the given actuator.
	ControllerOptions controller.Options
	// Type is the object type to watch.
	Type client.Object
	// ShouldEnsureDeleted specifies that the controller should ensure the object is properly deleted on not found.
	ShouldEnsureDeleted bool
	// Predicates are the predicates to use when watching objects.
	Predicates []predicate.Predicate
	// WatchBuilder defines additional watches that should be set up.
	WatchBuilder extensionscontroller.WatchBuilder
}

AddArgs are arguments for adding a controller to a manager.

type Mapper added in v0.9.0

type Mapper interface {
	// Map maps the given object to the object key of a different object.
	Map(obj client.Object) client.ObjectKey
}

Mapper maps an object to the object key of a different object.

func NewLabelMapper added in v0.9.0

func NewLabelMapper(objectLabeler ObjectLabeler, label string) Mapper

NewLabelMapper creates a mapper that uses GetNamespacedName of the given ObjectLabeler with the given label.

type ObjectLabeler added in v0.9.0

type ObjectLabeler interface {
	// GetLabelValue returns a label value that uniquely identifies the given object.
	GetLabelValue(obj client.Object) string
	// GetNamespacedName returns types.NamespacedName from the given label value.
	GetNamespacedName(labelValue string) types.NamespacedName
}

ObjectLabeler provides methods for creating a label value that uniquely identifies an object, as well as creating a namespaced name from such a label value.

func NewClusterObjectLabeler added in v0.9.0

func NewClusterObjectLabeler() ObjectLabeler

NewClusterObjectLabeler creates an ObjectLabeler that is appropriate for cluster objects. It uses the object name as the label value.

func NewNamespacedObjectLabeler added in v0.9.0

func NewNamespacedObjectLabeler(separator string) ObjectLabeler

NewNamespacedObjectLabeler creates an ObjectLabeler that is appropriate for namespaced objects. It uses the object namespace and name separated by the given separator as the label value.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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