TODO(community): Pull these helper functions into testenv. Restart policy is included to allow indexing on that field.
(ctx context.Context, name, namespace string, restartPolicy corev1.RestartPolicy, labels map[string]string)
| 57 | // TODO(community): Pull these helper functions into testenv. |
| 58 | // Restart policy is included to allow indexing on that field. |
| 59 | func createPodWithLabels(ctx context.Context, name, namespace string, restartPolicy corev1.RestartPolicy, labels map[string]string) client.Object { |
| 60 | three := int64(3) |
| 61 | if labels == nil { |
| 62 | labels = map[string]string{} |
| 63 | } |
| 64 | labels["test-label"] = name |
| 65 | pod := &corev1.Pod{ |
| 66 | ObjectMeta: metav1.ObjectMeta{ |
| 67 | Name: name, |
| 68 | Namespace: namespace, |
| 69 | Labels: labels, |
| 70 | }, |
| 71 | Spec: corev1.PodSpec{ |
| 72 | Containers: []corev1.Container{{Name: "nginx", Image: "nginx"}}, |
| 73 | RestartPolicy: restartPolicy, |
| 74 | ActiveDeadlineSeconds: &three, |
| 75 | }, |
| 76 | } |
| 77 | cl, err := client.New(cfg, client.Options{}) |
| 78 | Expect(err).NotTo(HaveOccurred()) |
| 79 | err = cl.Create(ctx, pod) |
| 80 | Expect(err).NotTo(HaveOccurred()) |
| 81 | return pod |
| 82 | } |
| 83 | |
| 84 | func createSvc(ctx context.Context, name, namespace string, cl client.Client) client.Object { |
| 85 | svc := &corev1.Service{ |
no test coverage detected
searching dependent graphs…