-
Notifications
You must be signed in to change notification settings - Fork 492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
httproute: add duplicate filter validation #606
httproute: add duplicate filter validation #606
Conversation
5050c35
to
d3a5b86
Compare
/cc @danehans @cmluciano |
d3a5b86
to
31afff7
Compare
31afff7
to
4de2daf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few small nits, otherwise looks good to me @hbagdi!
for _, filter := range rule.Filters { | ||
counts[filter.Type]++ | ||
} | ||
// customer filters don't have any validation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: s/customer/custom
}, | ||
Filters: []gatewayv1a1.HTTPRouteFilter{ | ||
{ | ||
Type: "RequestMirror", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Maybe use the const type here and for all the other filter types?: HTTPRouteFilterRequestMirror
4de2daf
to
0d49bd9
Compare
@stevesloka I've addressed your comments in the latest commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: hbagdi, stevesloka The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the work on this! Mostly LGTM, just a few tiny nits.
return validateHTTPRouteSpec(&route.Spec, field.NewPath("spec")) | ||
} | ||
|
||
// validateHTTPRouteSpec validates whether required fields of spec are set according to the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// validateHTTPRouteSpec validates whether required fields of spec are set according to the | |
// validateHTTPRouteSpec validates that required fields of spec are set according to the |
@@ -75,3 +75,40 @@ func validateListenerHostname(listeners []gatewayv1a1.Listener, path *field.Path | |||
} | |||
return errs | |||
} | |||
|
|||
// ValidateHTTPRoute validates route according to the Gateway API specification. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// ValidateHTTPRoute validates route according to the Gateway API specification. | |
// ValidateHTTPRoute validates HTTPRoute according to the Gateway API specification. |
counts[filter.Type]++ | ||
} | ||
// custom filters don't have any validation | ||
counts[gatewayv1a1.HTTPRouteFilterExtensionRef] = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might be better to have a specific list of filters that can or can't be repeated. Maybe declare a variable at the top of this file that lists the kinds of filters that can be repeated? Something similar to the upstream networking validation.
func stringPtr(s string) *string { | ||
return &s | ||
} | ||
|
||
func int32Ptr(i int) *int32 { | ||
result := int32(i) | ||
return &result | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we want to add a dependency here, but this is largely similar to https://github.com/kubernetes/utils/tree/master/pointer.
|
||
// ValidateHTTPRoute validates route according to the Gateway API specification. | ||
// For additional details of the HTTPRoute spec, refer to: | ||
// https://gateway-api.sigs.k8s.io/spec/#networking.x-k8s.io/v1alpha1.HTTPRoute |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// https://gateway-api.sigs.k8s.io/spec/#networking.x-k8s.io/v1alpha1.HTTPRoute | |
// https://gateway-api.sigs.k8s.io/spec/#networking.x-k8s.io/v1alpha1.HTTPRoute |
A variation of this patch first appeared in kubernetes-sigs#506. This patch is derived from kubernetes-sigs#506 and has been reworked to include it in the validation package. Co-authored-by: Christopher M. Luciano <cmluciano@isovalent.com>
0d49bd9
to
977527f
Compare
@robscott I've address all of your comments. PTAL. |
Thanks! /lgtm |
A variation of this patch first appeared in #506.
This patch is derived from #506 and has been reworked to include it in
the validation package.
What type of PR is this?
/kind feature
What this PR does / why we need it:
Introduces validation for HTTPRoute resource.
This is part of a patch series to get #506 merged in incrementally.
Which issue(s) this PR fixes:
None
Does this PR introduce a user-facing change?: