Skip to content

Commit a824a30

Browse files
committed
refactor: remove SpiffeHelperConf from webhook namespace/resolved config
Webhook no longer reads spiffe-helper-config CM at admission time. Remove SpiffeHelperConf field from NamespaceConfig and ResolvedConfig structs. The controller now derives the CM from PlatformConfig; the volume mount still references the CM by name (unchanged). RHAIENG-4939 Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Ian Miller <milleryan2003@gmail.com>
1 parent 1fdd126 commit a824a30

4 files changed

Lines changed: 4 additions & 24 deletions

File tree

kagenti-operator/internal/webhook/injector/namespace_config.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ type NamespaceConfig struct {
5353
SpiffeIdpAlias string // Keycloak SPIFFE Identity Provider alias (e.g., "spire-spiffe")
5454
JWTAudience string // Audience for SPIFFE JWT-SVIDs (token-exchange identity.jwt_audience)
5555

56-
// From "spiffe-helper-config" ConfigMap
57-
SpiffeHelperConf string // raw helper.conf content
58-
5956
// From "authproxy-routes" ConfigMap
6057
AuthproxyRoutesYAML string // raw routes.yaml content
6158

@@ -91,12 +88,9 @@ func ReadNamespaceConfig(ctx context.Context, c client.Reader, namespace string)
9188
// uses SecretKeyRef to reference the secret by name, keeping credentials out of
9289
// the NamespaceConfig struct and the webhook's memory.
9390

94-
// Read "spiffe-helper-config" ConfigMap
95-
if cm, err := getConfigMap(ctx, c, namespace, SpiffeHelperConfigMapName); err != nil {
96-
nsConfigLog.V(1).Info("ConfigMap not found", "name", SpiffeHelperConfigMapName, "namespace", namespace, "error", err)
97-
} else {
98-
cfg.SpiffeHelperConf = cm.Data["helper.conf"]
99-
}
91+
// Note: spiffe-helper-config is NOT read here. The controller derives it
92+
// from PlatformConfig via ensureSpiffeHelperConfigMap(). The volume mount
93+
// still references SpiffeHelperConfigMapName directly.
10094

10195
// Read "authproxy-routes" ConfigMap
10296
if cm, err := getConfigMap(ctx, c, namespace, AuthproxyRoutesConfigMapName); err != nil {

kagenti-operator/internal/webhook/injector/namespace_config_test.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,12 @@ func TestReadNamespaceConfig_AllPresent(t *testing.T) {
4848
"DEFAULT_OUTBOUND_POLICY": "passthrough",
4949
},
5050
}
51-
spiffeCM := &corev1.ConfigMap{
52-
ObjectMeta: metav1.ObjectMeta{Name: SpiffeHelperConfigMapName, Namespace: "ns1"},
53-
Data: map[string]string{"helper.conf": "agent_address = \"/spiffe-workload-api/spire-agent.sock\""},
54-
}
5551
routesCM := &corev1.ConfigMap{
5652
ObjectMeta: metav1.ObjectMeta{Name: AuthproxyRoutesConfigMapName, Namespace: "ns1"},
5753
Data: map[string]string{"routes.yaml": "routes: []"},
5854
}
5955

60-
reader := newFakeReader(abCM, spiffeCM, routesCM)
56+
reader := newFakeReader(abCM, routesCM)
6157
cfg, err := ReadNamespaceConfig(context.Background(), reader, "ns1")
6258
if err != nil {
6359
t.Fatalf("unexpected error: %v", err)
@@ -75,9 +71,6 @@ func TestReadNamespaceConfig_AllPresent(t *testing.T) {
7571
if cfg.Issuer != "http://keycloak:8080/realms/demo" {
7672
t.Errorf("Issuer = %q", cfg.Issuer)
7773
}
78-
if cfg.SpiffeHelperConf == "" {
79-
t.Error("SpiffeHelperConf is empty")
80-
}
8174
if cfg.TargetAudience != "auth-target" {
8275
t.Errorf("TargetAudience = %q", cfg.TargetAudience)
8376
}

kagenti-operator/internal/webhook/injector/resolved_config.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ type ResolvedConfig struct {
4747
SpiffeIdpAlias string // Keycloak SPIFFE Identity Provider alias
4848

4949
// Sidecar configs — from namespace CMs (not overridable by AgentRuntime v1alpha1)
50-
SpiffeHelperConf string
5150
AuthproxyRoutesYAML string
5251

5352
// AuthBridge runtime config — from namespace "authbridge-runtime-config" ConfigMap
@@ -92,7 +91,6 @@ func ResolveConfig(platform *config.PlatformConfig, ns *NamespaceConfig, ar *Age
9291
DefaultOutboundPolicy: ns.DefaultOutboundPolicy,
9392
ClientAuthType: ns.ClientAuthType,
9493
SpiffeIdpAlias: ns.SpiffeIdpAlias,
95-
SpiffeHelperConf: ns.SpiffeHelperConf,
9694
AuthproxyRoutesYAML: ns.AuthproxyRoutesYAML,
9795
AuthBridgeRuntimeYAML: ns.AuthBridgeRuntimeYAML,
9896
}

kagenti-operator/internal/webhook/injector/resolved_config_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,13 @@ func TestResolveConfig_SpiffeTrustDomain_AROverride(t *testing.T) {
9696

9797
func TestResolveConfig_SidecarConfigs_NotOverridable(t *testing.T) {
9898
ns := &NamespaceConfig{
99-
SpiffeHelperConf: "helper.conf content",
10099
AuthproxyRoutesYAML: "routes.yaml content",
101100
}
102-
// AR overrides don't have fields for these — they flow through from namespace
103101
ar := &AgentRuntimeOverrides{
104102
SpiffeTrustDomain: ptr.To("override"),
105103
}
106104

107105
resolved := ResolveConfig(config.CompiledDefaults(), ns, ar)
108-
if resolved.SpiffeHelperConf != "helper.conf content" {
109-
t.Errorf("SpiffeHelperConf should come from namespace")
110-
}
111106
if resolved.AuthproxyRoutesYAML != "routes.yaml content" {
112107
t.Errorf("AuthproxyRoutesYAML should come from namespace")
113108
}

0 commit comments

Comments
 (0)