Skip to content

Commit db00632

Browse files
committed
Add Extra config map configuration for all
Added Extra config map configuration for tobiko and horizon tests
1 parent a9dcbb2 commit db00632

File tree

4 files changed

+61
-4
lines changed

4 files changed

+61
-4
lines changed

pkg/horizontest/job.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func Job(
6161
Image: containerImage,
6262
Args: []string{},
6363
Env: env.MergeEnvs([]corev1.EnvVar{}, envVars),
64-
VolumeMounts: GetVolumeMounts(mountCerts, mountKeys, mountKubeconfig),
64+
VolumeMounts: GetVolumeMounts(mountCerts, mountKeys, mountKubeconfig, instance),
6565
SecurityContext: &securityContext,
6666
Resources: corev1.ResourceRequirements{
6767
Limits: util.GetResourceLimits(),

pkg/horizontest/volumes.go

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ func GetVolumes(
1818
//var privateKeyMode int32 = 0600
1919
//var publicKeyMode int32 = 0644
2020
var tlsCertificateMode int32 = 0444
21+
var publicInfoMode int32 = 0744
2122

2223
volumes := []corev1.Volume{
2324
{
@@ -94,12 +95,27 @@ func GetVolumes(
9495

9596
volumes = append(volumes, kubeconfigVolume)
9697
}
98+
for _, vol := range instance.Spec.ExtraConfigmapsMounts {
99+
extraVol := corev1.Volume{
100+
Name: vol.Name,
101+
VolumeSource: corev1.VolumeSource{
102+
ConfigMap: &corev1.ConfigMapVolumeSource{
103+
DefaultMode: &publicInfoMode,
104+
LocalObjectReference: corev1.LocalObjectReference{
105+
Name: vol.Name,
106+
},
107+
},
108+
},
109+
}
110+
111+
volumes = append(volumes, extraVol)
112+
}
97113

98114
return volumes
99115
}
100116

101117
// GetVolumeMounts -
102-
func GetVolumeMounts(mountCerts bool, mountKeys bool, mountKubeconfig bool) []corev1.VolumeMount {
118+
func GetVolumeMounts(mountCerts bool, mountKeys bool, mountKubeconfig bool, instance *testv1beta1.HorizonTest) []corev1.VolumeMount {
103119
volumeMounts := []corev1.VolumeMount{
104120
{
105121
Name: "test-operator-logs",
@@ -177,5 +193,17 @@ func GetVolumeMounts(mountCerts bool, mountKeys bool, mountKubeconfig bool) []co
177193
volumeMounts = append(volumeMounts, kubeconfigMount)
178194
}
179195

196+
for _, vol := range instance.Spec.ExtraConfigmapsMounts {
197+
198+
extraMounts := corev1.VolumeMount{
199+
Name: vol.Name,
200+
MountPath: vol.MountPath,
201+
SubPath: vol.SubPath,
202+
ReadOnly: true,
203+
}
204+
205+
volumeMounts = append(volumeMounts, extraMounts)
206+
}
207+
180208
return volumeMounts
181209
}

pkg/tobiko/job.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func Job(
6666
Image: containerImage,
6767
Args: []string{},
6868
Env: env.MergeEnvs([]corev1.EnvVar{}, envVars),
69-
VolumeMounts: GetVolumeMounts(mountCerts, mountKeys, mountKubeconfig),
69+
VolumeMounts: GetVolumeMounts(mountCerts, mountKeys, mountKubeconfig, instance),
7070
SecurityContext: &securityContext,
7171
Resources: corev1.ResourceRequirements{
7272
Limits: util.GetResourceLimits(),

pkg/tobiko/volumes.go

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ func GetVolumes(
1919
var privateKeyMode int32 = 0600
2020
var publicKeyMode int32 = 0644
2121
var tlsCertificateMode int32 = 0444
22+
var publicInfoMode int32 = 0744
2223

2324
volumes := []corev1.Volume{
2425
{
@@ -126,11 +127,27 @@ func GetVolumes(
126127
volumes = append(volumes, kubeconfigVolume)
127128
}
128129

130+
for _, vol := range instance.Spec.ExtraConfigmapsMounts {
131+
extraVol := corev1.Volume{
132+
Name: vol.Name,
133+
VolumeSource: corev1.VolumeSource{
134+
ConfigMap: &corev1.ConfigMapVolumeSource{
135+
DefaultMode: &publicInfoMode,
136+
LocalObjectReference: corev1.LocalObjectReference{
137+
Name: vol.Name,
138+
},
139+
},
140+
},
141+
}
142+
143+
volumes = append(volumes, extraVol)
144+
}
145+
129146
return volumes
130147
}
131148

132149
// GetVolumeMounts -
133-
func GetVolumeMounts(mountCerts bool, mountKeys bool, mountKubeconfig bool) []corev1.VolumeMount {
150+
func GetVolumeMounts(mountCerts bool, mountKeys bool, mountKubeconfig bool, instance *testv1beta1.Tobiko) []corev1.VolumeMount {
134151
volumeMounts := []corev1.VolumeMount{
135152
{
136153
Name: "test-operator-logs",
@@ -214,5 +231,17 @@ func GetVolumeMounts(mountCerts bool, mountKeys bool, mountKubeconfig bool) []co
214231
volumeMounts = append(volumeMounts, kubeconfigMount)
215232
}
216233

234+
for _, vol := range instance.Spec.ExtraConfigmapsMounts {
235+
236+
extraMounts := corev1.VolumeMount{
237+
Name: vol.Name,
238+
MountPath: vol.MountPath,
239+
SubPath: vol.SubPath,
240+
ReadOnly: true,
241+
}
242+
243+
volumeMounts = append(volumeMounts, extraMounts)
244+
}
245+
217246
return volumeMounts
218247
}

0 commit comments

Comments
 (0)