|
1 | 1 | package barbican |
2 | 2 |
|
3 | 3 | import ( |
| 4 | + "fmt" |
| 5 | + "slices" |
| 6 | + |
4 | 7 | barbicanv1beta1 "github.com/openstack-k8s-operators/barbican-operator/api/v1beta1" |
5 | 8 | corev1 "k8s.io/api/core/v1" |
6 | 9 | ) |
@@ -145,6 +148,44 @@ func GetCustomConfigVolumeMount() corev1.VolumeMount { |
145 | 148 | } |
146 | 149 | } |
147 | 150 |
|
| 151 | +// GetConfigOverwriteVolumeMounts returns SubPath volume mounts that place |
| 152 | +// each defaultConfigOverwrite key as an individual file under /etc/barbican/. |
| 153 | +// SubPath mounts are used instead of a directory mount so that existing files |
| 154 | +// in /etc/barbican/ (barbican.conf, api-paste.ini, etc.) are not shadowed. |
| 155 | +// The overwrite data lives in the same config-data-custom Secret (merged via |
| 156 | +// CustomData). |
| 157 | +// |
| 158 | +// Each key is mounted at the following locations: |
| 159 | +// 1. /etc/barbican/<key> (correct location per CRD) |
| 160 | +// 2. /etc/barbican/barbican.conf.d/<key> (backwards-compatible location) |
| 161 | +// |
| 162 | +// The dual mount preserves backwards-compatible customer workarounds where |
| 163 | +// policy.yaml was placed in .conf.d/ (due to the original bug) and referenced |
| 164 | +// via a customServiceConfig override. |
| 165 | +func GetConfigOverwriteVolumeMounts(overwriteKeys []string) []corev1.VolumeMount { |
| 166 | + mounts := make([]corev1.VolumeMount, 0, len(overwriteKeys)*2) |
| 167 | + sorted := make([]string, len(overwriteKeys)) |
| 168 | + copy(sorted, overwriteKeys) |
| 169 | + slices.Sort(sorted) |
| 170 | + for _, key := range sorted { |
| 171 | + mounts = append(mounts, |
| 172 | + corev1.VolumeMount{ |
| 173 | + Name: CustomConfigVolume, |
| 174 | + MountPath: fmt.Sprintf("%s/%s", ConfigOverwriteBasePath, key), |
| 175 | + SubPath: key, |
| 176 | + ReadOnly: true, |
| 177 | + }, |
| 178 | + corev1.VolumeMount{ |
| 179 | + Name: CustomConfigVolume, |
| 180 | + MountPath: fmt.Sprintf("%s/%s", CustomConfigMountPoint, key), |
| 181 | + SubPath: key, |
| 182 | + ReadOnly: true, |
| 183 | + }, |
| 184 | + ) |
| 185 | + } |
| 186 | + return mounts |
| 187 | +} |
| 188 | + |
148 | 189 | // GetDBSyncVolumes - dbsync volumes |
149 | 190 | // Unlike the individual Barbican services, the DbSyncJob doesn't need a |
150 | 191 | // secret that contains all of the config snippets required by every |
|
0 commit comments