From e3b43b6eb9b666d12fbe53e1ff4ff4aa0177820b Mon Sep 17 00:00:00 2001 From: Alexander Nicke Date: Fri, 18 Oct 2024 10:57:54 +0200 Subject: [PATCH] feat: implement support for per-route options This commit adds support for per-route options to the CFRoute struct. Required for route-emitter to forward the route-specific Options field. Co-authored-by: Tamara Boehm See: https://github.com/cloudfoundry/community/issues/909 --- cfroutes/routing_info_helpers.go | 11 ++++++----- cfroutes/routing_info_helpers_test.go | 8 +++++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/cfroutes/routing_info_helpers.go b/cfroutes/routing_info_helpers.go index 5e7ce74..a7536a3 100644 --- a/cfroutes/routing_info_helpers.go +++ b/cfroutes/routing_info_helpers.go @@ -11,11 +11,12 @@ const CF_ROUTER = "cf-router" type CFRoutes []CFRoute type CFRoute struct { - Hostnames []string `json:"hostnames"` - Port uint32 `json:"port"` - RouteServiceUrl string `json:"route_service_url,omitempty"` - IsolationSegment string `json:"isolation_segment,omitempty"` - Protocol string `json:"protocol,omitempty"` + Hostnames []string `json:"hostnames"` + Port uint32 `json:"port"` + RouteServiceUrl string `json:"route_service_url,omitempty"` + IsolationSegment string `json:"isolation_segment,omitempty"` + Protocol string `json:"protocol,omitempty"` + Options json.RawMessage `json:"options,omitempty"` } func (c CFRoutes) RoutingInfo() models.Routes { diff --git a/cfroutes/routing_info_helpers_test.go b/cfroutes/routing_info_helpers_test.go index 36402f4..5500be2 100644 --- a/cfroutes/routing_info_helpers_test.go +++ b/cfroutes/routing_info_helpers_test.go @@ -15,6 +15,7 @@ var _ = Describe("RoutingInfoHelpers", func() { route1 cfroutes.CFRoute route2 cfroutes.CFRoute route3 cfroutes.CFRoute + route4 cfroutes.CFRoute routes cfroutes.CFRoutes ) @@ -34,8 +35,13 @@ var _ = Describe("RoutingInfoHelpers", func() { RouteServiceUrl: "rs.example.com", Protocol: "http2", } + route4 = cfroutes.CFRoute{ + Hostnames: []string{"foo4.example.com", "bar4.examaple.com"}, + Port: 44444, + Options: json.RawMessage(`{"lb_algo":"least-connection"}`), + } - routes = cfroutes.CFRoutes{route1, route2, route3} + routes = cfroutes.CFRoutes{route1, route2, route3, route4} }) Describe("RoutingInfo", func() {