Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/3502.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
control-plane: Add `CaseInsensitive` flag to service-routers that allows paths and path prefixes to ignore URL upper and lower casing.
```
4 changes: 4 additions & 0 deletions charts/consul/templates/crd-servicerouters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ spec:
http:
description: HTTP is a set of http-specific match criteria.
properties:
caseInsensitive:
description: CaseInsensitive configures PathExact and
PathPrefix matches to ignore upper/lower casing.
type: boolean
header:
description: Header is a set of criteria that can match
on HTTP request headers. If more than one is configured
Expand Down
15 changes: 9 additions & 6 deletions control-plane/api/v1alpha1/servicerouter_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ type ServiceRouteMatch struct {
}

type ServiceRouteHTTPMatch struct {
// CaseInsensitive configures PathExact and PathPrefix matches to ignore upper/lower casing.
CaseInsensitive bool `json:"caseInsensitive,omitempty"`
// PathExact is an exact path to match on the HTTP request path.
PathExact string `json:"pathExact,omitempty"`
// PathPrefix is a path prefix to match on the HTTP request path.
Expand Down Expand Up @@ -422,12 +424,13 @@ func (in *ServiceRouteHTTPMatch) toConsul() *capi.ServiceRouteHTTPMatch {
query = append(query, q.toConsul())
}
return &capi.ServiceRouteHTTPMatch{
PathExact: in.PathExact,
PathPrefix: in.PathPrefix,
PathRegex: in.PathRegex,
Header: header,
QueryParam: query,
Methods: in.Methods,
CaseInsensitive: in.CaseInsensitive,
PathExact: in.PathExact,
PathPrefix: in.PathPrefix,
PathRegex: in.PathRegex,
Header: header,
QueryParam: query,
Methods: in.Methods,
}
}

Expand Down
28 changes: 16 additions & 12 deletions control-plane/api/v1alpha1/servicerouter_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ func TestServiceRouter_MatchesConsul(t *testing.T) {
{
Match: &ServiceRouteMatch{
HTTP: &ServiceRouteHTTPMatch{
PathExact: "pathExact",
PathPrefix: "pathPrefix",
PathRegex: "pathRegex",
CaseInsensitive: true,
PathExact: "pathExact",
PathPrefix: "pathPrefix",
PathRegex: "pathRegex",
Header: []ServiceRouteHTTPMatchHeader{
{
Name: "name",
Expand Down Expand Up @@ -131,9 +132,10 @@ func TestServiceRouter_MatchesConsul(t *testing.T) {
{
Match: &capi.ServiceRouteMatch{
HTTP: &capi.ServiceRouteHTTPMatch{
PathExact: "pathExact",
PathPrefix: "pathPrefix",
PathRegex: "pathRegex",
CaseInsensitive: true,
PathExact: "pathExact",
PathPrefix: "pathPrefix",
PathRegex: "pathRegex",
Header: []capi.ServiceRouteHTTPMatchHeader{
{
Name: "name",
Expand Down Expand Up @@ -259,9 +261,10 @@ func TestServiceRouter_ToConsul(t *testing.T) {
{
Match: &ServiceRouteMatch{
HTTP: &ServiceRouteHTTPMatch{
PathExact: "pathExact",
PathPrefix: "pathPrefix",
PathRegex: "pathRegex",
CaseInsensitive: true,
PathExact: "pathExact",
PathPrefix: "pathPrefix",
PathRegex: "pathRegex",
Header: []ServiceRouteHTTPMatchHeader{
{
Name: "name",
Expand Down Expand Up @@ -337,9 +340,10 @@ func TestServiceRouter_ToConsul(t *testing.T) {
{
Match: &capi.ServiceRouteMatch{
HTTP: &capi.ServiceRouteHTTPMatch{
PathExact: "pathExact",
PathPrefix: "pathPrefix",
PathRegex: "pathRegex",
CaseInsensitive: true,
PathExact: "pathExact",
PathPrefix: "pathPrefix",
PathRegex: "pathRegex",
Header: []capi.ServiceRouteHTTPMatchHeader{
{
Name: "name",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ spec:
http:
description: HTTP is a set of http-specific match criteria.
properties:
caseInsensitive:
description: CaseInsensitive configures PathExact and
PathPrefix matches to ignore upper/lower casing.
type: boolean
header:
description: Header is a set of criteria that can match
on HTTP request headers. If more than one is configured
Expand Down
2 changes: 1 addition & 1 deletion control-plane/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
github.com/hashicorp/consul-k8s/control-plane/cni v0.0.0-20230825213844-4ea04860c5ed
github.com/hashicorp/consul-server-connection-manager v0.1.6
github.com/hashicorp/consul/api v1.26.1
github.com/hashicorp/consul/api v1.10.1-0.20240122160221-1c7e9443cbcd
github.com/hashicorp/consul/proto-public v0.5.1
github.com/hashicorp/consul/sdk v0.15.0
github.com/hashicorp/go-bexpr v0.1.11
Expand Down
4 changes: 2 additions & 2 deletions control-plane/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ github.com/hashicorp/consul-k8s/control-plane/cni v0.0.0-20230825213844-4ea04860
github.com/hashicorp/consul-k8s/control-plane/cni v0.0.0-20230825213844-4ea04860c5ed/go.mod h1:mwODEC+VTCA1LY/m2RUG4S2c5lNRvBcsvqaMJtMLLos=
github.com/hashicorp/consul-server-connection-manager v0.1.6 h1:ktj8Fi+dRXn9hhM+FXsfEJayhzzgTqfH08Ne5M6Fmug=
github.com/hashicorp/consul-server-connection-manager v0.1.6/go.mod h1:HngMIv57MT+pqCVeRQMa1eTB5dqnyMm8uxjyv+Hn8cs=
github.com/hashicorp/consul/api v1.26.1 h1:5oSXOO5fboPZeW5SN+TdGFP/BILDgBm19OrPZ/pICIM=
github.com/hashicorp/consul/api v1.26.1/go.mod h1:B4sQTeaSO16NtynqrAdwOlahJ7IUDZM9cj2420xYL8A=
github.com/hashicorp/consul/api v1.10.1-0.20240122160221-1c7e9443cbcd h1:M98X+hMQSPtK5xpAFuSGlgh4eE2py9UNmB1S6w6/a6c=
github.com/hashicorp/consul/api v1.10.1-0.20240122160221-1c7e9443cbcd/go.mod h1:gInwZGrnWlE1Vvq6rSD5pUf6qwNa69NTLLknbdwQRUk=
github.com/hashicorp/consul/proto-public v0.5.1 h1:g4xHZ7rJ56iktDi1uThKp+IbvHrP6nveZeGVt2Qw5x0=
github.com/hashicorp/consul/proto-public v0.5.1/go.mod h1:SayEhfXS3DQDnW/vKSZXvkwDObg7XK60KTfrJcp0wrg=
github.com/hashicorp/consul/sdk v0.15.0 h1:2qK9nDrr4tiJKRoxPGhm6B7xJjLVIQqkjiab2M4aKjU=
Expand Down