From 88abeca7bf26aad9fb415bf5edaaab455e09548e Mon Sep 17 00:00:00 2001 From: Alan Cha Date: Tue, 19 May 2026 11:08:18 -0400 Subject: [PATCH] refactor: consolidate redundant spireEnabled checks in BuildEnvoyProxyContainer The BuildEnvoyProxyContainerWithSpireOption method had two consecutive if spireEnabled blocks that each appended volume mounts. This consolidates them into a single conditional block for better readability and maintainability while preserving the same functional behavior. Signed-off-by: Alan Cha --- .../webhook/injector/container_builder.go | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/kagenti-operator/internal/webhook/injector/container_builder.go b/kagenti-operator/internal/webhook/injector/container_builder.go index d8cc69d3..923894a7 100644 --- a/kagenti-operator/internal/webhook/injector/container_builder.go +++ b/kagenti-operator/internal/webhook/injector/container_builder.go @@ -109,22 +109,21 @@ func (b *ContainerBuilder) BuildEnvoyProxyContainerWithSpireOption(spireEnabled }, } if spireEnabled { - volumeMounts = append(volumeMounts, corev1.VolumeMount{ - Name: "svid-output", - MountPath: "/opt", - ReadOnly: true, - }) - } - - if spireEnabled { - // authbridge-envoy bundles spiffe-helper; the entrypoint reads - // helper.conf from this mount. Without it, the bundled - // spiffe-helper would fail to start on SPIRE_ENABLED=true. - volumeMounts = append(volumeMounts, corev1.VolumeMount{ - Name: "spiffe-helper-config", - MountPath: "/etc/spiffe-helper", - ReadOnly: true, - }) + volumeMounts = append(volumeMounts, + corev1.VolumeMount{ + Name: "svid-output", + MountPath: "/opt", + ReadOnly: true, + }, + // authbridge-envoy bundles spiffe-helper; the entrypoint reads + // helper.conf from this mount. Without it, the bundled + // spiffe-helper would fail to start on SPIRE_ENABLED=true. + corev1.VolumeMount{ + Name: "spiffe-helper-config", + MountPath: "/etc/spiffe-helper", + ReadOnly: true, + }, + ) } var env []corev1.EnvVar