Skip to content

Commit

Permalink
Cleanup from PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
robscott committed Dec 15, 2022
1 parent cd3a100 commit 34f00f8
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
8 changes: 4 additions & 4 deletions apis/v1alpha2/validation/grpcroute.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,14 @@ func validateGRPCHeaderModifier(filter gatewayv1a2.HTTPHeaderFilter, path *field
singleAction[strings.ToLower(string(action.Name))] = true
}
}
for i, action := range filter.Remove {
if needsErr, ok := singleAction[strings.ToLower(action)]; ok {
for i, name := range filter.Remove {
if needsErr, ok := singleAction[strings.ToLower(name)]; ok {
if needsErr {
errs = append(errs, field.Invalid(path.Child("remove"), filter.Remove[i], "cannot specify multiple actions for header"))
}
singleAction[strings.ToLower(action)] = false
singleAction[strings.ToLower(name)] = false
} else {
singleAction[strings.ToLower(action)] = true
singleAction[strings.ToLower(name)] = true
}
}
return errs
Expand Down
10 changes: 5 additions & 5 deletions apis/v1beta1/validation/httproute.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func validateHTTPPathMatch(path *gatewayv1b1.HTTPPathMatch, fldPath *field.Path)
r, err := regexp.Compile(validPathCharacters)
if err != nil {
allErrs = append(allErrs, field.InternalError(fldPath.Child("value"),
fmt.Errorf("could not compile path matching regex: %s", err)))
fmt.Errorf("could not compile path matching regex: %w", err)))
} else if !r.MatchString(*path.Value) {
allErrs = append(allErrs, field.Invalid(fldPath.Child("value"), *path.Value,
fmt.Sprintf("must only contain valid characters (matching %s)", validPathCharacters)))
Expand Down Expand Up @@ -321,14 +321,14 @@ func validateHTTPHeaderModifier(filter gatewayv1b1.HTTPHeaderFilter, path *field
singleAction[strings.ToLower(string(action.Name))] = true
}
}
for i, action := range filter.Remove {
if needsErr, ok := singleAction[strings.ToLower(action)]; ok {
for i, name := range filter.Remove {
if needsErr, ok := singleAction[strings.ToLower(name)]; ok {
if needsErr {
errs = append(errs, field.Invalid(path.Child("remove"), filter.Remove[i], "cannot specify multiple actions for header"))
}
singleAction[strings.ToLower(action)] = false
singleAction[strings.ToLower(name)] = false
} else {
singleAction[strings.ToLower(action)] = true
singleAction[strings.ToLower(name)] = true
}
}
return errs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ spec:
rules:
- matches:
- method:
- path: ../
- method: ../
backendRefs:
- name: bar-svc
port: 50051
16 changes: 16 additions & 0 deletions hack/invalid-examples/v1alpha2/grpcroute/invalid-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: gateway.networking.k8s.io/v1alpha2
kind: GRPCRoute
metadata:
name: invalid-method
spec:
parentRefs:
- name: example-gateway
hostnames:
- "bar.example.com"
rules:
- matches:
- method:
- service: ../
backendRefs:
- name: bar-svc
port: 50051

0 comments on commit 34f00f8

Please sign in to comment.