callbacks

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2024 License: Apache-2.0 Imports: 9 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CallbackDispatcher

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

CallbackDispatcher manages and executes resource callbacks

func NewCallbackDispatcher

func NewCallbackDispatcher(log logr.Logger, client, uncachedClient client.Client, scheme *runtime.Scheme, namespace string) *CallbackDispatcher

NewCallbackDispatcher creates new callback dispatcher

func (*CallbackDispatcher) AddCallback

func (cd *CallbackDispatcher) AddCallback(obj client.Object, cb ReconcileCallback)

AddCallback registers a callback for given object type

func (*CallbackDispatcher) InvokeCallbacks

func (cd *CallbackDispatcher) InvokeCallbacks(l logr.Logger, cr interface{}, s ReconcileState, desiredObj, currentObj client.Object, recorder record.EventRecorder) error

InvokeCallbacks executes callbacks for desired/current object type

type ReconcileCallback

type ReconcileCallback func(args *ReconcileCallbackArgs) error

ReconcileCallback is the callback function

type ReconcileCallbackArgs

type ReconcileCallbackArgs struct {
	Logger    logr.Logger
	Client    client.Client
	Scheme    *runtime.Scheme
	Recorder  record.EventRecorder
	Namespace string
	Resource  interface{}

	State         ReconcileState
	DesiredObject client.Object
	CurrentObject client.Object
}

ReconcileCallbackArgs contains the data of a ReconcileCallback

type ReconcileState

type ReconcileState string

ReconcileState is the current state of the reconcile for a particuar resource

const (
	// ReconcileStatePreCreate is the state before a resource is created
	ReconcileStatePreCreate ReconcileState = "PRE_CREATE"
	// ReconcileStatePostCreate is the state sfter a resource is created
	ReconcileStatePostCreate ReconcileState = "POST_CREATE"

	// ReconcileStatePostRead is the state sfter a resource is read
	ReconcileStatePostRead ReconcileState = "POST_READ"

	// ReconcileStatePreUpdate is the state before a resource is updated
	ReconcileStatePreUpdate ReconcileState = "PRE_UPDATE"
	// ReconcileStatePostUpdate is the state after a resource is updated
	ReconcileStatePostUpdate ReconcileState = "POST_UPDATE"

	// ReconcileStatePreDelete is the state before a resource is explicitly deleted (probably during upgrade)
	// don't count on this always being called for your resource
	// ideally we just let garbage collection do it's thing
	ReconcileStatePreDelete ReconcileState = "PRE_DELETE"
	// ReconcileStatePostDelete is the state after a resource is explicitly deleted (probably during upgrade)
	// don't count on this always being called for your resource
	// ideally we just let garbage collection do it's thing
	ReconcileStatePostDelete ReconcileState = "POST_DELETE"

	// ReconcileStateOperatorDelete is called during CR finalizer
	ReconcileStateOperatorDelete ReconcileState = "OPERATOR_DELETE"
)

Jump to

Keyboard shortcuts

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