Skip to content

Commit 2ec454c

Browse files
authored
fix: gave configmaps volume mounts a subpath to allow for multiple mounts (#321)
Signed-off-by: Skye Gill <[email protected]>
1 parent 7cba7e1 commit 2ec454c

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

webhooks/pod_webhook.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const (
2828
FlagDImagePullPolicy corev1.PullPolicy = "Always"
2929
clusterRoleBindingName string = "open-feature-operator-flagd-kubernetes-sync"
3030
flagdMetricPortEnvVar string = "FLAGD_METRICS_PORT"
31-
fileSyncMountPath string = "/etc/flagd/"
31+
rootFileSyncMountPath string = "/etc/flagd"
3232
OpenFeatureEnabledAnnotationPath = "metadata.annotations.openfeature.dev/enabled"
3333
)
3434

@@ -385,7 +385,7 @@ func (m *PodMutator) injectSidecar(
385385
commandSequence = append(
386386
commandSequence,
387387
"--uri",
388-
fmt.Sprintf("file:%s%s.json", fileSyncMountPath, featureFlag.Name),
388+
fmt.Sprintf("file:%s", fileSyncMountPath(featureFlag)),
389389
)
390390
pod.Spec.Volumes = append(pod.Spec.Volumes, corev1.Volume{
391391
Name: featureFlag.Name,
@@ -399,7 +399,8 @@ func (m *PodMutator) injectSidecar(
399399
})
400400
volumeMounts = append(volumeMounts, corev1.VolumeMount{
401401
Name: featureFlag.Name,
402-
MountPath: fileSyncMountPath,
402+
MountPath: fileSyncMountPath(featureFlag),
403+
SubPath: fileSyncFileName(featureFlag),
403404
})
404405
default:
405406
err := fmt.Errorf(
@@ -473,6 +474,14 @@ func setSecurityContext() *corev1.SecurityContext {
473474
}
474475
}
475476

477+
func fileSyncMountPath(featureFlag *corev1alpha1.FeatureFlagConfiguration) string {
478+
return fmt.Sprintf("%s/%s", rootFileSyncMountPath, fileSyncFileName(featureFlag))
479+
}
480+
481+
func fileSyncFileName(featureFlag *corev1alpha1.FeatureFlagConfiguration) string {
482+
return fmt.Sprintf("%s.json", featureFlag.Name)
483+
}
484+
476485
func OpenFeatureEnabledAnnotationIndex(o client.Object) []string {
477486
pod := o.(*corev1.Pod)
478487
if pod.ObjectMeta.Annotations == nil {

0 commit comments

Comments
 (0)