@@ -45,40 +45,61 @@ type ParentRefAttachmentStatus struct {
4545type RouteType string
4646
4747const (
48+ // RouteTypeHTTP indicates that the RouteType of the L7Route is HTTP
4849 RouteTypeHTTP RouteType = "http"
50+ // RouteTypeGRPC indicates that the RouteType of the L7Route is gRPC
4951 RouteTypeGRPC RouteType = "grpc"
5052)
5153
54+ // RouteKey is the unique identifier for a L7Route
5255type RouteKey struct {
5356 NamespacedName types.NamespacedName
5457 RouteType RouteType
5558}
5659
60+ // L7Route is the generic type for the layer 7 routes, HTTPRoute and GRPCRoute
5761type L7Route struct {
58- Source client.Object
59- RouteType RouteType
60- Spec L7RouteSpec
61- ParentRefs []ParentRef
62+ // Source is the source Gateway API object of the Route.
63+ Source client.Object
64+ // RouteType is the type (http or grpc) of the Route.
65+ RouteType RouteType
66+ // Spec is the L7RouteSpec of the Route
67+ Spec L7RouteSpec
68+ // ParentRefs describe the references to the parents in a Route.
69+ ParentRefs []ParentRef
70+ // SrcParentRefs contain the Gateway API references to the parents in a Route.
6271 SrcParentRefs []v1.ParentReference
63- Conditions []conditions.Condition
64- Valid bool
65- Attachable bool
72+ // Conditions define the conditions to be reported in the status of the Route.
73+ Conditions []conditions.Condition
74+ // Valid indicates if the Route is valid.
75+ Valid bool
76+ // Attachable indicates if the Route is attachable to any Listener.
77+ Attachable bool
6678}
6779
6880type L7RouteSpec struct {
81+ // Hostnames defines a set of hostnames used to select a Route used to process the request.
6982 Hostnames []v1.Hostname
70- Rules []RouteRule
83+ // Rules are the list of HTTP matchers, filters and actions.
84+ Rules []RouteRule
7185}
7286
7387type RouteRule struct {
74- Matches []v1.HTTPRouteMatch
75- Filters []v1.HTTPRouteFilter
88+ // Matches define the predicate used to match requests to a given action.
89+ Matches []v1.HTTPRouteMatch
90+ // Filters define processing steps that must be completed during the request or response lifecycle.
91+ Filters []v1.HTTPRouteFilter
92+ // RouteBackendRefs are a wrapper for v1.BackendRef and any BackendRef filters from the HTTPRoute or GRPCRoute.
7693 RouteBackendRefs []RouteBackendRef
77- BackendRefs []BackendRef
78- ValidMatches bool
79- ValidFilters bool
94+ // BackendRefs is an internal representation of a backendRef in a Route.
95+ BackendRefs []BackendRef
96+ // ValidMatches indicates if the matches are valid and accepted by the Route.
97+ ValidMatches bool
98+ // ValidFilters indicates if the filters are valid and accepted by the Route.
99+ ValidFilters bool
80100}
81101
102+ // RouteBackendRef is a wrapper for v1.BackendRef and any BackendRef filters from the HTTPRoute or GRPCRoute.
82103type RouteBackendRef struct {
83104 v1.BackendRef
84105 Filters []any
@@ -97,22 +118,22 @@ func buildRoutesForGateways(
97118
98119 routes := make (map [RouteKey ]* L7Route )
99120
100- for _ , ghr := range httpRoutes {
101- r := buildHTTPRoute (validator , ghr , gatewayNsNames )
121+ for _ , route := range httpRoutes {
122+ r := buildHTTPRoute (validator , route , gatewayNsNames )
102123 if r != nil {
103124 rk := RouteKey {
104- NamespacedName : client .ObjectKeyFromObject (ghr ),
125+ NamespacedName : client .ObjectKeyFromObject (route ),
105126 RouteType : RouteTypeHTTP ,
106127 }
107128 routes [rk ] = r
108129 }
109130 }
110131
111- for _ , ghr := range grpcRoutes {
112- r := buildGRPCRoute (validator , ghr , gatewayNsNames )
132+ for _ , route := range grpcRoutes {
133+ r := buildGRPCRoute (validator , route , gatewayNsNames )
113134 if r != nil {
114135 rk := RouteKey {
115- NamespacedName : client .ObjectKeyFromObject (ghr ),
136+ NamespacedName : client .ObjectKeyFromObject (route ),
116137 RouteType : RouteTypeGRPC ,
117138 }
118139 routes [rk ] = r
0 commit comments