conditions

package
v2.33.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindStatusCondition

func FindStatusCondition(a common.ConditionsAccessor, conditionType string) *common.Condition

func IsStatusConditionFalse

func IsStatusConditionFalse(a common.ConditionsAccessor, conditionType string) bool

func IsStatusConditionPresentAndEqual

func IsStatusConditionPresentAndEqual(a common.ConditionsAccessor, conditionType string, status metav1.ConditionStatus) bool

func IsStatusConditionTrue

func IsStatusConditionTrue(a common.ConditionsAccessor, conditionType string) bool

func RemoveStatusCondition

func RemoveStatusCondition(a common.ConditionsAccessor, conditionType string) bool

func SetStatusCondition

func SetStatusCondition(a common.ConditionsAccessor, newCondition common.Condition) bool

Types

type Manager added in v2.26.0

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

func NewManager added in v2.26.0

func NewManager(accessor common.ConditionsAccessor, happy string, dependents ...string) *Manager

func (*Manager) ClearCondition added in v2.26.0

func (r *Manager) ClearCondition(t string) error

ClearCondition removes the specified condition type from the manager's list of conditions and recomputes happiness.

Parameters:

  • `t`: The type of the condition to remove.

Returns:

  • `nil` if the condition was removed successfully or was not found.

func (*Manager) GetCondition added in v2.26.0

func (r *Manager) GetCondition(t string) *common.Condition

func (*Manager) GetTopLevelCondition added in v2.26.0

func (r *Manager) GetTopLevelCondition() *common.Condition

func (*Manager) IsHappy added in v2.26.0

func (r *Manager) IsHappy() bool

func (*Manager) Mark added in v2.26.0

func (r *Manager) Mark(t string, status metav1.ConditionStatus, opts ...Option)

Mark updates the status of a specified condition type and applies optional modifications.

This method allows setting a condition to any of the possible statuses (`True`, `False`, or `Unknown`) while also allowing additional options to modify the condition before it is stored.

Parameters:

  • `t`: The type of the condition to update.
  • `status`: The new status of the condition (one of `metav1.ConditionTrue`, `metav1.ConditionFalse`, or `metav1.ConditionUnknown`).
  • `opts`: Variadic options that can modify attributes of the condition (e.g., reason, message, timestamp).

Behavior:

  1. Creates a `common.Condition` with the specified type and status.
  2. Applies any provided options using `applyOpts(&c, opts...)`.
  3. Sets the condition using `r.SetCondition(c)`, which updates the condition list and recomputes happiness.

func (*Manager) MarkFalse added in v2.26.0

func (r *Manager) MarkFalse(t string, opts ...Option)

func (*Manager) MarkFrom added in v2.26.0

func (r *Manager) MarkFrom(t string, in common.Condition)

func (*Manager) MarkTrue added in v2.26.0

func (r *Manager) MarkTrue(t string, opts ...Option)

func (*Manager) MarkUnknown added in v2.26.0

func (r *Manager) MarkUnknown(t string, opts ...Option)

func (*Manager) RecomputeHappiness added in v2.26.0

func (r *Manager) RecomputeHappiness(t string)

RecomputeHappiness re-evaluates the happiness state of the manager based on the current set of conditions.

It checks if any dependent condition is unhappy (either `False` or `Unknown`). If found, the "happy" condition is updated to reflect the first unhappy condition's status. If no unhappy dependent conditions exist, it sets the "happy" condition to `True`.

Parameters:

  • `t`: The type of the condition that may have triggered a recomputation of happiness.

func (*Manager) Reset added in v2.27.0

func (r *Manager) Reset()

Reset clears all conditions managed by the Manager.

It achieves this by setting an empty slice of common.Condition in the underlying accessor.

func (*Manager) SetCondition added in v2.26.0

func (r *Manager) SetCondition(cond common.Condition)

SetCondition sets the given condition on the manager. It updates the list of conditions and sorts them alphabetically. After updating, it recomputes the happiness state based on the provided condition type.

Parameters:

  • `cond`: The condition to set. The condition will be added or updated based on its type.

func (*Manager) Sort added in v2.26.0

func (r *Manager) Sort()

Sort arranges the conditions retrieved from the accessor based on the following rules: 1. `happy` condition is assigned the highest priority. 2. `dependents` are prioritized in the order they are defined. 3. Conditions with priority `0` (not explicitly listed) are sorted alphabetically.

The sorting is stable, ensuring consistent ordering when conditions have the same priority.

type Option added in v2.26.0

type Option func(*common.Condition)

func WithError added in v2.26.0

func WithError(err error) Option

func WithMessage added in v2.26.0

func WithMessage(msg string, opts ...any) Option

func WithObservedGeneration added in v2.26.0

func WithObservedGeneration(value int64) Option

func WithReason added in v2.26.0

func WithReason(value string) Option

func WithSeverity added in v2.26.0

func WithSeverity(value common.ConditionSeverity) Option

Jump to

Keyboard shortcuts

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