Documentation
¶
Index ¶
- func FindStatusCondition(a common.ConditionsAccessor, conditionType string) *common.Condition
- func IsStatusConditionFalse(a common.ConditionsAccessor, conditionType string) bool
- func IsStatusConditionPresentAndEqual(a common.ConditionsAccessor, conditionType string, ...) bool
- func IsStatusConditionTrue(a common.ConditionsAccessor, conditionType string) bool
- func RemoveStatusCondition(a common.ConditionsAccessor, conditionType string) bool
- func SetStatusCondition(a common.ConditionsAccessor, newCondition common.Condition) bool
- type Manager
- func (r *Manager) ClearCondition(t string) error
- func (r *Manager) GetCondition(t string) *common.Condition
- func (r *Manager) GetTopLevelCondition() *common.Condition
- func (r *Manager) IsHappy() bool
- func (r *Manager) Mark(t string, status metav1.ConditionStatus, opts ...Option)
- func (r *Manager) MarkFalse(t string, opts ...Option)
- func (r *Manager) MarkFrom(t string, in common.Condition)
- func (r *Manager) MarkTrue(t string, opts ...Option)
- func (r *Manager) MarkUnknown(t string, opts ...Option)
- func (r *Manager) RecomputeHappiness(t string)
- func (r *Manager) Reset()
- func (r *Manager) SetCondition(cond common.Condition)
- func (r *Manager) Sort()
- type Option
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
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 (*Manager) GetTopLevelCondition ¶ added in v2.26.0
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:
- Creates a `common.Condition` with the specified type and status.
- Applies any provided options using `applyOpts(&c, opts...)`.
- Sets the condition using `r.SetCondition(c)`, which updates the condition list and recomputes happiness.
func (*Manager) MarkUnknown ¶ added in v2.26.0
func (*Manager) RecomputeHappiness ¶ added in v2.26.0
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
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
func WithMessage ¶ added in v2.26.0
func WithObservedGeneration ¶ added in v2.26.0
func WithReason ¶ added in v2.26.0
func WithSeverity ¶ added in v2.26.0
func WithSeverity(value common.ConditionSeverity) Option