Skip to content

Commit b2f0e00

Browse files
afaranhaxek
authored andcommitted
Update calls to getVolumes
1 parent 5c73cf8 commit b2f0e00

5 files changed

Lines changed: 16 additions & 18 deletions

File tree

pkg/keystone/bootstrap.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ func BootstrapJob(
6060
}
6161

6262
// create Volume and VolumeMounts
63-
volumes := getVolumes(instance.Name)
63+
volumes := getVolumes(instance)
6464
volumeMounts := getVolumeMounts()
6565

6666
// add CA cert if defined
6767
if instance.Spec.TLS.CaBundleSecretName != "" {
68-
volumes = append(getVolumes(instance.Name), instance.Spec.TLS.CreateVolume())
68+
volumes = append(getVolumes(instance), instance.Spec.TLS.CreateVolume())
6969
volumeMounts = append(getVolumeMounts(), instance.Spec.TLS.CreateVolumeMounts(nil)...)
7070
}
7171

pkg/keystone/cronjob.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ func CronJob(
4646
completions := int32(1)
4747

4848
// create Volume and VolumeMounts
49-
volumes := getVolumes(instance.Name)
49+
volumes := getVolumes(instance)
5050
volumeMounts := getVolumeMounts()
5151

5252
// add CA cert if defined
5353
if instance.Spec.TLS.CaBundleSecretName != "" {
54-
volumes = append(getVolumes(instance.Name), instance.Spec.TLS.CreateVolume())
54+
volumes = append(getVolumes(instance), instance.Spec.TLS.CreateVolume())
5555
volumeMounts = append(getVolumeMounts(), instance.Spec.TLS.CreateVolumeMounts(nil)...)
5656
}
5757

pkg/keystone/dbsync.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,13 @@ func DbSyncJob(
4545
envVars["KOLLA_BOOTSTRAP"] = env.SetValue("true")
4646

4747
// create Volume and VolumeMounts
48-
volumes := getVolumes(instance.Name)
48+
volumes := getVolumes(instance)
4949
volumeMounts := getVolumeMounts()
5050

5151
// add CA cert if defined
5252
if instance.Spec.TLS.CaBundleSecretName != "" {
53-
volumes = append(getVolumes(instance.Name), instance.Spec.TLS.CreateVolume())
53+
//TODO(afaranha): Why not reuse the 'volumes'?
54+
volumes = append(getVolumes(instance), instance.Spec.TLS.CreateVolume())
5455
volumeMounts = append(getVolumeMounts(), instance.Spec.TLS.CreateVolumeMounts(nil)...)
5556
}
5657

pkg/keystone/deployment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func Deployment(
8080
envVars["CONFIG_HASH"] = env.SetValue(configHash)
8181

8282
// create Volume and VolumeMounts
83-
volumes := getVolumes(instance.Name)
83+
volumes := getVolumes(instance)
8484
volumeMounts := getVolumeMounts()
8585

8686
// add CA cert if defined

pkg/keystone/volumes.go

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,16 @@ import (
2020
)
2121

2222
// getVolumes - service volumes
23-
func getVolumes(name string) []corev1.Volume {
23+
func getVolumes(instance *keystonev1.KeystoneAPI) []corev1.Volume {
24+
name := instance.Name
2425
var scriptsVolumeDefaultMode int32 = 0755
2526
var config0640AccessMode int32 = 0640
2627

28+
fernetKeys := []corev1.KeyToPath{}
29+
for i := range instance.Spec.FernetKeys {
30+
fernetKeys = append(fernetKeys, fmt.Sprintf("FernetKeys%d", i))
31+
}
32+
2733
return []corev1.Volume{
2834
{
2935
Name: "scripts",
@@ -48,16 +54,7 @@ func getVolumes(name string) []corev1.Volume {
4854
VolumeSource: corev1.VolumeSource{
4955
Secret: &corev1.SecretVolumeSource{
5056
SecretName: ServiceName,
51-
Items: []corev1.KeyToPath{
52-
{
53-
Key: "FernetKeys0",
54-
Path: "0",
55-
},
56-
{
57-
Key: "FernetKeys1",
58-
Path: "1",
59-
},
60-
},
57+
Items: fernetKeys,
6158
},
6259
},
6360
},

0 commit comments

Comments
 (0)