Skip to content

Refactor(hybrid gateway): Use generics in mapfuncs, index functions, and updating status#3727

Open
randmonkey wants to merge 4 commits intomainfrom
use_generics_in_status_update
Open

Refactor(hybrid gateway): Use generics in mapfuncs, index functions, and updating status#3727
randmonkey wants to merge 4 commits intomainfrom
use_generics_in_status_update

Conversation

@randmonkey
Copy link
Copy Markdown
Contributor

@randmonkey randmonkey commented Mar 30, 2026

What this PR does / why we need it:
Use type generics instead of HTTPRoute only for supporting TLSRoute in the following places:

  • index functions for controllers
  • Map functions for controllers
  • Setting status in hybrid gateway API converters
    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:

  • the CHANGELOG.md release notes have been updated to reflect significant changes

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@randmonkey randmonkey force-pushed the use_generics_in_status_update branch from 200fe62 to 280ec58 Compare March 31, 2026 03:29
@randmonkey randmonkey marked this pull request as ready for review March 31, 2026 03:34
@randmonkey randmonkey requested a review from a team as a code owner March 31, 2026 03:34
Copy link
Copy Markdown
Member

@tao12345666333 tao12345666333 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM, left a comment

@randmonkey randmonkey added this pull request to the merge queue Mar 31, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 31, 2026
@randmonkey randmonkey added this pull request to the merge queue Mar 31, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 31, 2026
@randmonkey randmonkey added this pull request to the merge queue Mar 31, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 31, 2026
@randmonkey randmonkey added this pull request to the merge queue Mar 31, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 31, 2026
@randmonkey randmonkey added this pull request to the merge queue Mar 31, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 31, 2026
@randmonkey randmonkey added this pull request to the merge queue Mar 31, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 31, 2026
@randmonkey randmonkey added this pull request to the merge queue Apr 1, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 1, 2026
@randmonkey randmonkey added this pull request to the merge queue Apr 1, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 1, 2026
@randmonkey randmonkey force-pushed the use_generics_in_status_update branch from 280ec58 to f5b0777 Compare April 1, 2026 02:45
@randmonkey randmonkey closed this Apr 1, 2026
@randmonkey randmonkey reopened this Apr 1, 2026
@randmonkey randmonkey added this pull request to the merge queue Apr 1, 2026
@randmonkey randmonkey removed this pull request from the merge queue due to a manual request Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants