conditions

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllConditionsHaveStatus

func AllConditionsHaveStatus[T comparable](status T, conditions ...Condition[T]) bool

AllConditionsHaveStatus returns true if all conditions have the specified status.

func ConditionUpdater

func ConditionUpdater[T comparable](construct func() Condition[T], conditions []Condition[T], removeUntouched bool) *conditionUpdater[T]

ConditionUpdater creates a builder-like helper struct for updating a list of Conditions. The 'constructor' argument is a function that returns a new (empty) instance of the condition implementation type. The 'conditions' argument contains the old condition list. If removeUntouched is true, the condition list returned with Conditions() will have all conditions removed that have not been updated. If false, all conditions will be kept. Note that calling this function stores the current time as timestamp that is used as timestamp if a condition's status changed. To overwrite this timestamp, modify the 'Now' field of the returned struct manually.

The given condition list is not modified.

Usage example: status.conditions = ConditionUpdater(status.conditions, true).UpdateCondition(...).UpdateCondition(...).Conditions()

Types

type Condition

type Condition[T comparable] interface {
	// SetStatus sets the status of the condition.
	SetStatus(status T)
	// GetStatus returns the status of the condition.
	GetStatus() T

	// SetType sets the type of the condition.
	SetType(conType string)
	// GetType returns the type of the condition.
	GetType() string

	// SetLastTransitionTime sets the timestamp of the condition.
	SetLastTransitionTime(timestamp time.Time)
	// GetLastTransitionTime returns the timestamp of the condition.
	GetLastTransitionTime() time.Time

	// SetReason sets the reason of the condition.
	SetReason(reason string)
	// GetReason returns the reason of the condition.
	GetReason() string

	// SetMessage sets the message of the condition.
	SetMessage(message string)
	// GetMessage returns the message of the condition.
	GetMessage() string
}

Condition represents a condition consisting of type, status, reason, message and a last transition timestamp.

func GetCondition

func GetCondition[T comparable](ccl []Condition[T], t string) Condition[T]

GetCondition returns a pointer to the condition for the given type, if it exists. Otherwise, nil is returned.

Jump to

Keyboard shortcuts

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