-
Notifications
You must be signed in to change notification settings - Fork 480
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
Adding QueryParam matching to HTTPRoute #631
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -270,6 +270,23 @@ const ( | |||||||||
HeaderMatchImplementationSpecific HeaderMatchType = "ImplementationSpecific" | ||||||||||
) | ||||||||||
|
||||||||||
// QueryParamMatchType specifies the semantics of how HTTP query parameter | ||||||||||
// values should be compared. Valid QueryParamMatchType values are: | ||||||||||
// | ||||||||||
// * "Exact" | ||||||||||
// * "RegularExpression" | ||||||||||
// * "ImplementationSpecific" | ||||||||||
// | ||||||||||
// +kubebuilder:validation:Enum=Exact;RegularExpression;ImplementationSpecific | ||||||||||
type QueryParamMatchType string | ||||||||||
|
||||||||||
// QueryParamMatchType constants. | ||||||||||
const ( | ||||||||||
QueryParamMatchExact QueryParamMatchType = "Exact" | ||||||||||
QueryParamMatchRegularExpression QueryParamMatchType = "RegularExpression" | ||||||||||
QueryParamMatchImplementationSpecific QueryParamMatchType = "ImplementationSpecific" | ||||||||||
) | ||||||||||
|
||||||||||
// HTTPPathMatch describes how to select a HTTP route by matching the HTTP request path. | ||||||||||
type HTTPPathMatch struct { | ||||||||||
// Type specifies how to match against the path Value. | ||||||||||
|
@@ -326,6 +343,38 @@ type HTTPHeaderMatch struct { | |||||||||
Values map[string]string `json:"values"` | ||||||||||
} | ||||||||||
|
||||||||||
// HTTPQueryParamMatch describes how to select a HTTP route by matching HTTP | ||||||||||
// query parameters. | ||||||||||
type HTTPQueryParamMatch struct { | ||||||||||
// Type specifies how to match against the value of the query parameter. | ||||||||||
// | ||||||||||
// Support: Extended (Exact) | ||||||||||
// | ||||||||||
// Support: Custom (RegularExpression, ImplementationSpecific) | ||||||||||
// | ||||||||||
// Since RegularExpression QueryParamMatchType has custom conformance, | ||||||||||
// implementations can support POSIX, PCRE or any other dialects of regular | ||||||||||
// expressions. Please read the implementation's documentation to determine | ||||||||||
// the supported dialect. | ||||||||||
// | ||||||||||
// HTTP query parameter matching MUST be case-sensitive for both keys and | ||||||||||
// values. | ||||||||||
// | ||||||||||
// +optional | ||||||||||
// +kubebuilder:default=Exact | ||||||||||
Type *QueryParamMatchType `json:"type,omitempty"` | ||||||||||
|
||||||||||
// Values is a map of HTTP query parameters to be matched. It MUST contain | ||||||||||
// at least one entry. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: If this must contain at least one entry, should we set the validation minimum? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately it does not look like it's possible to validate that with annotations. It does seem like something we should catch with the webhook though (for both this and header matching). |
||||||||||
// | ||||||||||
// The query parameter name to match is the map key, and the value of the | ||||||||||
// query parameter is the map value. | ||||||||||
// | ||||||||||
// Multiple match values are ANDed together, meaning, a request must match | ||||||||||
// all the specified query parameters to select the route. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: I feel like we should be clear that, even if you specify one of the ImplementationSpecific matches, we shouldn't allow regexes or other craziness in the query param name, just the value? Something like:
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More direct would be (don't refer to param matching type to avoid indirection):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good call, added in #636 |
||||||||||
Values map[string]string `json:"values"` | ||||||||||
} | ||||||||||
|
||||||||||
// HTTPRouteMatch defines the predicate used to match requests to a given | ||||||||||
// action. Multiple match types are ANDed together, i.e. the match will | ||||||||||
// evaluate to true only if all conditions are satisfied. | ||||||||||
|
@@ -354,6 +403,11 @@ type HTTPRouteMatch struct { | |||||||||
// +optional | ||||||||||
Headers *HTTPHeaderMatch `json:"headers,omitempty"` | ||||||||||
|
||||||||||
// QueryParams specifies a HTTP query parameter matcher. | ||||||||||
// | ||||||||||
// +optional | ||||||||||
QueryParams *HTTPQueryParamMatch `json:"queryParams,omitempty"` | ||||||||||
|
||||||||||
// ExtensionRef is an optional, implementation-specific extension to the | ||||||||||
// "match" behavior. For example, resource "myroutematcher" in group | ||||||||||
// "networking.acme.io". If the referent cannot be found, the rule is not | ||||||||||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
These need godoc comments for the generated API reference.