lifecycle

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action string

Action represents the type of operation a subroutine performs.

const (
	ActionProcess    Action = "process"
	ActionFinalize   Action = "finalize"
	ActionInitialize Action = "initialize"
	ActionTerminate  Action = "terminate"
)

func (Action) IsFinalize

func (a Action) IsFinalize() bool

IsFinalize returns true if the action is a finalize or terminate operation.

func (Action) String

func (a Action) String() string

String returns the string representation of the action.

type ConditionManager

type ConditionManager interface {
	InitUnknownConditions(obj client.Object, subroutineNames []string)
	SetSubroutineCondition(obj client.Object, name string, result subroutines.Result, err error, isFinalize bool)
	SetSkippedConditions(obj client.Object, names []string, ready bool, msg string)
	SetReadyCondition(obj client.Object, reason string)
}

ConditionManager manages per-subroutine and aggregate conditions.

type ErrorInfo

type ErrorInfo struct {
	Subroutine string
	Object     client.Object
	Action     Action
}

ErrorInfo provides context about the subroutine that failed.

type ErrorReporter

type ErrorReporter interface {
	Report(ctx context.Context, err error, info ErrorInfo)
}

ErrorReporter is called when a subroutine returns an error.

type Lifecycle

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

Lifecycle orchestrates subroutine execution for a Kubernetes controller.

func New

func New(mgr mcmanager.Manager, controllerName string, newObj func() client.Object, subs ...subroutines.Subroutine) *Lifecycle

New creates a Lifecycle for the given controller.

func (*Lifecycle) Reconcile

func (l *Lifecycle) Reconcile(ctx context.Context, req mcreconcile.Request) (reconcile.Result, error)

Reconcile implements mcreconcile.Reconciler.

func (*Lifecycle) WithConditions

func (l *Lifecycle) WithConditions(cm ConditionManager) *Lifecycle

WithConditions enables condition management. Panics if the object produced by newObj does not implement conditions.ConditionAccessor.

func (*Lifecycle) WithErrorReporters

func (l *Lifecycle) WithErrorReporters(reporters ...ErrorReporter) *Lifecycle

WithErrorReporters adds one or more error reporters.

func (*Lifecycle) WithInitializer

func (l *Lifecycle) WithInitializer(name string) *Lifecycle

WithInitializer enables initializer support. When the given name is present in status.initializers (set by kcp), subroutines implementing Initializer will run Initialize instead of Process. The marker is removed from status once all subroutines complete successfully.

func (*Lifecycle) WithPrepareContext

func (l *Lifecycle) WithPrepareContext(fn func(ctx context.Context, obj client.Object) (context.Context, error)) *Lifecycle

WithPrepareContext sets a function to enrich the context before subroutines run.

func (*Lifecycle) WithReadOnly

func (l *Lifecycle) WithReadOnly() *Lifecycle

WithReadOnly disables all patches.

func (*Lifecycle) WithSpecPatch

func (l *Lifecycle) WithSpecPatch() *Lifecycle

WithSpecPatch enables spec patching when spec changes are detected.

func (*Lifecycle) WithSpread

func (l *Lifecycle) WithSpread(sm SpreadManager) *Lifecycle

WithSpread enables reconciliation spreading. Panics if the object produced by newObj does not implement spread.SpreadReconcileStatus.

func (*Lifecycle) WithTerminator

func (l *Lifecycle) WithTerminator(name string) *Lifecycle

WithTerminator enables terminator support. When the given name is present in status.terminators (set by kcp), subroutines implementing Terminator will run Terminate instead of Finalize during deletion. The marker is removed from status once all subroutines complete successfully.

type SpreadManager

type SpreadManager interface {
	ReconcileRequired(obj client.Object) bool
	RequeueDelay(obj client.Object) time.Duration
	SetNextReconcileTime(obj client.Object)
	UpdateObservedGeneration(obj client.Object)
	RemoveRefreshLabel(obj client.Object) bool
}

SpreadManager manages reconciliation spreading.

Jump to

Keyboard shortcuts

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