cluster-api: sigs.k8s.io/cluster-api/util/conditions Index | Files

package conditions

import "sigs.k8s.io/cluster-api/util/conditions"

Copyright 2020 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Package Files

getter.go merge.go merge_strategies.go patch.go setter.go unstructured.go

func Delete Uses

func Delete(to Setter, t clusterv1.ConditionType)

Delete deletes the condition with the given type.

func FalseCondition Uses

func FalseCondition(t clusterv1.ConditionType, reason string, severity clusterv1.ConditionSeverity, messageFormat string, messageArgs ...interface{}) *clusterv1.Condition

FalseCondition returns a condition with Status=False and the given type.

func Get Uses

func Get(from Getter, t clusterv1.ConditionType) *clusterv1.Condition

Get returns the condition with the given type, if the condition does not exists, it returns nil.

func GetLastTransitionTime Uses

func GetLastTransitionTime(from Getter, t clusterv1.ConditionType) *metav1.Time

GetLastTransitionTime returns the condition Severity or nil if the condition does not exist (is nil).

func GetMessage Uses

func GetMessage(from Getter, t clusterv1.ConditionType) string

GetMessage returns a nil safe string of Message.

func GetReason Uses

func GetReason(from Getter, t clusterv1.ConditionType) string

GetReason returns a nil safe string of Reason for the condition with the given type.

func GetSeverity Uses

func GetSeverity(from Getter, t clusterv1.ConditionType) *clusterv1.ConditionSeverity

GetSeverity returns the condition Severity or nil if the condition does not exist (is nil).

func Has Uses

func Has(from Getter, t clusterv1.ConditionType) bool

Has returns true if a condition with the given type exists.

func IsFalse Uses

func IsFalse(from Getter, t clusterv1.ConditionType) bool

IsFalse is true if the condition with the given type is False, otherwise it return false if the condition is not False or if the condition does not exist (is nil).

func IsTrue Uses

func IsTrue(from Getter, t clusterv1.ConditionType) bool

IsTrue is true if the condition with the given type is True, otherwise it return false if the condition is not True or if the condition does not exist (is nil).

func IsUnknown Uses

func IsUnknown(from Getter, t clusterv1.ConditionType) bool

IsUnknown is true if the condition with the given type is Unknown or if the condition does not exist (is nil).

func MarkFalse Uses

func MarkFalse(to Setter, t clusterv1.ConditionType, reason string, severity clusterv1.ConditionSeverity, messageFormat string, messageArgs ...interface{})

MarkFalse sets Status=False for the condition with the given type.

func MarkTrue Uses

func MarkTrue(to Setter, t clusterv1.ConditionType)

MarkTrue sets Status=True for the condition with the given type.

func MarkUnknown Uses

func MarkUnknown(to Setter, t clusterv1.ConditionType, reason, messageFormat string, messageArgs ...interface{})

MarkUnknown sets Status=Unknown for the condition with the given type.

func Set Uses

func Set(to Setter, condition *clusterv1.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, Severity and Message.

func SetAggregate Uses

func SetAggregate(to Setter, targetCondition clusterv1.ConditionType, from []Getter, options ...MergeOption)

SetAggregate creates a new condition with the aggregation of all the the Ready condition from a list of dependent objects; if the Ready condition does not exists in one of the source object, the object is excluded from the aggregation; if none of the source object have ready condition, no target conditions is generated.

func SetMirror Uses

func SetMirror(to Setter, targetCondition clusterv1.ConditionType, 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 Uses

func SetSummary(to Setter, options ...MergeOption)

SetSummary sets a Ready 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 Uses

func TrueCondition(t clusterv1.ConditionType) *clusterv1.Condition

TrueCondition returns a condition with Status=True and the given type.

func UnknownCondition Uses

func UnknownCondition(t clusterv1.ConditionType, reason string, messageFormat string, messageArgs ...interface{}) *clusterv1.Condition

UnknownCondition returns a condition with Status=Unknown and the given type.

type ApplyOption Uses

type ApplyOption func(*applyOptions)

ApplyOption defines an option for applying a condition patch.

func WithForceOverwrite Uses

func WithForceOverwrite(v bool) ApplyOption

WithForceOverwrite In case of conflicts for the owned conditions, the patch helper will always use the value provided by the controller.

func WithOwnedConditions Uses

func WithOwnedConditions(t ...clusterv1.ConditionType) 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.

DEPRECATED: Use WithForceOverwrite.

type Getter Uses

type Getter interface {
    client.Object

    // GetConditions returns the list of conditions for a cluster API object.
    GetConditions() clusterv1.Conditions
}

Getter interface defines methods that a Cluster API object should implement in order to use the conditions package for getting conditions.

func UnstructuredGetter Uses

func UnstructuredGetter(u *unstructured.Unstructured) Getter

UnstructuredGetter return a Getter object that can read conditions from an Unstructured object. Important. This method should be used only with types implementing Cluster API conditions.

type MergeOption Uses

type MergeOption func(*mergeOptions)

MergeOption defines an option for computing a summary of conditions.

func AddSourceRef Uses

func AddSourceRef() MergeOption

AddSourceRef instructs merge to add info about the originating object to the target Reason.

func WithConditions Uses

func WithConditions(t ...clusterv1.ConditionType) MergeOption

WithConditions instructs merge about the condition types to consider when doing a merge operation; if this option is not specified, all the conditions (excepts Ready) 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. IMPORTANT: This options works only while generating the Summary condition.

func WithStepCounter Uses

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 Uses

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.

IMPORTANT: This options works only while generating the Summary condition.

func WithStepCounterIfOnly Uses

func WithStepCounterIfOnly(t ...clusterv1.ConditionType) MergeOption

WithStepCounterIfOnly ensure a step counter is show only if a subset of condition exists. This applies for example on Machines, where we want to use the step counter notation while provisioning the machine, but then we want to move away from this notation as soon as the machine is provisioned and e.g. a Machine health check condition is generated

IMPORTANT: This options requires WithStepCounter or WithStepCounterIf to be set. IMPORTANT: This options works only while generating the Summary condition.

type MirrorOptions Uses

type MirrorOptions func(*mirrorOptions)

MirrorOptions defines an option for mirroring conditions.

func WithFallbackValue Uses

func WithFallbackValue(fallbackValue bool, reason string, severity clusterv1.ConditionSeverity, 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, severity and message will be used.

type Patch Uses

type Patch []PatchOperation

Patch defines a list of operations to change a list of conditions into another

func NewPatch Uses

func NewPatch(before Getter, after Getter) Patch

NewPatch returns the list of Patch required to align source conditions to after conditions.

func (Patch) Apply Uses

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 (Patch) IsZero Uses

func (p Patch) IsZero() bool

IsZero returns true if the patch has no changes.

type PatchOperation Uses

type PatchOperation struct {
    Before *clusterv1.Condition
    After  *clusterv1.Condition
    Op     PatchOperationType
}

PatchOperation define an operation that changes a single condition.

type PatchOperationType Uses

type PatchOperationType string

PatchOperationType defines patch operation types.

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"
)

type Setter Uses

type Setter interface {
    Getter
    SetConditions(clusterv1.Conditions)
}

Setter interface defines methods that a Cluster API object should implement in order to use the conditions package for setting conditions.

func UnstructuredSetter Uses

func UnstructuredSetter(u *unstructured.Unstructured) Setter

UnstructuredSetter return a Setter object that can set conditions from an Unstructured object. Important. This method should be used only with types implementing Cluster API conditions.

Package conditions imports 15 packages (graph) and is imported by 24 packages. Updated 2020-10-12. Refresh now. Tools for package owners.