Documentation
¶
Overview ¶
Package controller provides shared helpers for the operator's reconcilers, including condition management, status patching and event recording.
Index ¶
- Variables
- func Eventf(recorder events.EventRecorder, obj runtime.Object, ...)
- func FinalizeStatus(ctx context.Context, c client.Client, recorder events.EventRecorder, ...)
- func HandleReconcileResult(res *ctrl.Result, err error) (ctrl.Result, error)
- func MarkNotReady(obj StatusObject, reason, message string)
- func MarkReady(obj StatusObject, reason, message string)
- func MarkReconciling(obj StatusObject, reason, message string)
- func PatchStatus(ctx context.Context, c client.Client, original, obj client.Object) error
- type FinalizeStatusOptions
- type Outcome
- type StatusObject
Constants ¶
This section is empty.
Variables ¶
var ErrRenovateConfigNotFound = errors.New("RenovateConfig not found")
ErrRenovateConfigNotFound is returned when no RenovateConfig can be resolved for a managed resource.
Functions ¶
func Eventf ¶
func Eventf( recorder events.EventRecorder, obj runtime.Object, event, reason, action, note string, args ...any, )
Eventf records an event on obj using the new events API. It is a no-op when recorder is nil so that controllers do not need to guard every call site.
func FinalizeStatus ¶
func FinalizeStatus( ctx context.Context, c client.Client, recorder events.EventRecorder, original client.Object, obj StatusObject, outcome Outcome, opts FinalizeStatusOptions, )
FinalizeStatus applies the Ready condition, emits an event for the outcome and patches the status subresource. It is the single point where status is written from a controller, which avoids racing concurrent helper functions.
func HandleReconcileResult ¶
HandleReconcileResult normalizes the (*ctrl.Result, error) pair returned by component reconcilers into the (ctrl.Result, error) signature expected by controller-runtime. A nil res is treated as the zero value while preserving any RequeueAfter the component requested, even on success.
func MarkNotReady ¶
func MarkNotReady(obj StatusObject, reason, message string)
MarkNotReady marks the object as Ready=False with the given reason and message. It does not flip Reconciling, because the object may either be retrying (transient error) or stuck (terminal error) — that signal belongs to the controller via the returned ctrl.Result.
func MarkReady ¶
func MarkReady(obj StatusObject, reason, message string)
MarkReady marks the object as Ready=True and clears the Reconciling condition. It only mutates the in-memory object; callers must persist the status with PatchStatus.
func MarkReconciling ¶
func MarkReconciling(obj StatusObject, reason, message string)
MarkReconciling marks the object as Reconciling=True. It is intended to be used at the start of a reconciliation that is expected to take more than a single pass, so that consumers can distinguish "work in progress" from "ready" or "failed".
func PatchStatus ¶
PatchStatus persists the in-memory status of obj using a merge patch computed against original. NotFound errors are ignored because the resource may have been deleted concurrently. Conflict errors are returned so the caller can requeue.
Types ¶
type FinalizeStatusOptions ¶
type FinalizeStatusOptions struct {
// SuccessMessage is the message used for both the Ready=True condition
// and the Normal event when reconciliation succeeds.
SuccessMessage string
// EventAction is the action label written into emitted events.
// It defaults to renovatev1beta1.EventActionReconciling when empty.
EventAction string
}
FinalizeStatusOptions describes how to translate an Outcome into a Ready condition and a Kubernetes Event. Each controller provides its own human-readable success message and event reasons.
type Outcome ¶
Outcome captures the result of a reconciliation pass. The Terminal flag signals that the reconciler has already chosen a final Ready condition.
type StatusObject ¶
type StatusObject interface {
client.Object
SetCondition(conditionType string, status metav1.ConditionStatus, reason, message string)
RemoveCondition(conditionType string)
}
StatusObject is the contract that every API kind reconciled by this operator must satisfy in order to participate in the shared status helpers.