Skip to content

Commit 34f00f8

Browse files
committed
Cleanup from PR feedback
1 parent cd3a100 commit 34f00f8

File tree

4 files changed

+26
-10
lines changed

4 files changed

+26
-10
lines changed

apis/v1alpha2/validation/grpcroute.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,14 @@ func validateGRPCHeaderModifier(filter gatewayv1a2.HTTPHeaderFilter, path *field
184184
singleAction[strings.ToLower(string(action.Name))] = true
185185
}
186186
}
187-
for i, action := range filter.Remove {
188-
if needsErr, ok := singleAction[strings.ToLower(action)]; ok {
187+
for i, name := range filter.Remove {
188+
if needsErr, ok := singleAction[strings.ToLower(name)]; ok {
189189
if needsErr {
190190
errs = append(errs, field.Invalid(path.Child("remove"), filter.Remove[i], "cannot specify multiple actions for header"))
191191
}
192-
singleAction[strings.ToLower(action)] = false
192+
singleAction[strings.ToLower(name)] = false
193193
} else {
194-
singleAction[strings.ToLower(action)] = true
194+
singleAction[strings.ToLower(name)] = true
195195
}
196196
}
197197
return errs

apis/v1beta1/validation/httproute.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ func validateHTTPPathMatch(path *gatewayv1b1.HTTPPathMatch, fldPath *field.Path)
176176
r, err := regexp.Compile(validPathCharacters)
177177
if err != nil {
178178
allErrs = append(allErrs, field.InternalError(fldPath.Child("value"),
179-
fmt.Errorf("could not compile path matching regex: %s", err)))
179+
fmt.Errorf("could not compile path matching regex: %w", err)))
180180
} else if !r.MatchString(*path.Value) {
181181
allErrs = append(allErrs, field.Invalid(fldPath.Child("value"), *path.Value,
182182
fmt.Sprintf("must only contain valid characters (matching %s)", validPathCharacters)))
@@ -321,14 +321,14 @@ func validateHTTPHeaderModifier(filter gatewayv1b1.HTTPHeaderFilter, path *field
321321
singleAction[strings.ToLower(string(action.Name))] = true
322322
}
323323
}
324-
for i, action := range filter.Remove {
325-
if needsErr, ok := singleAction[strings.ToLower(action)]; ok {
324+
for i, name := range filter.Remove {
325+
if needsErr, ok := singleAction[strings.ToLower(name)]; ok {
326326
if needsErr {
327327
errs = append(errs, field.Invalid(path.Child("remove"), filter.Remove[i], "cannot specify multiple actions for header"))
328328
}
329-
singleAction[strings.ToLower(action)] = false
329+
singleAction[strings.ToLower(name)] = false
330330
} else {
331-
singleAction[strings.ToLower(action)] = true
331+
singleAction[strings.ToLower(name)] = true
332332
}
333333
}
334334
return errs

hack/invalid-examples/v1alpha2/grpcroute/invalid-method.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ spec:
1010
rules:
1111
- matches:
1212
- method:
13-
- path: ../
13+
- method: ../
1414
backendRefs:
1515
- name: bar-svc
1616
port: 50051
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: gateway.networking.k8s.io/v1alpha2
2+
kind: GRPCRoute
3+
metadata:
4+
name: invalid-method
5+
spec:
6+
parentRefs:
7+
- name: example-gateway
8+
hostnames:
9+
- "bar.example.com"
10+
rules:
11+
- matches:
12+
- method:
13+
- service: ../
14+
backendRefs:
15+
- name: bar-svc
16+
port: 50051

0 commit comments

Comments
 (0)