Documentation
¶
Index ¶
- Variables
- func EnsureAnnotation(ctx context.Context, c client.Client, obj client.Object, ...) error
- func EnsureLabel(ctx context.Context, c client.Client, obj client.Object, ...) error
- func GetAnnotation(obj client.Object, key string) (string, bool)
- func GetLabel(obj client.Object, key string) (string, bool)
- func GotAnnotationPredicate(key, val string) predicate.Predicate
- func GotLabelPredicate(key, val string) predicate.Predicate
- func HasAnnotation(obj client.Object, key string) bool
- func HasAnnotationPredicate(key, val string) predicate.Predicate
- func HasAnnotationWithValue(obj client.Object, key, value string) bool
- func HasLabel(obj client.Object, key string) bool
- func HasLabelPredicate(key, val string) predicate.Predicate
- func HasLabelWithValue(obj client.Object, key, value string) bool
- func HasOwnerReference(owned, owner client.Object, scheme *runtime.Scheme) (int, error)
- func IsMetadataEntryAlreadyExistsError(err error) bool
- func LoadKubeconfig(configPath string) (*rest.Config, error)
- func LostAnnotationPredicate(key, val string) predicate.Predicate
- func LostLabelPredicate(key, val string) predicate.Predicate
- type DeletionTimestampChangedPredicate
- type MetadataEntryAlreadyExistsError
- type ModifyMetadataEntryMode
- type StatusChangedPredicate
Constants ¶
This section is empty.
Variables ¶
var ( ANNOTATION = &annotationMetadata{} LABEL = &labelMetadata{} )
Functions ¶
func EnsureAnnotation ¶
func EnsureAnnotation(ctx context.Context, c client.Client, obj client.Object, annKey, annValue string, patch bool, mode ...ModifyMetadataEntryMode) error
EnsureAnnotation ensures that the given annotation has the desired state on the object. If the annotation already exists with the expected value or doesn't exist when deletion is desired, this is a no-op. If the annotation already exists with a different value, a MetadataEntryAlreadyExistsError is returned, unless mode OVERWRITE is set. To remove an annotation, set mode to DELETE. The given annValue does not matter in this case. If patch is set to true, the object will be patched in the cluster immediately, otherwise only the in-memory object is modified. client may be nil when patch is false.
func EnsureLabel ¶
func EnsureLabel(ctx context.Context, c client.Client, obj client.Object, labelKey, labelValue string, patch bool, mode ...ModifyMetadataEntryMode) error
EnsureLabel ensures that the given label has the desired state on the object. If the label already exists with the expected value or doesn't exist when deletion is desired, this is a no-op. If the label already exists with a different value, a MetadataEntryAlreadyExistsError is returned, unless mode OVERWRITE is set. To remove an label, set mode to DELETE. The given labelValue does not matter in this case. If patch is set to true, the object will be patched in the cluster immediately, otherwise only the in-memory object is modified. client may be nil when patch is false.
func GetAnnotation ¶
GetAnnotation returns the value of the given annotation key on the object and whether it exists.
func GetLabel ¶
GetLabel returns the value of the given label key on the object and whether it exists.
func GotAnnotationPredicate ¶
GotAnnotationPredicate reacts if the specified annotation was added to the resource. If val is empty, the value of the annotation doesn't matter, just that it was added. Otherwise, true is only returned if the annotation was added (or changed) with the specified value.
func GotLabelPredicate ¶
GotLabelPredicate reacts if the specified label was added to the resource. If val is empty, the value of the label doesn't matter, just that it was added. Otherwise, true is only returned if the label was added (or changed) with the specified value.
func HasAnnotation ¶
HasAnnotation returns true if the given annotation key exists on the object.
func HasAnnotationPredicate ¶
HasAnnotationPredicate reacts if the resource has the specified annotation. If val is empty, the value of the annotation doesn't matter, only its existence. Otherwise, true is only returned if the annotation has the specified value. Note that GotAnnotationPredicate can be used to check if a resource just got a specific annotation.
func HasAnnotationWithValue ¶
HasAnnotationWithValue returns true if the given annotation key exists on the object and has the given value.
func HasLabelPredicate ¶
HasLabelPredicate reacts if the resource has the specified label. If val is empty, the value of the label doesn't matter, only its existence. Otherwise, true is only returned if the label has the specified value. Note that GotLabelPredicate can be used to check if a resource just got a specific label.
func HasLabelWithValue ¶
HasLabelWithValue returns true if the given label key exists on the object and has the given value.
func HasOwnerReference ¶
HasOwnerReference returns the index of the owner reference if the 'owned' object has a owner reference pointing to the 'owner' object. If not, -1 is returned. Note that name and uid are only compared if set in the owner object. This means that the function will return a positive index for an owner object with empty name and uid if the owned object contains a owner reference which fits just apiversion and kind. The scheme argument may be nil if the owners GVK is populated.
func LoadKubeconfig ¶
LoadKubeconfig loads a cluster configuration from the given path. If the path points to a single file, this file is expected to contain a kubeconfig which is then loaded. If the path points to a directory which contains a file named "kubeconfig", that file is used. If the path points to a directory which does not contain a "kubeconfig" file, there must be "host", "token", and "ca.crt" files present, which are used to configure cluster access based on an OIDC trust relationship. If the path is empty, the in-cluster config is returned.
func LostAnnotationPredicate ¶
LostAnnotationPredicate reacts if the specified annotation was removed from the resource. If val is empty, this predicate returns true if the annotation was removed completely, independent of which value it had. Otherwise, true is returned if the annotation had the specified value before and now lost it, either by being removed or by being set to a different value.
func LostLabelPredicate ¶
LostLabelPredicate reacts if the specified label was removed from the resource. If val is empty, this predicate returns true if the label was removed completely, independent of which value it had. Otherwise, true is returned if the label had the specified value before and now lost it, either by being removed or by being set to a different value.
Types ¶
type DeletionTimestampChangedPredicate ¶
DeletionTimestampChangedPredicate reacts to changes of the deletion timestamp.
func (DeletionTimestampChangedPredicate) Update ¶
func (DeletionTimestampChangedPredicate) Update(e event.UpdateEvent) bool
type MetadataEntryAlreadyExistsError ¶
type MetadataEntryAlreadyExistsError struct { MType metadataEntryType Key string DesiredValue string ActualValue string }
func NewMetadataEntryAlreadyExistsError ¶
func NewMetadataEntryAlreadyExistsError(mType metadataEntryType, key, desired, actual string) *MetadataEntryAlreadyExistsError
func (*MetadataEntryAlreadyExistsError) Error ¶
func (e *MetadataEntryAlreadyExistsError) Error() string
type ModifyMetadataEntryMode ¶
type ModifyMetadataEntryMode string
const ( OVERWRITE ModifyMetadataEntryMode = "overwrite" DELETE ModifyMetadataEntryMode = "delete" )
type StatusChangedPredicate ¶
StatusChangedPredicate returns true if the object's status changed. Getting the status is done via reflection and only works if the corresponding field is named 'Status'. If getting the status fails, this predicate always returns true.
func (StatusChangedPredicate) Update ¶
func (p StatusChangedPredicate) Update(e event.UpdateEvent) bool