controllers

package
v1.0.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnqueueForParentHandler

func EnqueueForParentHandler(q Queue, kind config.GroupVersionKind) func(obj Object)

EnqueueForParentHandler returns a handler that will enqueue the parent (by ownerRef) resource

func FilteredObjectHandler

func FilteredObjectHandler(handler func(o Object), filter func(o Object) bool) cache.ResourceEventHandler

FilteredObjectHandler returns a handler that will act on the latest version of an object This means Add/Update/Delete are all handled the same and are just used to trigger reconciling. If filters are set, returning 'false' will exclude the event. For Add and Deletes, the filter will be based on the new or old item. For updates, the item will be handled if either the new or the old object is updated.

func FilteredObjectSpecHandler

func FilteredObjectSpecHandler(handler func(o Object), filter func(o Object) bool) cache.ResourceEventHandler

FilteredObjectSpecHandler returns a handler that will act on the latest version of an object This means Add/Update/Delete are all handled the same and are just used to trigger reconciling. Unlike FilteredObjectHandler, the handler is only trigger when the resource spec changes (ie resourceVersion) If filters are set, returning 'false' will exclude the event. For Add and Deletes, the filter will be based on the new or old item. For updates, the item will be handled if either the new or the old object is updated.

func IgnoreNotFound

func IgnoreNotFound(err error) error

IgnoreNotFound returns nil on NotFound errors. All other values that are not NotFound errors or nil are returned unmodified.

func ObjectHandler

func ObjectHandler(handler func(o Object)) cache.ResourceEventHandler

ObjectHandler returns a handler that will act on the latest version of an object This means Add/Update/Delete are all handled the same and are just used to trigger reconciling.

func ObjectToGVR

func ObjectToGVR(u Object) (schema.GroupVersionResource, error)

ObjectToGVR extracts the GVR of an unstructured resource. This is useful when using dynamic clients.

func UnstructuredToGVR

UnstructuredToGVR extracts the GVR of an unstructured resource. This is useful when using dynamic clients.

func WithGenericReconciler

func WithGenericReconciler(f func(key interface{}) error) func(q *Queue)

WithGenericReconciler defines the handler function to handle items in the queue that can handle any type

func WithMaxAttempts

func WithMaxAttempts(n int) func(q *Queue)

WithMaxAttempts allows defining a custom max attempts for the queue. If not set, items will not be retried

func WithName

func WithName(name string) func(q *Queue)

WithName sets a name for the queue. This is used for logging

func WithRateLimiter

func WithRateLimiter(r workqueue.RateLimiter) func(q *Queue)

WithRateLimiter allows defining a custom rate limitter for the queue

func WithReconciler

func WithReconciler(f func(key types.NamespacedName) error) func(q *Queue)

WithReconciler defines the handler function to handle items in the queue.

Types

type Object

type Object interface {
	metav1.Object
	runtime.Object
}

Object is a union of runtime + meta objects. Essentially every k8s object meets this interface. and certainly all that we care about.

type Queue

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

Queue defines an abstraction around Kubernetes' workqueue. Items enqueued are deduplicated; this generally means relying on ordering of events in the queue is not feasible.

func NewQueue

func NewQueue(name string, options ...func(*Queue)) Queue

NewQueue creates a new queue

func (Queue) Add

func (q Queue) Add(item interface{})

Add an item to the queue.

func (Queue) AddObject

func (q Queue) AddObject(obj Object)

AddObject takes an Object and adds the types.NamespacedName associated.

func (Queue) HasSynced

func (q Queue) HasSynced() bool

HasSynced returns true if the queue has 'synced'. A synced queue has started running and has processed all events that were added prior to Run() being called Warning: these items will be processed at least once, but may have failed.

func (Queue) Run

func (q Queue) Run(stop <-chan struct{})

Run the queue. This is synchronous, so should typically be called in a goroutine.

Jump to

Keyboard shortcuts

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