mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-12-15 20:37:39 +00:00
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:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user