controller

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package controller provides shared helpers for the operator's reconcilers, including condition management, status patching and event recording.

Index

Constants

This section is empty.

Variables

View Source
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

func HandleReconcileResult(res *ctrl.Result, err error) (ctrl.Result, error)

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

func PatchStatus(ctx context.Context, c client.Client, original, obj client.Object) error

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

type Outcome struct {
	Result   *ctrl.Result
	Err      error
	Terminal bool
}

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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