func Delete(to Setter, t string)
Delete deletes the condition with the given type.
func FalseCondition(t, reason, messageFormat string, messageArgs ...interface{}) *metav1.Condition
FalseCondition returns a condition with Status=False and the given type, reason and message.
func Get(from Getter, t string) *metav1.Condition
Get returns the condition with the given type, if the condition does not exist, it returns nil.
func GetConditions(from Getter) []metav1.Condition
func GetLastTransitionTime(from Getter, t string) *metav1.Time
GetLastTransitionTime returns the LastTransitionType or nil if the condition does not exist (is nil).
func GetMessage(from Getter, t string) string
GetMessage returns a nil safe string of Message for the condition with the given type.
func GetObservedGeneration(from Getter, t string) int64
GetObservedGeneration returns a nil safe int64 of ObservedGeneration for the condition with the given type.
func GetReason(from Getter, t string) string
GetReason returns a nil safe string of Reason for the condition with the given type.
func Has(from Getter, t string) bool
Has returns true if a condition with the given type exists.
func HasAny(from Getter, t []string) bool
HasAny returns true if a condition with any of the given types exist.
func HasReason(from Getter, t, r string) bool
HasReason returns true if the given condition type t exists and has Reason r
func HaveSameStateOf(expected *metav1.Condition) types.GomegaMatcher
HaveSameStateOf returns a custom matcher to check equality of a metav1.Condition, the condition message is checked for a subset string match.
func IsFalse(from Getter, t string) bool
IsFalse is true if the condition with the given type is False, otherwise it is false if the condition is not False or if the condition does not exist (is nil).
func IsReady(from Getter) bool
IsReady is true if IsStalled and IsReconciling are False, and status.ReadyCondition is True, otherwise it is false if the condition is not True or if it does not exist (is nil).
func IsReconciling(from Getter) bool
IsReconciling is true if status.ReconcilingCondition is True and status.StalledCondition is False or does not exist, otherwise it is false.
func IsStalled(from Getter) bool
IsStalled is true if status.StalledCondition is True and status.ReconcilingCondition is False or does not exist, otherwise it is false.
func IsTrue(from Getter, t string) bool
IsTrue is true if the condition with the given type is True, otherwise it is false if the condition is not True or if the condition does not exist (is nil).
func IsUnknown(from Getter, t string) bool
IsUnknown is true if the condition with the given type is Unknown or if the condition does not exist (is nil).
func MarkFalse(to Setter, t, reason, messageFormat string, messageArgs ...interface{})
MarkFalse sets Status=False for the condition with the given type, reason and message.
func MarkReconciling(to Setter, reason, messageFormat string, messageArgs ...interface{})
MarkReconciling sets status.ReconcilingCondition=True with the given reason and message, and deletes the status.StalledCondition. This is normally called at the beginning of a reconcile run for an object.
For more information about the condition types, see the kstatus spec: https://github.com/kubernetes-sigs/cli-utils/blob/e351b2bc43cec2107ba1d874c3dec54fd0956c59/pkg/kstatus/README.md#conditions
func MarkStalled(to Setter, reason, messageFormat string, messageArgs ...interface{})
MarkStalled sets status.StalledCondition=True with the given reason and message, and deletes the status.ReconcilingCondition. This is normally deferred and conditionally called at the end of a reconcile run for an object. A common approach is to mark the object stalled if the object is not requeued as a reconcile result.
For more information about the condition types, see the kstatus spec: https://github.com/kubernetes-sigs/cli-utils/blob/e351b2bc43cec2107ba1d874c3dec54fd0956c59/pkg/kstatus/README.md#conditions
func MarkTrue(to Setter, t, reason, messageFormat string, messageArgs ...interface{})
MarkTrue sets Status=True for the condition with the given type, reason and message.
func MarkUnknown(to Setter, t, reason, messageFormat string, messageArgs ...interface{})
MarkUnknown sets Status=Unknown for the condition with the given type, reason and message.
func MatchCondition(expected metav1.Condition) types.GomegaMatcher
MatchCondition returns a custom matcher to check equality of metav1.Condition.
func MatchConditions(expected []metav1.Condition) types.GomegaMatcher
MatchConditions returns a custom matcher to check equality of a metav1.Condition slice, the condition messages are checked for a subset string match.
func Progressing(obj Setter, reason, messageFormat string, messageArgs ...interface{})
Progressing helps report the progressive status of an object based on the given status value. It always sets Reconciling=True with the given status values.
Ready condition is set only when:
- there's no existing Ready condition in the status - Ready=Unknown
func Set(to Setter, condition *metav1.Condition)
Set sets the given condition.
NOTE: If a condition already exists, the LastTransitionTime is updated only if a change is detected in any of the following fields: Status, Reason, and Message. The ObservedGeneration is always updated.
func SetAggregate(to Setter, targetCondition string, from []Getter, options ...MergeOption)
SetAggregate creates a new condition with the aggregation of all the conditions from a list of dependency objects, or a subset using WithConditions; if none of the source objects have a condition within the scope of the merge operation, no target condition is generated.
func SetMirror(to Setter, targetCondition string, from Getter, options ...MirrorOptions)
SetMirror creates a new condition by mirroring the the Ready condition from a dependent object; if the Ready condition does not exists in the source object, no target conditions is generated.
func SetSummary(to Setter, targetCondition string, options ...MergeOption)
SetSummary creates a new summary condition with the summary of all the conditions existing on an object. If the object does not have other conditions, no summary condition is generated.
func TrueCondition(t, reason, messageFormat string, messageArgs ...interface{}) *metav1.Condition
TrueCondition returns a condition with Status=True and the given type, reason and message.
func UniqueConditions(conditions []metav1.Condition) []metav1.Condition
func UnknownCondition(t, reason, messageFormat string, messageArgs ...interface{}) *metav1.Condition
UnknownCondition returns a condition with Status=Unknown and the given type, reason and message.
ApplyOption defines an option for applying a condition patch.
type ApplyOption func(*applyOptions)
func WithForceOverwrite(v bool) ApplyOption
WithForceOverwrite instructs the patch helper to always use the value provided by the controller in case of conflicts for the owned conditions.
func WithOwnedConditions(t ...string) ApplyOption
WithOwnedConditions allows to define condition types owned by the controller. In case of conflicts for the owned conditions, the patch helper will always use the value provided by the controller.
type ConditionMatcher struct { Expected *metav1.Condition }
func (matcher *ConditionMatcher) FailureMessage(actual interface{}) (message string)
func (matcher *ConditionMatcher) Match(actual interface{}) (success bool, err error)
func (matcher *ConditionMatcher) NegatedFailureMessage(actual interface{}) (message string)
Getter interface defines methods that a Kubernetes resource object should implement in order to use the conditions package for getting conditions.
type Getter interface { client.Object GetConditions() []metav1.Condition }
MergeOption defines an option for computing a summary of conditions.
type MergeOption func(*mergeOptions)
func WithConditions(t ...string) MergeOption
WithConditions instructs merge about the condition types to consider when doing a merge operation; if this option is not specified, all the conditions (except Ready, Stalled, and Reconciling) will be considered. This is required so we can provide some guarantees about the semantic of the target condition without worrying about side effects if someone or something adds custom conditions to the objects.
NOTE: The order of conditions types defines the priority for determining the Reason and Message for the target condition.
func WithCounter() MergeOption
WithCounter instructs merge to add a "x of y Type" string to the message, where x is the number of conditions in the top group, y is the number of objects in scope, and Type is the top group condition type.
func WithCounterIfOnly(t ...string) MergeOption
WithCounterIfOnly ensures a counter is show only if a subset of condition exists. This may apply when you want to use a step counter while reconciling the resource, but then want to move away from this notation as soon as the resource has been reconciled, and e.g. a health check condition is generated.
IMPORTANT: This options requires WithStepCounter or WithStepCounterIf to be set.
func WithLatestGeneration() MergeOption
WithLatestGeneration instructs merge to consider the conditions with the latest observed generation only.
func WithNegativePolarityConditions(t ...string) MergeOption
WithNegativePolarityConditions instructs merge about the condition types that adhere to a "normal-false" or "abnormal-true" pattern, i.e. that conditions are present with a value of True whenever something unusual happens.
func WithSourceRef() MergeOption
WithSourceRef instructs merge to add info about the originating object to the target Reason and in summaries.
func WithSourceRefIf(t ...string) MergeOption
WithSourceRefIf ensures a source ref is show only if one of the types in the set exists.
func WithStepCounter() MergeOption
WithStepCounter instructs merge to add a "x of y completed" string to the message, where x is the number of conditions with Status=true and y is the number of conditions in scope.
func WithStepCounterIf(value bool) MergeOption
WithStepCounterIf adds a step counter if the value is true. This can be used e.g. to add a step counter only if the object is not being deleted.
func WithStepCounterIfOnly(t ...string) MergeOption
WithStepCounterIfOnly ensures a step counter is show only if a subset of condition exists. This may apply when you want to use a step counter while reconciling the resource, but then want to move away from this notation as soon as the resource has been reconciled, and e.g. a health check condition is generated.
IMPORTANT: This options requires WithStepCounter or WithStepCounterIf to be set. IMPORTANT: This option works only while generating the Summary or Aggregated condition.
MirrorOptions defines an option for mirroring conditions.
type MirrorOptions func(*mirrorOptions)
func WithFallbackValue(fallbackValue bool, reason string, message string) MirrorOptions
WithFallbackValue specify a fallback value to use in case the mirrored condition does not exists; in case the fallbackValue is false, given values for reason and message will be used.
Patch defines a list of operations to change a list of conditions into another.
type Patch []PatchOperation
func NewPatch(before Getter, after Getter) Patch
NewPatch returns the list of Patch required to align source conditions to after conditions.
func (p Patch) Apply(latest Setter, options ...ApplyOption) error
Apply executes a three-way merge of a list of Patch. When merge conflicts are detected (latest deviated from before in an incompatible way), an error is returned.
func (p Patch) IsZero() bool
IsZero returns true if the patch has no changes.
PatchOperation define an operation that changes a single condition.
type PatchOperation struct { Before *metav1.Condition After *metav1.Condition Op PatchOperationType }
PatchOperationType defines patch operation types.
type PatchOperationType string
const ( // AddConditionPatch defines an add condition patch operation. AddConditionPatch PatchOperationType = "Add" // ChangeConditionPatch defines an change condition patch operation. ChangeConditionPatch PatchOperationType = "Change" // RemoveConditionPatch defines a remove condition patch operation. RemoveConditionPatch PatchOperationType = "Remove" )
Setter is an interface that defines methods a Kubernetes object should implement in order to use the conditions package for setting conditions.
type Setter interface { Getter SetConditions([]metav1.Condition) }