66 testv1beta1 "github.com/openstack-k8s-operators/test-operator/api/v1beta1"
77 util "github.com/openstack-k8s-operators/test-operator/pkg/util"
88 corev1 "k8s.io/api/core/v1"
9- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
109)
1110
1211// Pod - prepare pod to run Tempest tests
@@ -22,72 +21,41 @@ func Pod(
2221 mountSSHKey bool ,
2322 containerImage string ,
2423) * corev1.Pod {
25-
26- envVars := map [string ]env.Setter {}
27- runAsUser := int64 (42480 )
28- runAsGroup := int64 (42480 )
29- securityContext := util .GetSecurityContext (runAsUser , []corev1.Capability {}, instance .Spec .Privileged )
30-
31- pod := & corev1.Pod {
32- ObjectMeta : metav1.ObjectMeta {
33- Annotations : annotations ,
34- Name : podName ,
35- Namespace : instance .Namespace ,
36- Labels : labels ,
37- },
38- Spec : corev1.PodSpec {
39- AutomountServiceAccountToken : & instance .Spec .Privileged ,
40- RestartPolicy : corev1 .RestartPolicyNever ,
41- Tolerations : instance .Spec .Tolerations ,
42- NodeSelector : instance .Spec .NodeSelector ,
43- SecurityContext : & corev1.PodSecurityContext {
44- RunAsUser : & runAsUser ,
45- RunAsGroup : & runAsGroup ,
46- FSGroup : & runAsGroup ,
24+ envFromSource := []corev1.EnvFromSource {
25+ {
26+ ConfigMapRef : & corev1.ConfigMapEnvSource {
27+ LocalObjectReference : corev1.LocalObjectReference {
28+ Name : customDataConfigMapName ,
29+ },
4730 },
48- Containers : []corev1.Container {
49- {
50- Name : instance .Name + "-tests-runner" ,
51- Image : containerImage ,
52- Args : []string {},
53- Env : env .MergeEnvs ([]corev1.EnvVar {}, envVars ),
54- VolumeMounts : GetVolumeMounts (mountCerts , mountSSHKey , TempestPropagation , instance ),
55- SecurityContext : & securityContext ,
56- Resources : instance .Spec .Resources ,
57- EnvFrom : []corev1.EnvFromSource {
58- {
59- ConfigMapRef : & corev1.ConfigMapEnvSource {
60- LocalObjectReference : corev1.LocalObjectReference {
61- Name : customDataConfigMapName ,
62- },
63- },
64- },
65- {
66- ConfigMapRef : & corev1.ConfigMapEnvSource {
67- LocalObjectReference : corev1.LocalObjectReference {
68- Name : envVarsConfigMapName ,
69- },
70- },
71- },
72- },
31+ },
32+ {
33+ ConfigMapRef : & corev1.ConfigMapEnvSource {
34+ LocalObjectReference : corev1.LocalObjectReference {
35+ Name : envVarsConfigMapName ,
7336 },
7437 },
75- Volumes : GetVolumes (
76- instance ,
77- customDataConfigMapName ,
78- logsPVCName ,
79- mountCerts ,
80- mountSSHKey ,
81- TempestPropagation ,
82- ),
8338 },
8439 }
8540
86- if len (instance .Spec .SELinuxLevel ) > 0 {
87- pod .Spec .SecurityContext .SELinuxOptions = & corev1.SELinuxOptions {
88- Level : instance .Spec .SELinuxLevel ,
89- }
90- }
91-
92- return pod
41+ return util .BuildTestPod (
42+ annotations ,
43+ PodCapabilities ,
44+ containerImage ,
45+ instance .Name + "-tests-runner" ,
46+ envFromSource ,
47+ map [string ]env.Setter {},
48+ labels ,
49+ instance .Namespace ,
50+ instance .Spec .NodeSelector ,
51+ podName ,
52+ instance .Spec .Privileged ,
53+ instance .Spec .Resources ,
54+ PodRunAsGroup ,
55+ PodRunAsUser ,
56+ instance .Spec .SELinuxLevel ,
57+ instance .Spec .Tolerations ,
58+ GetVolumeMounts (mountCerts , mountSSHKey , TempestPropagation , instance ),
59+ GetVolumes (instance , customDataConfigMapName , logsPVCName , mountCerts , mountSSHKey , TempestPropagation ),
60+ )
9361}
0 commit comments