Skip to content

Commit d7bcd4b

Browse files
committed
Review feedback
1 parent e392c67 commit d7bcd4b

File tree

4 files changed

+56
-35
lines changed

4 files changed

+56
-35
lines changed

go.sum

+2-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ github.com./go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBj
3232
github.com./go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA=
3333
github.com./go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
3434
github.com./go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
35-
github.com./go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
3635
github.com./go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
3736
github.com./go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
3837
github.com./go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
@@ -237,8 +236,8 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
237236
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
238237
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
239238
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
240-
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
241-
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
239+
golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=
240+
golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
242241
golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
243242
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
244243
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=

internal/mode/static/nginx/config/servers.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ func updateLocationsForFilters(
240240
matchRule dataplane.MatchRule,
241241
listenerPort int32,
242242
path string,
243-
GRPC bool,
243+
grpc bool,
244244
) []http.Location {
245245
if filters.InvalidFilter != nil {
246246
for i := range buildLocations {
@@ -258,7 +258,7 @@ func updateLocationsForFilters(
258258
}
259259

260260
rewrites := createRewritesValForRewriteFilter(filters.RequestURLRewrite, path)
261-
proxySetHeaders := generateProxySetHeaders(&matchRule.Filters, GRPC)
261+
proxySetHeaders := generateProxySetHeaders(&matchRule.Filters, grpc)
262262
for i := range buildLocations {
263263
if rewrites != nil {
264264
if rewrites.Rewrite != "" {
@@ -270,18 +270,18 @@ func updateLocationsForFilters(
270270
proxyPass := createProxyPass(
271271
matchRule.BackendGroup,
272272
matchRule.Filters.RequestURLRewrite,
273-
generateProtocolString(buildLocations[i].ProxySSLVerify, GRPC),
274-
GRPC,
273+
generateProtocolString(buildLocations[i].ProxySSLVerify, grpc),
274+
grpc,
275275
)
276276
buildLocations[i].ProxyPass = proxyPass
277-
buildLocations[i].GRPC = GRPC
277+
buildLocations[i].GRPC = grpc
278278
}
279279

280280
return buildLocations
281281
}
282282

283-
func generateProtocolString(ssl *http.ProxySSLVerify, GRPC bool) string {
284-
if !GRPC {
283+
func generateProtocolString(ssl *http.ProxySSLVerify, grpc bool) string {
284+
if !grpc {
285285
if ssl != nil {
286286
return "https"
287287
}
@@ -495,10 +495,10 @@ func createProxyPass(
495495
backendGroup dataplane.BackendGroup,
496496
filter *dataplane.HTTPURLRewriteFilter,
497497
protocol string,
498-
GRPC bool,
498+
grpc bool,
499499
) string {
500500
var requestURI string
501-
if !GRPC {
501+
if !grpc {
502502
if filter == nil || filter.Path == nil {
503503
requestURI = "$request_uri"
504504
}
@@ -518,8 +518,8 @@ func createMatchLocation(path string) http.Location {
518518
}
519519
}
520520

521-
func generateProxySetHeaders(filters *dataplane.HTTPFilters, GRPC bool) []http.Header {
522-
if GRPC {
521+
func generateProxySetHeaders(filters *dataplane.HTTPFilters, grpc bool) []http.Header {
522+
if grpc {
523523
return []http.Header{}
524524
}
525525

internal/mode/static/state/graph/backend_refs.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
staticConds "github.com./nginxinc/nginx-gateway-fabric/internal/mode/static/state/conditions"
1717
)
1818

19-
// BackendRef is an internal representation of a backendRef in an HTTPRoute.
19+
// BackendRef is an internal representation of a backendRef in an HTTP/GRPCRoute.
2020
type BackendRef struct {
2121
// BackendTLSPolicy is the BackendTLSPolicy of the Service which is referenced by the backendRef.
2222
BackendTLSPolicy *BackendTLSPolicy
@@ -231,7 +231,8 @@ func validateBackendTLSPolicyMatchingAllBackends(backendRefs []BackendRef) *cond
231231
func findBackendTLSPolicyForService(
232232
backendTLSPolicies map[types.NamespacedName]*BackendTLSPolicy,
233233
refNamespace *gatewayv1.Namespace,
234-
refName, routeNamespace string,
234+
refName,
235+
routeNamespace string,
235236
) (*BackendTLSPolicy, error) {
236237
var beTLSPolicy *BackendTLSPolicy
237238
var err error

internal/mode/static/state/graph/route_common.go

+40-19
Original file line numberDiff line numberDiff line change
@@ -45,40 +45,61 @@ type ParentRefAttachmentStatus struct {
4545
type RouteType string
4646

4747
const (
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
5255
type 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
5761
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.
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

6880
type 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

7387
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.
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.
82103
type 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

Comments
 (0)