Refactor(hybrid gateway): Use generics in mapfuncs, index functions, and updating status#3727
Refactor(hybrid gateway): Use generics in mapfuncs, index functions, and updating status#3727randmonkey wants to merge 4 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Refactors hybrid gateway route handling to use generic helpers (instead of HTTPRoute-only implementations) in indexing, controller watch map functions, and status/ReferenceGrant handling—intended to enable future support for additional Gateway API route types (e.g., TLSRoute). Updates and reorganizes unit tests accordingly.
Changes:
- Introduces shared/generic route index utilities (e.g.,
GatewaysOnRoute) and updates HTTPRoute indexes to use them. - Adds generic/shared map functions for Gateway/Service/EndpointSlice-to-route reconciliation wiring, and updates watchers to use them.
- Refactors route status helpers and ReferenceGrant checks to be route-kind aware; updates converter/target/status tests (including setting
TypeMeta).
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/utils/index/httproute.go | Switches HTTPRoute gateway index extraction to generic GatewaysOnRoute; backend service indexing uses shared backendRef helper. |
| internal/utils/index/httproute_test.go | Replaces old gateway-parentref tests with backendRef + plugin filter coverage; minor naming/typo issues. |
| internal/utils/index/gateway_route.go | Adds generic GatewaysOnRoute and shared backendRefToServiceKey. |
| internal/utils/index/gateway_route_test.go | Adds tests for generic GatewaysOnRoute and shared pointer helpers. |
| controller/hybridgateway/watch/watch.go | Updates HTTPRoute watchers to use generic MapRouteFor* map funcs. |
| controller/hybridgateway/watch/mapfuncs_httproute.go | Removes HTTPRoute-specific map funcs in favor of shared ones; updates KongPlugin mapfunc to call generic Kong resource mapper. |
| controller/hybridgateway/watch/mapfuncs_httproute_test.go | Updates index usage to GatewaysOnRoute. |
| controller/hybridgateway/watch/mapfuncs_gateway_route.go | Adds shared generic map funcs for Gateway/GatewayClass/Service/EndpointSlice and generic Kong resource mapper. |
| controller/hybridgateway/watch/mapfuncs_gateway_route_test.go | Adds tests for new shared map funcs (currently with indexing mismatch vs production). |
| controller/hybridgateway/target/target.go | Updates ReferenceGrant check call to pass backendRef + route kind. |
| controller/hybridgateway/target/target_test.go | Sets TypeMeta on test HTTPRoutes. |
| controller/hybridgateway/route/status.go | Generalizes multiple status/ReferenceGrant helpers; extracts BackendRef resolved condition logic; renames resolved-refs builder. (Contains a compile-breaking generic signature issue.) |
| controller/hybridgateway/route/status_test.go | Renames ReferenceGrant test and updates callsites; adds TypeMeta to many route fixtures; updates resolved-refs builder calls. |
| controller/hybridgateway/converter/http_route.go | Uses renamed resolved-refs builder function. |
| controller/hybridgateway/converter/http_route_converter_test.go | Sets TypeMeta on generated HTTPRoute fixtures. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
7feb874 to
200fe62
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 15 changed files in this pull request and generated 8 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
200fe62 to
280ec58
Compare
tao12345666333
left a comment
There was a problem hiding this comment.
Overall LGTM, left a comment
280ec58 to
f5b0777
Compare
What this PR does / why we need it:
Use type generics instead of
HTTPRouteonly for supportingTLSRoutein the following places:Also updates the unit tests.
Which issue this PR fixes
Split from #3708
Special notes for your reviewer:
PR Readiness Checklist:
Complete these before marking the PR as
ready to review:CHANGELOG.mdrelease notes have been updated to reflect significant changes