Skip to content

Commit

Permalink
Merge pull request #631 from robscott/query-params
Browse files Browse the repository at this point in the history
Adding QueryParam matching to HTTPRoute
  • Loading branch information
k8s-ci-robot authored Apr 27, 2021
2 parents cbbdc4c + 1f5c0fa commit 980552d
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 0 deletions.
54 changes: 54 additions & 0 deletions apis/v1alpha1/httproute_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
//
// 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.
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.
Expand Down Expand Up @@ -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
Expand Down
32 changes: 32 additions & 0 deletions apis/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions config/crd/bases/networking.x-k8s.io_httproutes.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions examples/basic-http.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ spec:
type: Exact
values:
magic: foo
queryParams:
type: Exact
values:
great: example
path:
type: Prefix
value: /some/thing
Expand Down

0 comments on commit 980552d

Please sign in to comment.