Commit fafa0d1
feat(api): Add filterContext field to Lua type in EnvoyExtensionPolicy (envoyproxy#8730)
* feat: add filterContext field to Lua EnvoyExtensionPolicy (envoyproxy#8715)
Add an optional `filterContext` field (map[string]string) to the Lua type
in EnvoyExtensionPolicySpec. This exposes Envoy's existing
LuaPerRoute.filter_context so that a shared Lua script can be
parameterized differently per route via request_handle:filterContext().
Without this, users must either duplicate the entire script inline with
hardcoded values or resort to EnvoyPatchPolicy to manually patch xDS.
Changes:
- api: add FilterContext to Lua struct
- ir: add FilterContext to IR Lua struct
- gatewayapi: pass FilterContext from API to IR in buildLua()
- xds: set FilterContext on LuaPerRoute in patchRoute(), converting
map[string]string to structpb.Struct
- tests: update gatewayapi/xds translator testdata, add e2e test
- docs: add FilterContext section to Lua extension task guide
Signed-off-by: Norman Stetter <85173861+norman-zon@users.noreply.github.com>
* feat: update release notes
Signed-off-by: Norman Stetter <85173861+norman-zon@users.noreply.github.com>
* chore: regenerate test output and helm CRD files
Signed-off-by: Norman Stetter <85173861+norman-zon@users.noreply.github.com>
* fix: add missing mocks
Signed-off-by: Norman Stetter <85173861+norman-zon@users.noreply.github.com>
* fix(e2e): use retry pattern for lua filter context test
Signed-off-by: Norman Stetter <85173861+norman-zon@users.noreply.github.com>
* fix(api): use apiextensionsv1.JSON for Lua filterContext
Address review feedback on envoyproxy#8730:
- Change FilterContext field type from map[string]string to
*apiextensionsv1.JSON in both the API (lua_types.go) and IR (xds.go),
matching the existing pattern used by Wasm.Config and
DynamicModule.Config.
- Drop json/yaml struct tags from ir.Lua.FilterContext, consistent with
the other untagged fields on that struct.
- Update the xDS translator to unmarshal FilterContext.Raw into
structpb.Struct via protojson.Unmarshal, replacing the previous
string-only map iteration.
- Regenerate deepcopy, CRD manifests, and test fixtures.
Users can now pass non-string JSON values (numbers, bools, nested
objects) in filterContext without stringifying them.
Signed-off-by: Norman Stetter <85173861+norman-zon@users.noreply.github.com>
* fix(e2e): use request_handle:filterContext() and dynamicMetadata to propagate filter context in Lua test
filterContext() is only available on request_handle, not response_handle.
Read the value in envoy_on_request and store it via dynamicMetadata, then
retrieve it in envoy_on_response to set the X-Lua-Filter-Context header.
Fixes TestE2E/LuaHTTP/http_route_with_lua_filter_context
Signed-off-by: Norman Stetter <85173861+norman-zon@users.noreply.github.com>
* fix(e2e): simplify lua filter context script to use response_handle:filterContext() directly
The previous script had a nil-value bug:
- ctx["custom_value"] returns nil when filterContext() wraps an empty struct
- Storing nil via dynamicMetadata and then using it in headers():add() caused
a silent Lua error, so the response header was never set
Fix by calling response_handle:filterContext() directly in envoy_on_response,
which is available on both request and response handles per Envoy's C++ source.
Also add a nil guard for val before calling headers():add() to be safe.
Signed-off-by: Norman Stetter <85173861+norman-zon@users.noreply.github.com>
* fix(e2e): use dynamicMetadata to bridge lua filter context between phases
Signed-off-by: Norman Stetter <85173861+norman-zon@users.noreply.github.com>
* fix(e2e): simplify lua filter context by storing value string directly
Signed-off-by: Norman Stetter <85173861+norman-zon@users.noreply.github.com>
* fix(e2e): read Lua filterContext via ctx:get() instead of table indexing
filterContext() returns a MetadataMapWrapper whose only Lua methods are
get and __pairs; its metatable __index points at the methods table, so
ctx["custom_value"] resolves to a method lookup and always returns nil.
Read values via ctx:get("custom_value") instead.
The per-route filter config is re-resolved on the response path, so the
response handle exposes filterContext directly; the dynamicMetadata bridge
is unnecessary and the script is now a single response-phase function.
Update the luavalidator mock so StreamHandle:filterContext() returns the
Metadata wrapper (with a :get method) matching real Envoy, add a validator
test for the get() syntax, and fix the docs examples accordingly.
Signed-off-by: Norman Stetter <85173861+norman-zon@users.noreply.github.com>
---------
Signed-off-by: Norman Stetter <85173861+norman-zon@users.noreply.github.com>
Signed-off-by: Rudrakh Panigrahi <rudrakh97@gmail.com>
Co-authored-by: Rudrakh Panigrahi <rudrakh97@gmail.com>1 parent 0ab5d11 commit fafa0d1
27 files changed
Lines changed: 325 additions & 5 deletions
File tree
- api/v1alpha1
- charts
- gateway-crds-helm/templates/generated
- gateway-helm/charts/crds/crds/generated
- internal
- gatewayapi
- luavalidator
- testdata
- ir
- xds/translator
- testdata
- in/xds-ir
- out/xds-ir
- release-notes
- site/content/en/latest
- api
- tasks/extensibility
- test
- e2e
- testdata
- tests
- helm/gateway-crds-helm
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
9 | 12 | | |
10 | 13 | | |
11 | 14 | | |
| |||
45 | 48 | | |
46 | 49 | | |
47 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
48 | 58 | | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1641 | 1641 | | |
1642 | 1642 | | |
1643 | 1643 | | |
| 1644 | + | |
| 1645 | + | |
| 1646 | + | |
| 1647 | + | |
| 1648 | + | |
| 1649 | + | |
| 1650 | + | |
1644 | 1651 | | |
1645 | 1652 | | |
1646 | 1653 | | |
| |||
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1640 | 1640 | | |
1641 | 1641 | | |
1642 | 1642 | | |
| 1643 | + | |
| 1644 | + | |
| 1645 | + | |
| 1646 | + | |
| 1647 | + | |
| 1648 | + | |
| 1649 | + | |
1643 | 1650 | | |
1644 | 1651 | | |
1645 | 1652 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
774 | 774 | | |
775 | 775 | | |
776 | 776 | | |
777 | | - | |
778 | | - | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
779 | 780 | | |
780 | 781 | | |
781 | 782 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
181 | 181 | | |
182 | 182 | | |
183 | 183 | | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
184 | 197 | | |
185 | 198 | | |
186 | 199 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
587 | 587 | | |
588 | 588 | | |
589 | 589 | | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
590 | 594 | | |
591 | 595 | | |
592 | 596 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
| 218 | + | |
218 | 219 | | |
219 | 220 | | |
220 | 221 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
317 | 317 | | |
318 | 318 | | |
319 | 319 | | |
| 320 | + | |
320 | 321 | | |
321 | 322 | | |
322 | 323 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
292 | 292 | | |
293 | 293 | | |
294 | 294 | | |
| 295 | + | |
295 | 296 | | |
296 | 297 | | |
297 | 298 | | |
| |||
327 | 328 | | |
328 | 329 | | |
329 | 330 | | |
| 331 | + | |
330 | 332 | | |
331 | 333 | | |
332 | 334 | | |
| |||
0 commit comments