@@ -45,40 +45,61 @@ type ParentRefAttachmentStatus struct {
45
45
type RouteType string
46
46
47
47
const (
48
+ // RouteTypeHTTP indicates that the RouteType of the L7Route is HTTP
48
49
RouteTypeHTTP RouteType = "http"
50
+ // RouteTypeGRPC indicates that the RouteType of the L7Route is gRPC
49
51
RouteTypeGRPC RouteType = "grpc"
50
52
)
51
53
54
+ // RouteKey is the unique identifier for a L7Route
52
55
type RouteKey struct {
53
56
NamespacedName types.NamespacedName
54
57
RouteType RouteType
55
58
}
56
59
60
+ // L7Route is the generic type for the layer 7 routes, HTTPRoute and GRPCRoute
57
61
type 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.
62
71
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
66
78
}
67
79
68
80
type L7RouteSpec struct {
81
+ // Hostnames defines a set of hostnames used to select a Route used to process the request.
69
82
Hostnames []v1.Hostname
70
- Rules []RouteRule
83
+ // Rules are the list of HTTP matchers, filters and actions.
84
+ Rules []RouteRule
71
85
}
72
86
73
87
type 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.
76
93
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
80
100
}
81
101
102
+ // RouteBackendRef is a wrapper for v1.BackendRef and any BackendRef filters from the HTTPRoute or GRPCRoute.
82
103
type RouteBackendRef struct {
83
104
v1.BackendRef
84
105
Filters []any
@@ -97,22 +118,22 @@ func buildRoutesForGateways(
97
118
98
119
routes := make (map [RouteKey ]* L7Route )
99
120
100
- for _ , ghr := range httpRoutes {
101
- r := buildHTTPRoute (validator , ghr , gatewayNsNames )
121
+ for _ , route := range httpRoutes {
122
+ r := buildHTTPRoute (validator , route , gatewayNsNames )
102
123
if r != nil {
103
124
rk := RouteKey {
104
- NamespacedName : client .ObjectKeyFromObject (ghr ),
125
+ NamespacedName : client .ObjectKeyFromObject (route ),
105
126
RouteType : RouteTypeHTTP ,
106
127
}
107
128
routes [rk ] = r
108
129
}
109
130
}
110
131
111
- for _ , ghr := range grpcRoutes {
112
- r := buildGRPCRoute (validator , ghr , gatewayNsNames )
132
+ for _ , route := range grpcRoutes {
133
+ r := buildGRPCRoute (validator , route , gatewayNsNames )
113
134
if r != nil {
114
135
rk := RouteKey {
115
- NamespacedName : client .ObjectKeyFromObject (ghr ),
136
+ NamespacedName : client .ObjectKeyFromObject (route ),
116
137
RouteType : RouteTypeGRPC ,
117
138
}
118
139
routes [rk ] = r
0 commit comments