|
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,37 @@ 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 | +// Backwards compatibility: the overwrite keys also remain accessible at |
| 159 | +// /etc/barbican/barbican.conf.d/<key> because the config-data-custom Secret |
| 160 | +// is already directory-mounted at /etc/barbican/barbican.conf.d/ by |
| 161 | +// GetCustomConfigVolumeMount. This preserves customer workarounds where e.g. |
| 162 | +// policy.yaml was referenced via customServiceConfig as: |
| 163 | +// |
| 164 | +// [oslo_policy] |
| 165 | +// policy_file = /etc/barbican/barbican.conf.d/policy.yaml |
| 166 | +func GetConfigOverwriteVolumeMounts(overwriteKeys []string) []corev1.VolumeMount { |
| 167 | + mounts := make([]corev1.VolumeMount, 0, len(overwriteKeys)) |
| 168 | + sorted := make([]string, len(overwriteKeys)) |
| 169 | + copy(sorted, overwriteKeys) |
| 170 | + slices.Sort(sorted) |
| 171 | + for _, key := range sorted { |
| 172 | + mounts = append(mounts, corev1.VolumeMount{ |
| 173 | + Name: CustomConfigVolume, |
| 174 | + MountPath: fmt.Sprintf("%s/%s", ConfigOverwriteBasePath, key), |
| 175 | + SubPath: key, |
| 176 | + ReadOnly: true, |
| 177 | + }) |
| 178 | + } |
| 179 | + return mounts |
| 180 | +} |
| 181 | + |
148 | 182 | // GetDBSyncVolumes - dbsync volumes |
149 | 183 | // Unlike the individual Barbican services, the DbSyncJob doesn't need a |
150 | 184 | // secret that contains all of the config snippets required by every |
|
0 commit comments