From 82d76e2d6d3c2e87c9518a0ef6041ebd091bb969 Mon Sep 17 00:00:00 2001 From: Caleb Woodbine Date: Thu, 21 May 2020 10:00:17 +1200 Subject: [PATCH] Add dynamic client resource watch function --- test/e2e/framework/util.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/e2e/framework/util.go b/test/e2e/framework/util.go index 07b43c6f049..8f16a9a3bfc 100644 --- a/test/e2e/framework/util.go +++ b/test/e2e/framework/util.go @@ -1286,6 +1286,14 @@ func taintExists(taints []v1.Taint, taintToFind *v1.Taint) bool { return false } +func getDynamicResourceWatch(testContext context.Context, dc dynamic.Interface, resourceType schema.GroupVersionResource, namespace string, resourceName string, listOptions metav1.ListOptions) func() (watch.Interface, error) { + return func() (watch.Interface, error) { + res, err := dc.Resource(resourceType).Namespace(namespace).Watch(context.TODO(), listOptions) + ExpectNoError(err, "Failed to create a watch for %v", resourceType.Resource) + return res, err + } +} + // WatchEventEnsurerAndManager // manages a watch for a given resource, ensures that events take place in a given order, retries the test on failure // testContext cancelation signal across API boundries, e.g: context.TODO()