testpredicates

package
v1.15.3 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFailedPredicate = errors.New("failed predicate")

ErrFailedPredicate indicates the the object on the API server does not match the Predicate.

View Source
var ErrObjectNotFound = errors.New("object not found")

ErrObjectNotFound indicates that the caller passed a nil object, indicating the object was deleted or never existed.

View Source
var ErrWrongType = errors.New("wrong type")

ErrWrongType indicates that the caller passed an object of the incorrect type to the Predicate.

Functions

func EvaluatePredicates

func EvaluatePredicates(obj client.Object, predicates []Predicate) []error

EvaluatePredicates evaluates a list of predicates and returns any errors

func HasDeletionTimestamp

func HasDeletionTimestamp(o client.Object) error

HasDeletionTimestamp is a predicate that tests that an Object has a DeletionTimestamp.

func MissingDeletionTimestamp

func MissingDeletionTimestamp(o client.Object) error

MissingDeletionTimestamp is a predicate that tests that an Object does NOT have a DeletionTimestamp.

func NotPendingDeletion

func NotPendingDeletion(o client.Object) error

NotPendingDeletion ensures o is not pending deletion.

Check this when the object could be scheduled for deletion, to avoid flaky behavior when we're ensuring we don't want something to be deleted.

func ObjectFoundPredicate

func ObjectFoundPredicate(o client.Object) error

ObjectFoundPredicate returns ErrObjectNotFound if the object is nil (not found).

func WrongTypeErr

func WrongTypeErr(got, want interface{}) error

WrongTypeErr reports that the passed type was not equivalent to the wanted type.

Types

type Predicate

type Predicate func(o client.Object) error

Predicate evaluates a client.Object, returning an error if it fails validation. The object will be nil if the object was deleted or never existed.

func AllResourcesAreCurrent

func AllResourcesAreCurrent() Predicate

AllResourcesAreCurrent ensures that the managed resources are all Current in the ResourceGroup CR.

func DeploymentHasEnvVar

func DeploymentHasEnvVar(containerName, key, value string) Predicate

DeploymentHasEnvVar check whether the deployment contains environment variable with specified name and value

func DeploymentMissingEnvVar

func DeploymentMissingEnvVar(containerName, key string) Predicate

DeploymentMissingEnvVar check whether the deployment does not contain environment variable with specified name and value

func HasAllAnnotationKeys

func HasAllAnnotationKeys(keys ...string) Predicate

HasAllAnnotationKeys returns a predicate that tests if an Object has the specified annotation keys.

func HasAllNomosMetadata

func HasAllNomosMetadata() Predicate

HasAllNomosMetadata ensures that the object contains the expected nomos labels and annotations.

func HasAnnotation

func HasAnnotation(key, value string) Predicate

HasAnnotation returns a predicate that tests if an Object has the specified annotation key/value pair.

func HasAnnotationKey

func HasAnnotationKey(key string) Predicate

HasAnnotationKey returns a predicate that tests if an Object has the specified annotation key.

func HasCorrectResourceRequestsLimits

func HasCorrectResourceRequestsLimits(containerName string, cpuRequest, cpuLimit, memoryRequest, memoryLimit resource.Quantity) Predicate

HasCorrectResourceRequestsLimits verify a root/namespace reconciler container has the correct resource requests and limits.

func HasExactlyAnnotationKeys

func HasExactlyAnnotationKeys(wantKeys ...string) Predicate

HasExactlyAnnotationKeys ensures the Object has exactly the passed set of annotations, ignoring values.

func HasExactlyImage

func HasExactlyImage(containerName, expectImageName, expectImageTag, expectImageDigest string) Predicate

HasExactlyImage ensures a container has the expected image.

func HasExactlyLabelKeys

func HasExactlyLabelKeys(wantKeys ...string) Predicate

HasExactlyLabelKeys ensures the Object has exactly the passed set of labels, ignoring values.

func HasFinalizer

func HasFinalizer(name string) Predicate

HasFinalizer returns a predicate that tests that an Object has the specified finalizer.

func HasGenerationAtLeast

func HasGenerationAtLeast(minGeneration int64) Predicate

HasGenerationAtLeast checks that the object's Generation is greater than or equal to the specified value.

func HasLabel

func HasLabel(key, value string) Predicate

HasLabel returns a predicate that tests if an Object has the specified label key/value pair.

func IsManagedBy

func IsManagedBy(scheme *runtime.Scheme, scope declared.Scope, syncName string) Predicate

IsManagedBy checks that the object is managed by configsync, has the expected resource manager, and has a valid resource-id. Use diff.IsManager if you just need a boolean without errors.

func IsNotManaged

func IsNotManaged(scheme *runtime.Scheme) Predicate

IsNotManaged checks that the object is NOT managed by configsync. Use differ.ManagedByConfigSync if you just need a boolean without errors.

func MissingAnnotation

func MissingAnnotation(key string) Predicate

MissingAnnotation returns a predicate that tests that an object does not have a specified annotation.

func MissingFinalizer

func MissingFinalizer(name string) Predicate

MissingFinalizer returns a predicate that tests that an Object does NOT have the specified finalizer.

func MissingLabel

func MissingLabel(key string) Predicate

MissingLabel returns a predicate that tests that an object does not have a specified label.

func NoConfigSyncMetadata

func NoConfigSyncMetadata() Predicate

NoConfigSyncMetadata ensures that the object doesn't contain configsync labels and annotations.

func ObjectNotFoundPredicate

func ObjectNotFoundPredicate(scheme *runtime.Scheme) Predicate

ObjectNotFoundPredicate returns an error unless the object is nil (not found).

func RepoSyncHasRenderingError

func RepoSyncHasRenderingError(errCode, errMessage string) Predicate

RepoSyncHasRenderingError returns an error if the RootSync does not have the specified Rendering error code and (optional, partial) message.

func RepoSyncHasSourceError

func RepoSyncHasSourceError(errCode, errMessage string) Predicate

RepoSyncHasSourceError returns an error if the RootSync does not have the specified Source error code and (optional, partial) message.

func RepoSyncHasSyncError

func RepoSyncHasSyncError(errCode, errMessage string) Predicate

RepoSyncHasSyncError returns an error if the RootSync does not have the specified Sync error code and (optional, partial) message.

func ResourceVersionEquals

func ResourceVersionEquals(scheme *runtime.Scheme, expected string) Predicate

ResourceVersionEquals checks that the object's ResourceVersion matches the specified value.

func ResourceVersionNotEquals

func ResourceVersionNotEquals(scheme *runtime.Scheme, unexpected string) Predicate

ResourceVersionNotEquals checks that the object's ResourceVersion does NOT match specified value.

func RoleBindingHasName

func RoleBindingHasName(expectedName string) Predicate

RoleBindingHasName will check the Rolebindings name and compare it with expected value

func RootSyncHasObservedGenerationNoLessThan

func RootSyncHasObservedGenerationNoLessThan(generation int64) Predicate

RootSyncHasObservedGenerationNoLessThan returns an error if the RootSync has the observedGeneration less than the expected generation.

func RootSyncHasRenderingError

func RootSyncHasRenderingError(errCode, errMessage string) Predicate

RootSyncHasRenderingError returns an error if the RootSync does not have the specified Rendering error code and (optional, partial) message.

func RootSyncHasSourceError

func RootSyncHasSourceError(errCode, errMessage string) Predicate

RootSyncHasSourceError returns an error if the RootSync does not have the specified Source error code and (optional, partial) message.

func RootSyncHasSyncError

func RootSyncHasSyncError(errCode, errMessage string) Predicate

RootSyncHasSyncError returns an error if the RootSync does not have the specified Sync error code and (optional, partial) message.

func SecretHasKey

func SecretHasKey(key, value string) Predicate

SecretHasKey checks that the secret contains key with value

func SecretMissingKey

func SecretMissingKey(key string) Predicate

SecretMissingKey checks that the secret does not contain key

func StatusEquals

func StatusEquals(scheme *runtime.Scheme, expected status.Status) Predicate

StatusEquals checks that the object's computed status matches the specified status.

func WatchSyncPredicate

func WatchSyncPredicate() (Predicate, <-chan struct{})

WatchSyncPredicate returns a predicate and a channel. The channel will be closed when the predicate is first called. Use this to block until WatchObject has completed its first LIST call. This will help avoid missed events when WatchObject is run asynchronously.

Jump to

Keyboard shortcuts

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