conditions

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package conditions owns condition management. Conditions are the canonical mechanism for communicating reconciliation state on a CR's status subresource. Every domain writes conditions at each stage of its pipeline via SetCondition so that operators and tooling can observe fine-grained progress without reading logs.

Condition types are domain-defined (e.g. "BuildResolved", "BuildTriggered") and written at each reconciliation stage. The three status aliases here (ConditionTrue, ConditionFalse, ConditionUnknown) are re-exported from metav1 so domain code imports only conditions and never reaches into k8s.io directly for condition status values.

Index

Constants

View Source
const (
	ConditionTrue    = metav1.ConditionTrue
	ConditionFalse   = metav1.ConditionFalse
	ConditionUnknown = metav1.ConditionUnknown
)

Re-exported metav1 condition status constants. Domain code uses these aliases so condition writes read naturally at the call site:

conditions.SetCondition(&cr.Status.Conditions, "BuildResolved", conditions.ConditionTrue, ...)

Variables

This section is empty.

Functions

func GetCondition

func GetCondition(conditions []metav1.Condition, conditionType string) *metav1.Condition

GetCondition returns a pointer to the condition matching conditionType, or nil if no such condition exists. The pointer is into the slice — callers must not retain it across mutations of the conditions slice.

func HasCondition

func HasCondition(conditions []metav1.Condition, conditionType string, status metav1.ConditionStatus) bool

HasCondition reports whether a condition of the given type and status exists in the slice. Useful for predicate checks without needing the full condition struct.

if conditions.HasCondition(build.Status.Conditions, "BuildResolved", conditions.ConditionTrue) { ... }

func SetCondition

func SetCondition(conditions *[]metav1.Condition, conditionType string, status metav1.ConditionStatus, reason, message string)

SetCondition upserts a condition into a CR's conditions slice.

If a condition of the same Type already exists, its Status, Reason, Message, and LastTransitionTime are updated in place. If no matching condition exists, a new one is appended.

Called by domains at each pipeline stage to record progress:

conditions.SetCondition(&build.Status.Conditions, "BuildResolved", conditions.ConditionTrue, "Resolved", "...")
conditions.SetCondition(&build.Status.Conditions, "BuildTriggered", conditions.ConditionFalse, "TriggerFailed", err.Error())

The conditions pointer must not be nil; a nil slice is initialised on first write.

Types

This section is empty.

Jump to

Keyboard shortcuts

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