phases

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: MIT Imports: 11 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckReadyPhase

func CheckReadyPhase(r workload.Reconciler, req *workload.Request) (bool, error)

CheckReadyPhase executes checking for a parent component's readiness status.

func CompletePhase

func CompletePhase(r workload.Reconciler, req *workload.Request) (bool, error)

CompletePhase executes the completion of a reconciliation loop.

func CreateOrUpdate

func CreateOrUpdate(r workload.Reconciler, req *workload.Request, resource client.Object) error

CreateOrUpdate creates a resource if it does not already exist or updates a resource if it does already exist.

func CreateResourcesPhase

func CreateResourcesPhase(r workload.Reconciler, req *workload.Request) (bool, error)

CreateResourcesPhase creates or updated the child resources of a workload during a reconciliation loop.

func DeletionCompletePhase

func DeletionCompletePhase(r workload.Reconciler, req *workload.Request) (bool, error)

DeletionCompletePhase executes the completion of a reconciliation loop for a delete request.

func DependencyPhase

func DependencyPhase(r workload.Reconciler, req *workload.Request) (bool, error)

DependencyPhase executes a dependency check prior to attempting to create resources.

func HandleResourcePhaseExit

func HandleResourcePhaseExit(
	resourceCreated bool,
	resourceErr error,
) (status.ChildResourceCondition, bool, error)

HandleResourcePhaseExit will generate the appropriate resource condition for a resource creation event.

func IsOptimisticLockError

func IsOptimisticLockError(err error) bool

IsOptimisticLockError checks to see if the error is a locking error.

func RegisterDeleteHooks

func RegisterDeleteHooks(r workload.Reconciler, req *workload.Request) error

RegisterDeleteHooks add finializers to the workload resources so that the delete lifecycle can be run beofre the object is deleted.

func UpdateResourceConditions

func UpdateResourceConditions(
	r workload.Reconciler,
	req *workload.Request,
	resource *status.ChildResource,
) error

UpdateResourceConditions updates the status.resourceConditions field of the parent custom resource.

Types

type HandlerFunc

type HandlerFunc func(r workload.Reconciler, req *workload.Request) (proceed bool, err error)

HandlerFunc is an adapter to allow the use of ordinary functions as reconcile phases. If the function has the appropriate signature, it will considered a valid phase handler.

type LifecycleEvent

type LifecycleEvent int32

LifecycleEvent is used to convey which lifecycle event we are targeting.

const (
	CreateEvent LifecycleEvent = iota
	UpdateEvent
	DeleteEvent
)

type Phase

type Phase struct {
	Name string
	// contains filtered or unexported fields
}

Phase defines a phase of the reconciliation process.

func (*Phase) DefaultReconcileResult

func (p *Phase) DefaultReconcileResult() ctrl.Result

DefaultReconcileResult will return the default reconcile result when requeuing is not needed.

func (*Phase) Requeue

func (p *Phase) Requeue() ctrl.Result

Requeue will return the phase's reconcile result when requeueing is needed.

type PhaseOption

type PhaseOption func(*Phase)

PhaseOption is a function pattern to allow customization of a phase upon registration.

func WithCustomRequeueResult

func WithCustomRequeueResult(requeueResult ctrl.Result) PhaseOption

WithCustomRequeueResult allows you to define a custom result for a phase when it is requeued, this allows for custom requeue time backoffs.

type Registry

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

Registry is a store for all the phases for each event loop.

func (*Registry) Execute

func (registry *Registry) Execute(r workload.Reconciler, req *workload.Request, event LifecycleEvent) (reconcile.Result, error)

Execute runs the phases for the specified lifecycle event.

func (*Registry) HandleExecution

func (registry *Registry) HandleExecution(r workload.Reconciler, req *workload.Request) (reconcile.Result, error)

HandleExecution will trigger the execution of the phases for the appropriate lifecycle event. This is the main entrypoint into our phases.

func (*Registry) Register

func (registry *Registry) Register(name string, definition HandlerFunc, event LifecycleEvent, options ...PhaseOption)

Register is used to add a Phase to the Registry for the provided event loop.

Jump to

Keyboard shortcuts

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