lifecycle

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AppliedPropagatorAnnotation stores the list of last applied label keys on the destination object
	AppliedPropagatorAnnotation = "greenhouse.sap/last-applied-propagator"

	// PropagateLabelsAnnotation defines which label keys should be propagated from source to destination
	PropagateLabelsAnnotation = "greenhouse.sap/propagate-labels"
)
View Source
const (
	CreatedReason         greenhousemetav1alpha1.ConditionReason = "Created"
	PendingCreationReason greenhousemetav1alpha1.ConditionReason = "PendingCreation"
	FailingCreationReason greenhousemetav1alpha1.ConditionReason = "FailingCreation"
	// ScheduledDeletionReason is used to indicate that the resource is scheduled for deletion
	ScheduledDeletionReason greenhousemetav1alpha1.ConditionReason = "ScheduledDeletion"
	PendingDeletionReason   greenhousemetav1alpha1.ConditionReason = "PendingDeletion"
	FailingDeletionReason   greenhousemetav1alpha1.ConditionReason = "FailingDeletion"
	DeletedReason           greenhousemetav1alpha1.ConditionReason = "Deleted"
	CommonCleanupFinalizer                                         = "greenhouse.sap/cleanup"

	// Success should be returned in case the operator reached its target state
	Success ReconcileResult = "Success"
	// Failed should be returned in case the operator wasn't able to reach its target state and without external changes it's unlikely that this will succeed in the next try
	Failed ReconcileResult = "Failed"
	// Pending should be returned in case the operator is still trying to reach the target state (Requeue, waiting for remote resource to be cleaned up, etc.)
	Pending ReconcileResult = "Pending"
)

Variables

This section is empty.

Functions

func Reconcile

func Reconcile(ctx context.Context, kubeClient client.Client, namespacedName types.NamespacedName, runtimeObject RuntimeObject, reconciler Reconciler, statusFunc Conditioner) (ctrl.Result, error)

Reconcile - is a generic function that is used to reconcile the state of a resource It standardizes the reconciliation loop and provides a common way to set finalizers, remove finalizers, and update the status of the resource It splits the reconciliation into two phases: EnsureCreated and EnsureDeleted to keep the create / update and delete logic in controllers segregated

Types

type Conditioner

type Conditioner func(context.Context, RuntimeObject)

Conditioner is a function that can be used to set the status conditions of the object at a later point in the reconciliation process Provided by the caller of the Reconcile function

type Propagator added in v0.5.0

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

Propagator encapsulates a source and destination object between which label keys are propagated according to configured annotations.

func NewPropagator added in v0.5.0

func NewPropagator(src, dst client.Object) *Propagator

NewPropagator creates a new Propagator instance for syncing labels between a source and destination Kubernetes object.

func (*Propagator) ApplyLabels added in v0.5.0

func (p *Propagator) ApplyLabels() client.Object

ApplyLabels - performs idempotent label propagation based on the propagate-labels annotation. It adds or updates only the specified label keys from src to dst, and removes any previously propagated labels that were removed in src or are no longer declared.

type ReconcileResult

type ReconcileResult string

type Reconciler

type Reconciler interface {
	EnsureCreated(context.Context, RuntimeObject) (ctrl.Result, ReconcileResult, error)
	EnsureDeleted(context.Context, RuntimeObject) (ctrl.Result, ReconcileResult, error)
}

Reconciler is the interface that wraps the basic EnsureCreated and EnsureDeleted methods that a controller should implement

type RuntimeObject

type RuntimeObject interface {
	runtime.Object
	v1.Object
	// GetConditions returns the status conditions of the object (must be implemented in respective types)
	GetConditions() greenhousemetav1alpha1.StatusConditions
	// SetCondition sets the status conditions of the object (must be implemented in respective types)
	SetCondition(greenhousemetav1alpha1.Condition)
}

RuntimeObject is an interface that generalizes the CR object that is being reconciled

Jump to

Keyboard shortcuts

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