gloo icon indicating copy to clipboard operation
gloo copied to clipboard

HTTPRoute Delegation: Separate querying from translation

Open stevenctl opened this issue 1 year ago • 2 comments

Description

I've split all querying logic to happen upfront before translating HTTPRoutes. HTTPRoute translation is complex enough that I'd like to re-use the code rather than rewrite it or maintain a copy.

Code changes

  • [X] Remove all calls to query.Queries methods in httproute translator
  • [X] Add a new Query that fetches all backends and delegated HTTPRoutes upfront
  • [X] Changed translator tests to show a diff when they fail.
  • [x] Cleanup some now unused parameters being passed around
  • [x] Make some query methods private/helpers
  • [x] Repair any tests that had mocks broken

Context

In an effort to experiment with using alternative ways of fetching data, such as Istio's krt, this allows existing translation to be re-used.

Testing steps

All existing delegation tests are passing. There should be end-behavior changes introduced here.

Notes for reviewers

  • This is a complex PR and may require a huddle to discuss, feel free to reach out anytime.
  • getRoutesForGw was moved from query.go 100% unmodified except for the name, along with the helpers
  • applyDelegationFilters was moved out of GetDelegatedRoutes from the query package and into a translation helper func so it can be re-used.

Checklist:

  • [X] I have performed a self-review of my own code
  • [X] I have commented my code, particularly in hard-to-understand areas
  • [X] I have added tests that prove my fix is effective or that my feature works (kind of)

stevenctl avatar Jun 04 '24 22:06 stevenctl