Repository: envoyproxy/gateway
Pull request #5329 (2025-02-22 14:52:41)

fix: Standalone mode - Secret and ConfigMap parsing
**What type of PR is this?**
* "fix: fix xx bug"
Standalone mode does not parse Secret and ConfigMap resources. 

**What this PR does / why we need it**:
Now Standalone mode parses the Secret and ConfigMap resources. This enables the use of the OIDC task in Standalone mode.

**Which issue(s) this PR fixes**:
Fixes https://github.com/envoyproxy/gateway/issues/5318

Release Notes: Yes


codecov[bot]: ## [Codecov](https://app.codecov.io/gh/envoyproxy/gateway/pull/5329?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=envoyproxy) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 64.95%. Comparing base [(`f8c0b32`)](https://app.codecov.io/gh/envoyproxy/gateway/commit/f8c0b323a7f079be371e07a469af44ddf0ca7a7b?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=envoyproxy) to head [(`d081af8`)](https://app.codecov.io/gh/envoyproxy/gateway/commit/d081af822e9183927a5cd06f200f37ce3e36d795?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=envoyproxy).

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##             main    #5329      +/-   ##
==========================================
- Coverage   64.98%   64.95%   -0.03%     
==========================================
  Files         213      213              
  Lines       33474    33504      +30     
==========================================
+ Hits        21752    21763      +11     
- Misses      10396    10409      +13     
- Partials     1326     1332       +6     
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/envoyproxy/gateway/pull/5329?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=envoyproxy).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=envoyproxy).

bstasz: @shawnh2 @zirain
Hello,
Is it possible to run a single E2E test locally? Two tests failed during the E2E run. Tried running the E2E tests locally, but it timed out after 1 hour.
The 2 tests would be
- TestE2E/UsageRateLimit
- TestMultipleGC/Private_GC_Test/PrivateGC/private_gc 
bstasz: I made a mistake with creating a merge commit from main. I see the merge is blocked because `This branch must not contain merge commits.`. Should I rebase the branch?
arkodg: > I made a mistake with creating a merge commit from main. I see the merge is blocked because `This branch must not contain merge commits.`. Should I rebase the branch?

All looks good, this PR needs another approval from a reviewer/maintainer and should be in soon :)

Patch:
diff --git a/examples/extension-server/go.mod b/examples/extension-server/go.mod
index 37173798f..ed38b67c3 100644
--- a/examples/extension-server/go.mod
+++ b/examples/extension-server/go.mod
@@ -3,7 +3,7 @@ module github.com/exampleorg/envoygateway-extension
 go 1.24.0
 
 require (
-	github.com/envoyproxy/gateway v1.0.2
+	github.com/envoyproxy/gateway v1.3.0
 	github.com/envoyproxy/go-control-plane v0.13.4
 	github.com/envoyproxy/go-control-plane/envoy v1.32.4
 	github.com/urfave/cli/v2 v2.27.5
diff --git a/internal/gatewayapi/resource/load.go b/internal/gatewayapi/resource/load.go
index d9bcaa9b1..e3357b0b2 100644
--- a/internal/gatewayapi/resource/load.go
+++ b/internal/gatewayapi/resource/load.go
@@ -99,6 +99,8 @@ func loadKubernetesYAMLToResources(input []byte, addMissingResources bool) (*Res
 		}
 		kobjVal := reflect.ValueOf(kobj).Elem()
 		spec := kobjVal.FieldByName("Spec")
+		data := kobjVal.FieldByName("Data")
+		stringData := kobjVal.FieldByName("StringData")
 
 		switch gvk.Kind {
 		case KindEnvoyProxy:
@@ -311,6 +313,34 @@ func loadKubernetesYAMLToResources(input []byte, addMissingResources bool) (*Res
 				Spec: typedSpec.(egv1a1.BackendSpec),
 			}
 			resources.Backends = append(resources.Backends, backend)
+		case KindSecret:
+			typedData := data.Interface()
+			typedStringData := stringData.Interface()
+			secret := &corev1.Secret{
+				TypeMeta: metav1.TypeMeta{
+					Kind: KindSecret,
+				},
+				ObjectMeta: metav1.ObjectMeta{
+					Name:      name,
+					Namespace: namespace,
+				},
+				Data:       typedData.(map[string][]byte),
+				StringData: typedStringData.(map[string]string),
+			}
+			resources.Secrets = append(resources.Secrets, secret)
+		case KindConfigMap:
+			typedData := data.Interface()
+			configMap := &corev1.ConfigMap{
+				TypeMeta: metav1.TypeMeta{
+					Kind: KindConfigMap,
+				},
+				ObjectMeta: metav1.ObjectMeta{
+					Name:      name,
+					Namespace: namespace,
+				},
+				Data: typedData.(map[string]string),
+			}
+			resources.ConfigMaps = append(resources.ConfigMaps, configMap)
 		}
 
 		return nil
diff --git a/release-notes/current.yaml b/release-notes/current.yaml
index cf57e3ed3..a72b97fe8 100644
--- a/release-notes/current.yaml
+++ b/release-notes/current.yaml
@@ -18,6 +18,7 @@ new features: |
   Added support for HorizontalPodAutoscaler to helm chart
 
 bug fixes: |
+  Added support for Secret and ConfigMap parsing in Standalone mode.
   Bypass overload manager for stats and ready listeners
 
 # Enhancements that improve performance.


Test patch:
diff --git a/internal/gatewayapi/resource/testdata/all-resources.in.yaml b/internal/gatewayapi/resource/testdata/all-resources.in.yaml
index 733660178..6bb599437 100644
--- a/internal/gatewayapi/resource/testdata/all-resources.in.yaml
+++ b/internal/gatewayapi/resource/testdata/all-resources.in.yaml
@@ -229,3 +229,40 @@ spec:
     - ip:
         address: 0.0.0.0
         port: 4321
+---
+apiVersion: v1
+kind: Secret
+metadata:
+  name: secret-with-data-and-string-data
+  namespace: default
+data:
+  .secret-file: dmFsdWUtMg0KDQo=
+stringData:
+  secret: "literal value"
+---
+apiVersion: v1
+kind: Secret
+metadata:
+  name: secret-with-data
+  namespace: default
+data:
+  .secret-file: dmFsdWUtMg0KDQo=
+---
+apiVersion: v1
+kind: Secret
+metadata:
+  name: secret-with-string-data
+  namespace: default
+stringData:
+  secret: "literal value"
+---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: configmap
+  namespace: default
+data:
+  player_initial_lives: "3"
+  game.properties: |
+    enemy.types=aliens,monsters
+    player.maximum-lives=5
diff --git a/internal/gatewayapi/resource/testdata/all-resources.out.yaml b/internal/gatewayapi/resource/testdata/all-resources.out.yaml
index 162b782ab..00f0bf210 100644
--- a/internal/gatewayapi/resource/testdata/all-resources.out.yaml
+++ b/internal/gatewayapi/resource/testdata/all-resources.out.yaml
@@ -71,6 +71,17 @@ clientTrafficPolicies:
         requestReceivedTimeout: 50ms
   status:
     ancestors: null
+configMaps:
+- data:
+    game.properties: |
+      enemy.types=aliens,monsters
+      player.maximum-lives=5
+    player_initial_lives: "3"
+  kind: ConfigMap
+  metadata:
+    creationTimestamp: null
+    name: configmap
+    namespace: default
 envoyPatchPolicies:
 - kind: EnvoyPatchPolicy
   metadata:
@@ -234,6 +245,30 @@ namespaces:
     name: gateway-conformance-infra
   spec: {}
   status: {}
+secrets:
+- data:
+    .secret-file: dmFsdWUtMg0KDQo=
+  kind: Secret
+  metadata:
+    creationTimestamp: null
+    name: secret-with-data-and-string-data
+    namespace: default
+  stringData:
+    secret: literal value
+- data:
+    .secret-file: dmFsdWUtMg0KDQo=
+  kind: Secret
+  metadata:
+    creationTimestamp: null
+    name: secret-with-data
+    namespace: default
+- kind: Secret
+  metadata:
+    creationTimestamp: null
+    name: secret-with-string-data
+    namespace: default
+  stringData:
+    secret: literal value
 securityPolicies:
 - kind: SecurityPolicy
   metadata: