e2e: use Ginkgo context

All code must use the context from Ginkgo when doing API calls or polling for a
change, otherwise the code would not return immediately when the test gets
aborted.
This commit is contained in:
Patrick Ohly
2022-12-12 10:11:10 +01:00
parent bf1d1dfd0f
commit 2f6c4f5eab
418 changed files with 11489 additions and 11369 deletions

View File

@@ -44,18 +44,18 @@ var (
// GetRuntimeObjectForKind returns a runtime.Object based on its GroupKind,
// namespace and name.
func GetRuntimeObjectForKind(c clientset.Interface, kind schema.GroupKind, ns, name string) (runtime.Object, error) {
func GetRuntimeObjectForKind(ctx context.Context, c clientset.Interface, kind schema.GroupKind, ns, name string) (runtime.Object, error) {
switch kind {
case kindReplicationController:
return c.CoreV1().ReplicationControllers(ns).Get(context.TODO(), name, metav1.GetOptions{})
return c.CoreV1().ReplicationControllers(ns).Get(ctx, name, metav1.GetOptions{})
case kindExtensionsReplicaSet, kindAppsReplicaSet:
return c.AppsV1().ReplicaSets(ns).Get(context.TODO(), name, metav1.GetOptions{})
return c.AppsV1().ReplicaSets(ns).Get(ctx, name, metav1.GetOptions{})
case kindExtensionsDeployment, kindAppsDeployment:
return c.AppsV1().Deployments(ns).Get(context.TODO(), name, metav1.GetOptions{})
return c.AppsV1().Deployments(ns).Get(ctx, name, metav1.GetOptions{})
case kindExtensionsDaemonSet:
return c.AppsV1().DaemonSets(ns).Get(context.TODO(), name, metav1.GetOptions{})
return c.AppsV1().DaemonSets(ns).Get(ctx, name, metav1.GetOptions{})
case kindBatchJob:
return c.BatchV1().Jobs(ns).Get(context.TODO(), name, metav1.GetOptions{})
return c.BatchV1().Jobs(ns).Get(ctx, name, metav1.GetOptions{})
default:
return nil, fmt.Errorf("Unsupported kind when getting runtime object: %v", kind)
}