MCPcopy
hub / github.com/operator-framework/operator-sdk / getPodDefinition

Function getPodDefinition

internal/scorecard/testpod.go:37–122  ·  view source on GitHub ↗

getPodDefinition fills out a Pod definition based on information from the test

(configMapName string, test v1alpha3.TestConfiguration, r PodTestRunner)

Source from the content-addressed store, hash-verified

35// getPodDefinition fills out a Pod definition based on
36// information from the test
37func getPodDefinition(configMapName string, test v1alpha3.TestConfiguration, r PodTestRunner) *v1.Pod {
38
39 return &v1.Pod{
40 ObjectMeta: metav1.ObjectMeta{
41 Name: fmt.Sprintf("scorecard-test-%s", rand.String(4)),
42 Namespace: r.Namespace,
43 Labels: map[string]string{
44 "app": "scorecard-test",
45 "testrun": configMapName,
46 },
47 },
48 Spec: v1.PodSpec{
49 ServiceAccountName: r.ServiceAccount,
50 RestartPolicy: v1.RestartPolicyNever,
51 Containers: []v1.Container{
52 {
53 Name: "scorecard-test",
54 Image: test.Image,
55 ImagePullPolicy: v1.PullIfNotPresent,
56 Command: test.Entrypoint,
57 VolumeMounts: []v1.VolumeMount{
58 {
59 MountPath: PodBundleRoot,
60 Name: "scorecard-untar",
61 ReadOnly: true,
62 },
63 },
64 Env: []v1.EnvVar{
65 {
66 Name: "SCORECARD_NAMESPACE",
67 ValueFrom: &v1.EnvVarSource{
68 FieldRef: &v1.ObjectFieldSelector{
69 FieldPath: "metadata.namespace",
70 },
71 },
72 },
73 },
74 },
75 },
76 InitContainers: []v1.Container{
77 {
78 Name: "scorecard-untar",
79 Image: r.UntarImage,
80 ImagePullPolicy: v1.PullIfNotPresent,
81 Args: []string{
82 "tar",
83 "xvzf",
84 "/scorecard/bundle.tar.gz",
85 "-C",
86 "/scorecard-bundle",
87 },
88 VolumeMounts: []v1.VolumeMount{
89 {
90 MountPath: "/scorecard",
91 Name: "scorecard-bundle",
92 ReadOnly: true,
93 },
94 {

Callers 1

RunTestMethod · 0.85

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected