Documentation
¶
Index ¶
Constants ¶
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" // PropagateAnnotationsAnnotation defines which annotation keys should be propagated from source to destination PropagateAnnotationsAnnotation = "greenhouse.sap/propagate-annotations" )
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" // SuspendAnnotation is the annotation used to suspend reconciliation of a resource SuspendAnnotation = "greenhouse.sap/suspend" // ReconcileAnnotation is the annotation used to trigger reconciliation of a resource // Any change to the value of this annotation should trigger a reconciliation. ReconcileAnnotation = "greenhouse.sap/reconcile" )
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 CatalogObject ¶
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 LastReconciledAtSetter ¶
type LastReconciledAtSetter interface {
// SetLastReconciledAtStatus sets the status field for last reconcile annotation
UpdateLastReconciledAtStatus(string)
}
LastReconciledAtSetter is an interface for runtime objects that support setting the lastReconciledAt status
type Propagator ¶
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 ¶
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) Apply ¶
func (p *Propagator) Apply() client.Object
Apply - performs idempotent propagation of declared label and annotation keys based on the propagate-labels and propagate-annotations annotations on the source object. It adds or updates only the specified keys from src to dst, and removes any previously propagated keys 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)
EnsureSuspended(context.Context, RuntimeObject) (ctrl.Result, 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