Documentation ¶
Overview ¶
Package funcs contains convenience functions for working with e2e-framework environments and feature tests.
Index ¶
- Constants
- Variables
- func AddCrossplaneTypesToScheme() env.Func
- func AllOf(fns ...features.Func) features.Func
- func ApplyClaim(manager, dir, cm string, options ...decoder.DecodeOption) features.Func
- func ApplyHandler(r *resources.Resources, manager string, osh ...onSuccessHandler) decoder.HandlerFunc
- func ApplyResources(manager, dir, pattern string, options ...decoder.DecodeOption) features.Func
- func AsFeaturesFunc(fn env.Func) features.Func
- func CRDInitialNamesAccepted() xpv1.Condition
- func ClaimUnderTestMustNotChangeWithin(d time.Duration) features.Func
- func ComposedResourcesHaveFieldValueWithin(d time.Duration, dir, file, path string, want any, ...) features.Func
- func CompositeResourceHasFieldValueWithin(d time.Duration, dir, claimFile, path string, want any, ...) features.Func
- func CompositeResourceMustMatchWithin(d time.Duration, dir, claimFile string, ...) features.Func
- func CompositeUnderTestMustNotChangeWithin(d time.Duration) features.Func
- func CreateKindClusterWithConfig(clusterName, configFilePath string) env.Func
- func DeleteResources(dir, pattern string, options ...decoder.DecodeOption) features.Func
- func DeletionBlockedByUsageWebhook(dir, pattern string, options ...decoder.DecodeOption) features.Func
- func DeploymentBecomesAvailableWithin(d time.Duration, namespace, name string) features.Func
- func EnvFuncs(fns ...env.Func) env.Func
- func FilterByGK(gk schema.GroupKind) func(o k8s.Object) bool
- func HelmInstall(o ...helm.Option) env.Func
- func HelmRepo(o ...helm.Option) env.Func
- func HelmUninstall(o ...helm.Option) env.Func
- func HelmUpgrade(o ...helm.Option) env.Func
- func InBackground(fn features.Func) features.Func
- func ListedResourcesDeletedWithin(d time.Duration, list k8s.ObjectList, listOptions ...resources.ListOption) features.Func
- func ListedResourcesModifiedWith(list k8s.ObjectList, min int, modify func(object k8s.Object), ...) features.Func
- func ListedResourcesValidatedWithin(d time.Duration, list k8s.ObjectList, min int, ...) features.Func
- func LogResources(list k8s.ObjectList, listOptions ...resources.ListOption) features.Func
- func ReadyToTestWithin(d time.Duration, namespace string) features.Func
- func RelatedObjects(ctx context.Context, t *testing.T, config *rest.Config, objs ...client.Object) ([]client.Object, error)
- func ResourceCreatedWithin(d time.Duration, o k8s.Object) features.Func
- func ResourceDeletedWithin(d time.Duration, o k8s.Object) features.Func
- func ResourceHasFieldValueWithin(d time.Duration, o k8s.Object, path string, want any) features.Func
- func ResourcesCreatedWithin(d time.Duration, dir, pattern string, options ...decoder.DecodeOption) features.Func
- func ResourcesDeletedAfterListedAreGone(d time.Duration, dir, pattern string, list k8s.ObjectList, ...) features.Func
- func ResourcesDeletedWithin(d time.Duration, dir, pattern string, options ...decoder.DecodeOption) features.Func
- func ResourcesFailToApply(manager, dir, pattern string, options ...decoder.DecodeOption) features.Func
- func ResourcesHaveConditionWithin(d time.Duration, dir, pattern string, cds ...xpv1.Condition) features.Func
- func ResourcesHaveFieldValueWithin(d time.Duration, dir, pattern, path string, want any, ...) features.Func
- func ServiceIngressEndPoint(ctx context.Context, cfg *envconf.Config, ...) (string, error)
- func SetAnnotationMutateOption(key, value string) decoder.DecodeOption
Constants ¶
const DefaultPollInterval = time.Millisecond * 500
DefaultPollInterval is the suggested poll interval for wait.For.
Variables ¶
var NotFound = notFound{} //nolint:gochecknoglobals // We treat this as a constant.
NotFound is a special 'want' value that indicates the supplied path should not be found.
Functions ¶
func AddCrossplaneTypesToScheme ¶
AddCrossplaneTypesToScheme adds Crossplane's core custom resource's to the environment's scheme. This allows the environment's client to work with said types.
func ApplyClaim ¶ added in v1.15.0
func ApplyClaim(manager, dir, cm string, options ...decoder.DecodeOption) features.Func
ApplyClaim applies the claim stored in the given folder and file and stores it in the test context for later retrival if needed.
func ApplyHandler ¶
func ApplyHandler(r *resources.Resources, manager string, osh ...onSuccessHandler) decoder.HandlerFunc
ApplyHandler is a decoder.Handler that uses server-side apply to apply the supplied object.
func ApplyResources ¶
func ApplyResources(manager, dir, pattern string, options ...decoder.DecodeOption) features.Func
ApplyResources applies all manifests under the supplied directory that match the supplied glob pattern (e.g. *.yaml). It uses server-side apply - fields are managed by the supplied field manager. It fails the test if any supplied resource cannot be applied successfully.
func AsFeaturesFunc ¶
AsFeaturesFunc converts an env.Func to a features.Func. If the env.Func returns an error the calling test is failed with t.Fatal(err).
func CRDInitialNamesAccepted ¶
CRDInitialNamesAccepted is the status condition CRDs emit when they're established. Most of our Crossplane status conditions are defined elsewhere (e.g. in the xpv1 package), but this isn't so we define it here for convenience.
func ClaimUnderTestMustNotChangeWithin ¶ added in v1.15.0
ClaimUnderTestMustNotChangeWithin asserts that the claim available in the test context does not change within the given time.
func ComposedResourcesHaveFieldValueWithin ¶ added in v1.15.0
func ComposedResourcesHaveFieldValueWithin(d time.Duration, dir, file, path string, want any, filter func(object k8s.Object) bool, options ...decoder.DecodeOption) features.Func
ComposedResourcesHaveFieldValueWithin fails a test if the composed resources created by the claim does not have the supplied value at the supplied path within the supplied duration.
func CompositeResourceHasFieldValueWithin ¶ added in v1.15.0
func CompositeResourceHasFieldValueWithin(d time.Duration, dir, claimFile, path string, want any, options ...decoder.DecodeOption) features.Func
CompositeResourceHasFieldValueWithin asserts that the XR referred to by the claim in the given file has the specified value at the specified path within the specified time.
func CompositeResourceMustMatchWithin ¶ added in v1.15.0
func CompositeResourceMustMatchWithin(d time.Duration, dir, claimFile string, match func(xr *composite.Unstructured) bool, options ...decoder.DecodeOption) features.Func
CompositeResourceMustMatchWithin assert that a composite referred by the given file must be matched by the given function within the given timeout.
func CompositeUnderTestMustNotChangeWithin ¶ added in v1.15.0
CompositeUnderTestMustNotChangeWithin asserts that the claim available in the test context does not change within the given time.
func CreateKindClusterWithConfig ¶
CreateKindClusterWithConfig create kind cluster of the given name according to configuration referred via configFilePath. The configuration is placed in test context afterward.
func DeleteResources ¶
func DeleteResources(dir, pattern string, options ...decoder.DecodeOption) features.Func
DeleteResources deletes (from the environment) all resources defined by the manifests under the supplied directory that match the supplied glob pattern (e.g. *.yaml).
func DeletionBlockedByUsageWebhook ¶ added in v1.14.0
func DeletionBlockedByUsageWebhook(dir, pattern string, options ...decoder.DecodeOption) features.Func
DeletionBlockedByUsageWebhook attempts deleting all resources defined by the manifests under the supplied directory that match the supplied glob pattern (e.g. *.yaml) and verifies that they are blocked by the usage webhook.
func DeploymentBecomesAvailableWithin ¶
DeploymentBecomesAvailableWithin fails a test if the supplied Deployment is not Available within the supplied duration.
func FilterByGK ¶
FilterByGK returns a filter function that returns true if the supplied object is of the supplied GroupKind.
func HelmUninstall ¶
HelmUninstall uninstalls a Helm chart.
func InBackground ¶ added in v1.14.0
InBackground runs the supplied function in a goroutine.
func ListedResourcesDeletedWithin ¶ added in v1.14.0
func ListedResourcesDeletedWithin(d time.Duration, list k8s.ObjectList, listOptions ...resources.ListOption) features.Func
ListedResourcesDeletedWithin fails a test if the supplied list of resources is not deleted within the supplied duration.
func ListedResourcesModifiedWith ¶ added in v1.14.0
func ListedResourcesModifiedWith(list k8s.ObjectList, min int, modify func(object k8s.Object), listOptions ...resources.ListOption) features.Func
ListedResourcesModifiedWith modifies the supplied list of resources with the supplied function and fails a test if the supplied number of resources were not modified within the supplied duration.
func ListedResourcesValidatedWithin ¶ added in v1.14.0
func ListedResourcesValidatedWithin(d time.Duration, list k8s.ObjectList, min int, validate func(object k8s.Object) bool, listOptions ...resources.ListOption) features.Func
ListedResourcesValidatedWithin fails a test if the supplied list of resources does not have the supplied number of resources that pass the supplied validation function within the supplied duration.
func LogResources ¶ added in v1.14.0
func LogResources(list k8s.ObjectList, listOptions ...resources.ListOption) features.Func
LogResources polls the given kind of resources and logs creations, deletions and changed conditions.
func ReadyToTestWithin ¶
ReadyToTestWithin fails a test if Crossplane is not ready to test within the supplied duration. It's typically called in a feature's Setup function. Its purpose isn't to test that Crossplane installed successfully (we have a specific test for that). Instead its purpose is to make sure tests don't start before Crossplane has finished installing.
func RelatedObjects ¶ added in v1.14.0
func RelatedObjects(ctx context.Context, t *testing.T, config *rest.Config, objs ...client.Object) ([]client.Object, error)
RelatedObjects returns all objects related to the supplied object through ownership, i.e. the returned objects are transitively owned by obj, or resource reference.
func ResourceCreatedWithin ¶
ResourceCreatedWithin fails a test if the supplied resource is not found to exist within the supplied duration.
func ResourceDeletedWithin ¶
ResourceDeletedWithin fails a test if the supplied resource is not deleted within the supplied duration.
func ResourceHasFieldValueWithin ¶
func ResourceHasFieldValueWithin(d time.Duration, o k8s.Object, path string, want any) features.Func
ResourceHasFieldValueWithin fails a test if the supplied resource does not have the supplied value at the supplied field path within the supplied duration. The supplied 'want' value must cmp.Equal the actual value.
func ResourcesCreatedWithin ¶
func ResourcesCreatedWithin(d time.Duration, dir, pattern string, options ...decoder.DecodeOption) features.Func
ResourcesCreatedWithin fails a test if the supplied resources are not found to exist within the supplied duration.
func ResourcesDeletedAfterListedAreGone ¶ added in v1.14.0
func ResourcesDeletedAfterListedAreGone(d time.Duration, dir, pattern string, list k8s.ObjectList, listOptions ...resources.ListOption) features.Func
ResourcesDeletedAfterListedAreGone will ensure that the resources matching the supplied pattern under the supplied directory are deleted after the supplied list of resources are deleted.
func ResourcesDeletedWithin ¶
func ResourcesDeletedWithin(d time.Duration, dir, pattern string, options ...decoder.DecodeOption) features.Func
ResourcesDeletedWithin fails a test if the supplied resources are not deleted within the supplied duration.
func ResourcesFailToApply ¶
func ResourcesFailToApply(manager, dir, pattern string, options ...decoder.DecodeOption) features.Func
ResourcesFailToApply applies all manifests under the supplied directory that match the supplied glob pattern (e.g. *.yaml). It uses server-side apply - fields are managed by the supplied field manager. It fails the test if any supplied resource _can_ be applied successfully - use it to test that the API server should reject a resource.
func ResourcesHaveConditionWithin ¶
func ResourcesHaveConditionWithin(d time.Duration, dir, pattern string, cds ...xpv1.Condition) features.Func
ResourcesHaveConditionWithin fails a test if the supplied resources do not have (i.e. become) the supplied conditions within the supplied duration. Comparison of conditions is modulo messages.
func ResourcesHaveFieldValueWithin ¶
func ResourcesHaveFieldValueWithin(d time.Duration, dir, pattern, path string, want any, options ...decoder.DecodeOption) features.Func
ResourcesHaveFieldValueWithin fails a test if the supplied resources do not have the supplied value at the supplied field path within the supplied duration. The supplied 'want' value must cmp.Equal the actual value.
func ServiceIngressEndPoint ¶
func ServiceIngressEndPoint(ctx context.Context, cfg *envconf.Config, clusterName, namespace, serviceName string) (string, error)
ServiceIngressEndPoint returns endpoint (addr:port) that can be used for accessing the service in the cluster with the given name.
func SetAnnotationMutateOption ¶ added in v1.14.0
func SetAnnotationMutateOption(key, value string) decoder.DecodeOption
SetAnnotationMutateOption returns a DecodeOption that sets the supplied annotation on the decoded object.
Types ¶
This section is empty.