Documentation ¶
Overview ¶
Package funcs contains convenience functions for working with e2e-framework environments and feature tests.
Index ¶
- Constants
- func AddCrossplaneTypesToScheme() env.Func
- func AllOf(fns ...features.Func) features.Func
- func ApplyHandler(r *resources.Resources, manager string) 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 ComposedResourcesOfClaimHaveFieldValueWithin(d time.Duration, dir, file, path string, want any, ...) features.Func
- func CopyImageToRegistry(clusterName, ns, sName, image string, timeout time.Duration) features.Func
- func CreateKindClusterWithConfig(clusterName, configFilePath string) env.Func
- func DeleteResources(dir, pattern string) features.Func
- func DeletionBlockedByUsageWebhook(dir, pattern string) 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, 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) features.Func
- func ResourcesDeletedAfterListedAreGone(d time.Duration, dir, pattern string, list k8s.ObjectList, ...) features.Func
- func ResourcesDeletedWithin(d time.Duration, dir, pattern string) features.Func
- func ResourcesFailToApply(manager, dir, pattern string) 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 ¶
This section is empty.
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 ApplyHandler ¶
func ApplyHandler(r *resources.Resources, manager string) 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 ComposedResourcesOfClaimHaveFieldValueWithin ¶ added in v1.14.0
func ComposedResourcesOfClaimHaveFieldValueWithin(d time.Duration, dir, file, path string, want any, filter func(object k8s.Object) bool) features.Func
ComposedResourcesOfClaimHaveFieldValueWithin 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 CopyImageToRegistry ¶
CopyImageToRegistry tries to copy the supplied image to the supplied registry within the timeout
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 ¶
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
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, 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 ¶
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 ¶
ResourcesDeletedWithin fails a test if the supplied resources are not deleted within the supplied duration.
func ResourcesFailToApply ¶
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) 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.