MCPcopy
hub / github.com/kubernetes-sigs/controller-runtime / createPodWithLabels

Function createPodWithLabels

pkg/cache/cache_test.go:59–82  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

57// TODO(community): Pull these helper functions into testenv.
58// Restart policy is included to allow indexing on that field.
59func 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
84func createSvc(ctx context.Context, name, namespace string, cl client.Client) client.Object {
85 svc := &corev1.Service{

Callers 3

createPodFunction · 0.85
cache_test.goFile · 0.85
CacheTestFunction · 0.85

Calls 2

NewFunction · 0.92
CreateMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…