From 2d76932875ff3be916c7ce838307fcc835ddc8dc Mon Sep 17 00:00:00 2001 From: James Peach Date: Thu, 16 Sep 2021 09:10:29 +1000 Subject: [PATCH] Align path prefix matching with Ingress. Explicitly align path prefix matching with the Ingress API by specifying it as an prefix of path elements, not a prefix of bytes. Signed-off-by: James Peach --- apis/v1alpha2/httproute_types.go | 34 ++++++++++++------- .../gateway.networking.k8s.io_httproutes.yaml | 7 +--- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/apis/v1alpha2/httproute_types.go b/apis/v1alpha2/httproute_types.go index 357ba47e06..67d72cf597 100644 --- a/apis/v1alpha2/httproute_types.go +++ b/apis/v1alpha2/httproute_types.go @@ -214,18 +214,33 @@ type HTTPRouteRule struct { // // Prefix and Exact paths must be syntactically valid: // -// - Must begin with the '/' character -// - Must not contain consecutive '/' characters (e.g. /foo///, //). -// - For prefix paths, a trailing '/' character in the Path is ignored, -// e.g. /abc and /abc/ specify the same match. +// - Must begin with the `/` character +// - Must not contain consecutive `/` characters (e.g. `/foo///`, `//`). // // +kubebuilder:validation:Enum=Exact;Prefix;RegularExpression type PathMatchType string -// PathMatchType constants. const ( - PathMatchExact PathMatchType = "Exact" - PathMatchPrefix PathMatchType = "Prefix" + // Matches based on a URL path prefix split by `/`. Matching is + // case sensitive and done on a path element by element basis. A + // path element refers to the list of labels in the path split by + // the `/` separator. A request is a match for path _p_ if every + // _p_ is an element-wise prefix of the request path. + // + // For example, `/abc`, `/abc/` and `/abc/def` match the prefix + // `/abc`, but `/abcd` does not. + PathMatchExact PathMatchType = "Exact" + + // Matches the URL path exactly and with case sensitivity. + PathMatchPrefix PathMatchType = "Prefix" + + // Matches if the URL path matches the given regular expression with + // case sensitivity. + // + // Since `"RegularExpression"` has custom conformance, implementations + // can support POSIX, PCRE, RE2 or any other regular expression dialect. + // Please read the implementation's documentation to determine the supported + // dialect. PathMatchRegularExpression PathMatchType = "RegularExpression" ) @@ -237,11 +252,6 @@ type HTTPPathMatch struct { // // Support: Custom (RegularExpression) // - // Since RegularExpression PathType 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. - // // +optional // +kubebuilder:default=Prefix Type *PathMatchType `json:"type,omitempty"` diff --git a/config/crd/v1alpha2/gateway.networking.k8s.io_httproutes.yaml b/config/crd/v1alpha2/gateway.networking.k8s.io_httproutes.yaml index 53833551e2..e3db4a96a8 100644 --- a/config/crd/v1alpha2/gateway.networking.k8s.io_httproutes.yaml +++ b/config/crd/v1alpha2/gateway.networking.k8s.io_httproutes.yaml @@ -1020,12 +1020,7 @@ spec: default: Prefix description: "Type specifies how to match against the path Value. \n Support: Core (Exact, Prefix) - \n Support: Custom (RegularExpression) \n Since - RegularExpression PathType 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." + \n Support: Custom (RegularExpression)" enum: - Exact - Prefix