mirror of
https://github.com/traefik/traefik.git
synced 2026-06-08 16:22:52 -04:00
Avoid ingress path matcher injection and backport 11d251415
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Build and Publish Documentation / Doc Process (push) Waiting to run
Build experimental image on branch / build-webui (push) Waiting to run
Build experimental image on branch / Build experimental image on branch (push) Waiting to run
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Build and Publish Documentation / Doc Process (push) Waiting to run
Build experimental image on branch / build-webui (push) Waiting to run
Build experimental image on branch / Build experimental image on branch (push) Waiting to run
This commit is contained in:
parent
4d9031bdb2
commit
f9d9b72380
8 changed files with 151 additions and 77 deletions
|
|
@ -33,7 +33,7 @@
|
|||
"web"
|
||||
],
|
||||
"service": "default-whoami-http",
|
||||
"rule": "Host(`whoami.test`) \u0026\u0026 PathPrefix(`/whoami`)",
|
||||
"rule": "Host(\"whoami.test\") \u0026\u0026 PathPrefix(\"/whoami\")",
|
||||
"status": "enabled",
|
||||
"using": [
|
||||
"web"
|
||||
|
|
|
|||
8
integration/testdata/rawdata-ingress.json
vendored
8
integration/testdata/rawdata-ingress.json
vendored
|
|
@ -33,7 +33,7 @@
|
|||
"web"
|
||||
],
|
||||
"service": "default-whoami-http",
|
||||
"rule": "Host(`whoami.test.https`) \u0026\u0026 PathPrefix(`/whoami`)",
|
||||
"rule": "Host(\"whoami.test.https\") \u0026\u0026 PathPrefix(\"/whoami\")",
|
||||
"status": "enabled",
|
||||
"using": [
|
||||
"web"
|
||||
|
|
@ -44,7 +44,7 @@
|
|||
"web"
|
||||
],
|
||||
"service": "default-whoami-http",
|
||||
"rule": "Host(`whoami.test`) \u0026\u0026 PathPrefix(`/whoami`)",
|
||||
"rule": "Host(\"whoami.test\") \u0026\u0026 PathPrefix(\"/whoami\")",
|
||||
"status": "enabled",
|
||||
"using": [
|
||||
"web"
|
||||
|
|
@ -55,7 +55,7 @@
|
|||
"web"
|
||||
],
|
||||
"service": "default-whoami-80",
|
||||
"rule": "Host(`whoami.test.drop`) \u0026\u0026 PathPrefix(`/drop`)",
|
||||
"rule": "Host(\"whoami.test.drop\") \u0026\u0026 PathPrefix(\"/drop\")",
|
||||
"status": "enabled",
|
||||
"using": [
|
||||
"web"
|
||||
|
|
@ -66,7 +66,7 @@
|
|||
"web"
|
||||
],
|
||||
"service": "default-whoami-80",
|
||||
"rule": "Host(`whoami.test.keep`) \u0026\u0026 PathPrefix(`/keep`)",
|
||||
"rule": "Host(\"whoami.test.keep\") \u0026\u0026 PathPrefix(\"/keep\")",
|
||||
"status": "enabled",
|
||||
"using": [
|
||||
"web"
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
"web"
|
||||
],
|
||||
"service": "default-whoami-80",
|
||||
"rule": "Host(`whoami.test.keep`) \u0026\u0026 PathPrefix(`/keep`)",
|
||||
"rule": "Host(\"whoami.test.keep\") \u0026\u0026 PathPrefix(\"/keep\")",
|
||||
"status": "enabled",
|
||||
"using": [
|
||||
"web"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
kind: Endpoints
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: service1
|
||||
namespace: testing
|
||||
|
||||
subsets:
|
||||
- addresses:
|
||||
- ip: 10.10.0.1
|
||||
ports:
|
||||
- port: 8080
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
kind: Ingress
|
||||
apiVersion: networking.k8s.io/v1
|
||||
metadata:
|
||||
name: ""
|
||||
namespace: testing
|
||||
annotations:
|
||||
traefik.ingress.kubernetes.io/router.pathmatcher: 'Host("injection") || PathPrefix'
|
||||
spec:
|
||||
rules:
|
||||
- http:
|
||||
paths:
|
||||
- path: /bar
|
||||
pathType: ImplementationSpecific
|
||||
backend:
|
||||
service:
|
||||
name: service1
|
||||
port:
|
||||
number: 80
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
kind: Service
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: service1
|
||||
namespace: testing
|
||||
|
||||
spec:
|
||||
ports:
|
||||
- port: 80
|
||||
clusterIP: 10.0.0.1
|
||||
|
|
@ -283,7 +283,7 @@ func (p *Provider) loadConfigurationFromIngresses(ctx context.Context, client Cl
|
|||
}
|
||||
|
||||
rt := &dynamic.Router{
|
||||
Rule: "PathPrefix(`/`)",
|
||||
Rule: `PathPrefix("/")`,
|
||||
Priority: math.MinInt32,
|
||||
Service: "default-backend",
|
||||
}
|
||||
|
|
@ -349,7 +349,14 @@ func (p *Provider) loadConfigurationFromIngresses(ctx context.Context, client Cl
|
|||
serviceName := provider.Normalize(ingress.Namespace + "-" + pa.Backend.Service.Name + "-" + portString)
|
||||
conf.HTTP.Services[serviceName] = service
|
||||
|
||||
rt := loadRouter(rule, pa, rtConfig, serviceName)
|
||||
rt, err := loadRouter(rule, pa, rtConfig, serviceName)
|
||||
if err != nil {
|
||||
log.FromContext(ctxIngress).
|
||||
WithField("serviceName", pa.Backend.Service.Name).
|
||||
WithField("path", pa.Path).
|
||||
Errorf("Skipping path: %s", err)
|
||||
continue
|
||||
}
|
||||
|
||||
p.applyRouterTransform(ctxIngress, rt, ingress)
|
||||
|
||||
|
|
@ -447,10 +454,10 @@ func (p *Provider) shouldProcessIngress(ingress *netv1.Ingress, ingressClasses [
|
|||
|
||||
func buildHostRule(host string) string {
|
||||
if strings.HasPrefix(host, "*.") {
|
||||
return "HostRegexp(`" + strings.Replace(host, "*.", "{subdomain:[a-zA-Z0-9-]+}.", 1) + "`)"
|
||||
return fmt.Sprintf("HostRegexp(%q)", strings.Replace(host, "*.", "{subdomain:[a-zA-Z0-9-]+}.", 1))
|
||||
}
|
||||
|
||||
return "Host(`" + host + "`)"
|
||||
return fmt.Sprintf("Host(%q)", host)
|
||||
}
|
||||
|
||||
func getCertificates(ctx context.Context, ingress *netv1.Ingress, k8sClient Client, tlsConfigs map[string]*tls.CertAndStores) error {
|
||||
|
|
@ -693,7 +700,7 @@ func makeRouterKeyWithHash(key, rule string) (string, error) {
|
|||
return dupKey, nil
|
||||
}
|
||||
|
||||
func loadRouter(rule netv1.IngressRule, pa netv1.HTTPIngressPath, rtConfig *RouterConfig, serviceName string) *dynamic.Router {
|
||||
func loadRouter(rule netv1.IngressRule, pa netv1.HTTPIngressPath, rtConfig *RouterConfig, serviceName string) (*dynamic.Router, error) {
|
||||
var rules []string
|
||||
if len(rule.Host) > 0 {
|
||||
rules = []string{buildHostRule(rule.Host)}
|
||||
|
|
@ -704,13 +711,19 @@ func loadRouter(rule netv1.IngressRule, pa netv1.HTTPIngressPath, rtConfig *Rout
|
|||
|
||||
if pa.PathType == nil || *pa.PathType == "" || *pa.PathType == netv1.PathTypeImplementationSpecific {
|
||||
if rtConfig != nil && rtConfig.Router != nil && rtConfig.Router.PathMatcher != "" {
|
||||
switch rtConfig.Router.PathMatcher {
|
||||
case "Path", "PathPrefix":
|
||||
default:
|
||||
return nil, fmt.Errorf("invalid router path matcher %q: must be one of Path, PathPrefix", rtConfig.Router.PathMatcher)
|
||||
}
|
||||
|
||||
matcher = rtConfig.Router.PathMatcher
|
||||
}
|
||||
} else if *pa.PathType == netv1.PathTypeExact {
|
||||
matcher = "Path"
|
||||
}
|
||||
|
||||
rules = append(rules, fmt.Sprintf("%s(`%s`)", matcher, pa.Path))
|
||||
rules = append(rules, fmt.Sprintf("%s(%q)", matcher, pa.Path))
|
||||
}
|
||||
|
||||
rt := &dynamic.Router{
|
||||
|
|
@ -728,7 +741,7 @@ func loadRouter(rule netv1.IngressRule, pa netv1.HTTPIngressPath, rtConfig *Rout
|
|||
}
|
||||
}
|
||||
|
||||
return rt
|
||||
return rt, nil
|
||||
}
|
||||
|
||||
func throttleEvents(ctx context.Context, throttleDuration time.Duration, pool *safe.Pool, eventsChan <-chan any) chan any {
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-bar": {
|
||||
Rule: "PathPrefix(`/bar`)",
|
||||
Rule: `PathPrefix("/bar")`,
|
||||
Service: "testing-service1-80",
|
||||
},
|
||||
},
|
||||
|
|
@ -90,7 +90,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-bar": {
|
||||
Rule: "Path(`/bar`)",
|
||||
Rule: `Path("/bar")`,
|
||||
EntryPoints: []string{"ep1", "ep2"},
|
||||
Service: "testing-service1-80",
|
||||
Middlewares: []string{"md1", "md2"},
|
||||
|
|
@ -145,11 +145,11 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-bar": {
|
||||
Rule: "PathPrefix(`/bar`)",
|
||||
Rule: `PathPrefix("/bar")`,
|
||||
Service: "testing-service1-80",
|
||||
},
|
||||
"testing-foo": {
|
||||
Rule: "PathPrefix(`/foo`)",
|
||||
Rule: `PathPrefix("/foo")`,
|
||||
Service: "testing-service1-80",
|
||||
},
|
||||
},
|
||||
|
|
@ -178,12 +178,12 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-bar-bar-3be6cfd7daba66cf2fdd": {
|
||||
Rule: "HostRegexp(`{subdomain:[a-zA-Z0-9-]+}.bar`) && PathPrefix(`/bar`)",
|
||||
"testing-bar-bar-19f852c6ac4fff6a1896": {
|
||||
Rule: `HostRegexp("{subdomain:[a-zA-Z0-9-]+}.bar") && PathPrefix("/bar")`,
|
||||
Service: "testing-service1-80",
|
||||
},
|
||||
"testing-bar-bar-636bf36c00fedaab3d44": {
|
||||
Rule: "Host(`bar`) && PathPrefix(`/bar`)",
|
||||
"testing-bar-bar-605945111a3c9f84dc65": {
|
||||
Rule: `Host("bar") && PathPrefix("/bar")`,
|
||||
Service: "testing-service1-80",
|
||||
},
|
||||
},
|
||||
|
|
@ -212,12 +212,12 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-foo-bar-d0b30949e54d6a7515ca": {
|
||||
Rule: "PathPrefix(`/foo/bar`)",
|
||||
"testing-foo-bar-207cc2245cb31ba18e29": {
|
||||
Rule: `PathPrefix("/foo-bar")`,
|
||||
Service: "testing-service1-80",
|
||||
},
|
||||
"testing-foo-bar-dcd54bae39a6d7557f48": {
|
||||
Rule: "PathPrefix(`/foo-bar`)",
|
||||
"testing-foo-bar-930f0e8b221e60bc7ab7": {
|
||||
Rule: `PathPrefix("/foo/bar")`,
|
||||
Service: "testing-service1-80",
|
||||
},
|
||||
},
|
||||
|
|
@ -247,11 +247,11 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-bar": {
|
||||
Rule: "PathPrefix(`/bar`)",
|
||||
Rule: `PathPrefix("/bar")`,
|
||||
Service: "testing-service1-80",
|
||||
},
|
||||
"testing-foo": {
|
||||
Rule: "PathPrefix(`/foo`)",
|
||||
Rule: `PathPrefix("/foo")`,
|
||||
Service: "testing-service1-80",
|
||||
},
|
||||
},
|
||||
|
|
@ -281,7 +281,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-traefik-tchouk-bar": {
|
||||
Rule: "Host(`traefik.tchouk`) && PathPrefix(`/bar`)",
|
||||
Rule: `Host("traefik.tchouk") && PathPrefix("/bar")`,
|
||||
Service: "testing-service1-80",
|
||||
},
|
||||
},
|
||||
|
|
@ -311,7 +311,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-example-com": {
|
||||
Rule: "Host(`example.com`)",
|
||||
Rule: `Host("example.com")`,
|
||||
Service: "testing-example-com-80",
|
||||
},
|
||||
},
|
||||
|
|
@ -338,11 +338,11 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-traefik-tchouk-bar": {
|
||||
Rule: "Host(`traefik.tchouk`) && PathPrefix(`/bar`)",
|
||||
Rule: `Host("traefik.tchouk") && PathPrefix("/bar")`,
|
||||
Service: "testing-service1-80",
|
||||
},
|
||||
"testing-traefik-tchouk-foo": {
|
||||
Rule: "Host(`traefik.tchouk`) && PathPrefix(`/foo`)",
|
||||
Rule: `Host("traefik.tchouk") && PathPrefix("/foo")`,
|
||||
Service: "testing-service1-80",
|
||||
},
|
||||
},
|
||||
|
|
@ -372,11 +372,11 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-traefik-tchouk-bar": {
|
||||
Rule: "Host(`traefik.tchouk`) && PathPrefix(`/bar`)",
|
||||
Rule: `Host("traefik.tchouk") && PathPrefix("/bar")`,
|
||||
Service: "testing-service1-80",
|
||||
},
|
||||
"testing-traefik-courgette-carotte": {
|
||||
Rule: "Host(`traefik.courgette`) && PathPrefix(`/carotte`)",
|
||||
Rule: `Host("traefik.courgette") && PathPrefix("/carotte")`,
|
||||
Service: "testing-service1-80",
|
||||
},
|
||||
},
|
||||
|
|
@ -406,11 +406,11 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-traefik-tchouk-bar": {
|
||||
Rule: "Host(`traefik.tchouk`) && PathPrefix(`/bar`)",
|
||||
Rule: `Host("traefik.tchouk") && PathPrefix("/bar")`,
|
||||
Service: "testing-service1-80",
|
||||
},
|
||||
"testing-traefik-courgette-carotte": {
|
||||
Rule: "Host(`traefik.courgette`) && PathPrefix(`/carotte`)",
|
||||
Rule: `Host("traefik.courgette") && PathPrefix("/carotte")`,
|
||||
Service: "testing-service2-8082",
|
||||
},
|
||||
},
|
||||
|
|
@ -454,7 +454,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-traefik-tchouk-bar": {
|
||||
Rule: "Host(`traefik.tchouk`) && PathPrefix(`/bar`)",
|
||||
Rule: `Host("traefik.tchouk") && PathPrefix("/bar")`,
|
||||
Service: "testing-service1-80",
|
||||
},
|
||||
},
|
||||
|
|
@ -511,7 +511,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"default-router": {
|
||||
Rule: "PathPrefix(`/`)",
|
||||
Rule: `PathPrefix("/")`,
|
||||
Service: "default-backend",
|
||||
Priority: math.MinInt32,
|
||||
},
|
||||
|
|
@ -542,7 +542,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-traefik-tchouk-bar": {
|
||||
Rule: "Host(`traefik.tchouk`) && PathPrefix(`/bar`)",
|
||||
Rule: `Host("traefik.tchouk") && PathPrefix("/bar")`,
|
||||
Service: "testing-service1-80",
|
||||
},
|
||||
},
|
||||
|
|
@ -572,7 +572,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-traefik-tchouk-bar": {
|
||||
Rule: "Host(`traefik.tchouk`) && PathPrefix(`/bar`)",
|
||||
Rule: `Host("traefik.tchouk") && PathPrefix("/bar")`,
|
||||
Service: "testing-service1-tchouk",
|
||||
},
|
||||
},
|
||||
|
|
@ -602,7 +602,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-traefik-tchouk-bar": {
|
||||
Rule: "Host(`traefik.tchouk`) && PathPrefix(`/bar`)",
|
||||
Rule: `Host("traefik.tchouk") && PathPrefix("/bar")`,
|
||||
Service: "testing-service1-tchouk",
|
||||
},
|
||||
},
|
||||
|
|
@ -632,11 +632,11 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-traefik-tchouk-bar": {
|
||||
Rule: "Host(`traefik.tchouk`) && PathPrefix(`/bar`)",
|
||||
Rule: `Host("traefik.tchouk") && PathPrefix("/bar")`,
|
||||
Service: "testing-service1-tchouk",
|
||||
},
|
||||
"testing-traefik-tchouk-foo": {
|
||||
Rule: "Host(`traefik.tchouk`) && PathPrefix(`/foo`)",
|
||||
Rule: `Host("traefik.tchouk") && PathPrefix("/foo")`,
|
||||
Service: "testing-service1-carotte",
|
||||
},
|
||||
},
|
||||
|
|
@ -679,7 +679,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-traefik-tchouk-bar": {
|
||||
Rule: "Host(`traefik.tchouk`) && PathPrefix(`/bar`)",
|
||||
Rule: `Host("traefik.tchouk") && PathPrefix("/bar")`,
|
||||
Service: "testing-service1-tchouk",
|
||||
},
|
||||
},
|
||||
|
|
@ -709,11 +709,11 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-traefik-tchouk-bar": {
|
||||
Rule: "Host(`traefik.tchouk`) && PathPrefix(`/bar`)",
|
||||
Rule: `Host("traefik.tchouk") && PathPrefix("/bar")`,
|
||||
Service: "testing-service1-tchouk",
|
||||
},
|
||||
"toto-toto-traefik-tchouk-bar": {
|
||||
Rule: "Host(`toto.traefik.tchouk`) && PathPrefix(`/bar`)",
|
||||
Rule: `Host("toto.traefik.tchouk") && PathPrefix("/bar")`,
|
||||
Service: "toto-service1-tchouk",
|
||||
},
|
||||
},
|
||||
|
|
@ -778,7 +778,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-traefik-port-port": {
|
||||
Rule: "Host(`traefik.port`) && PathPrefix(`/port`)",
|
||||
Rule: `Host("traefik.port") && PathPrefix("/port")`,
|
||||
Service: "testing-service1-8080",
|
||||
},
|
||||
},
|
||||
|
|
@ -805,7 +805,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-example-com": {
|
||||
Rule: "Host(`example.com`)",
|
||||
Rule: `Host("example.com")`,
|
||||
Service: "testing-example-com-80",
|
||||
TLS: &dynamic.RouterTLSConfig{},
|
||||
},
|
||||
|
|
@ -843,7 +843,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-bar": {
|
||||
Rule: "PathPrefix(`/bar`)",
|
||||
Rule: `PathPrefix("/bar")`,
|
||||
Service: "testing-service1-443",
|
||||
},
|
||||
},
|
||||
|
|
@ -873,7 +873,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-bar": {
|
||||
Rule: "PathPrefix(`/bar`)",
|
||||
Rule: `PathPrefix("/bar")`,
|
||||
Service: "testing-service1-8443",
|
||||
},
|
||||
},
|
||||
|
|
@ -904,7 +904,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-bar": {
|
||||
Rule: "PathPrefix(`/bar`)",
|
||||
Rule: `PathPrefix("/bar")`,
|
||||
Service: "testing-service1-8443",
|
||||
},
|
||||
},
|
||||
|
|
@ -934,7 +934,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"default-router": {
|
||||
Rule: "PathPrefix(`/`)",
|
||||
Rule: `PathPrefix("/")`,
|
||||
Service: "default-backend",
|
||||
Priority: math.MinInt32,
|
||||
},
|
||||
|
|
@ -965,7 +965,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-bar": {
|
||||
Rule: "PathPrefix(`/bar`)",
|
||||
Rule: `PathPrefix("/bar")`,
|
||||
Service: "testing-service1-80",
|
||||
},
|
||||
},
|
||||
|
|
@ -1039,7 +1039,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-foobar-com-bar": {
|
||||
Rule: "HostRegexp(`{subdomain:[a-zA-Z0-9-]+}.foobar.com`) && PathPrefix(`/bar`)",
|
||||
Rule: `HostRegexp("{subdomain:[a-zA-Z0-9-]+}.foobar.com") && PathPrefix("/bar")`,
|
||||
Service: "testing-service1-80",
|
||||
},
|
||||
},
|
||||
|
|
@ -1069,7 +1069,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-bar": {
|
||||
Rule: "PathPrefix(`/bar`)",
|
||||
Rule: `PathPrefix("/bar")`,
|
||||
Service: "testing-service1-80",
|
||||
},
|
||||
},
|
||||
|
|
@ -1097,11 +1097,11 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-foo": {
|
||||
Rule: "PathPrefix(`/foo`)",
|
||||
Rule: `PathPrefix("/foo")`,
|
||||
Service: "testing-service1-80",
|
||||
},
|
||||
"testing-bar": {
|
||||
Rule: "PathPrefix(`/bar`)",
|
||||
Rule: `PathPrefix("/bar")`,
|
||||
Service: "testing-service1-80",
|
||||
},
|
||||
},
|
||||
|
|
@ -1129,7 +1129,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-bar": {
|
||||
Rule: "Path(`/bar`)",
|
||||
Rule: `Path("/bar")`,
|
||||
Service: "testing-service1-80",
|
||||
},
|
||||
},
|
||||
|
|
@ -1157,7 +1157,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-bar": {
|
||||
Rule: "Path(`/bar`)",
|
||||
Rule: `Path("/bar")`,
|
||||
Service: "testing-service1-80",
|
||||
},
|
||||
},
|
||||
|
|
@ -1185,7 +1185,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-bar": {
|
||||
Rule: "Path(`/bar`)",
|
||||
Rule: `Path("/bar")`,
|
||||
Service: "testing-service1-80",
|
||||
},
|
||||
},
|
||||
|
|
@ -1213,7 +1213,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-bar": {
|
||||
Rule: "PathPrefix(`/bar`)",
|
||||
Rule: `PathPrefix("/bar")`,
|
||||
Service: "testing-service1-80",
|
||||
},
|
||||
},
|
||||
|
|
@ -1241,7 +1241,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-bar": {
|
||||
Rule: "Path(`/bar`)",
|
||||
Rule: `Path("/bar")`,
|
||||
Service: "testing-service1-80",
|
||||
},
|
||||
},
|
||||
|
|
@ -1281,7 +1281,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-bar": {
|
||||
Rule: "PathPrefix(`/bar`)",
|
||||
Rule: `PathPrefix("/bar")`,
|
||||
Service: "testing-service1-80",
|
||||
},
|
||||
},
|
||||
|
|
@ -1310,7 +1310,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-foo": {
|
||||
Rule: "PathPrefix(`/foo`)",
|
||||
Rule: `PathPrefix("/foo")`,
|
||||
Service: "testing-service1-80",
|
||||
},
|
||||
},
|
||||
|
|
@ -1338,7 +1338,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-bar": {
|
||||
Rule: "PathPrefix(`/bar`)",
|
||||
Rule: `PathPrefix("/bar")`,
|
||||
Service: "testing-service1-80",
|
||||
},
|
||||
},
|
||||
|
|
@ -1366,7 +1366,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-bar": {
|
||||
Rule: "Path(`/bar`)",
|
||||
Rule: `Path("/bar")`,
|
||||
Service: "testing-service1-80",
|
||||
},
|
||||
},
|
||||
|
|
@ -1394,7 +1394,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-bar": {
|
||||
Rule: "Path(`/bar`)",
|
||||
Rule: `Path("/bar")`,
|
||||
Service: "testing-service1-80",
|
||||
},
|
||||
},
|
||||
|
|
@ -1422,7 +1422,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-bar": {
|
||||
Rule: "Path(`/bar`)",
|
||||
Rule: `Path("/bar")`,
|
||||
Service: "testing-service1-80",
|
||||
},
|
||||
},
|
||||
|
|
@ -1450,7 +1450,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-bar": {
|
||||
Rule: "Path(`/bar`)",
|
||||
Rule: `Path("/bar")`,
|
||||
Service: "testing-service1-80",
|
||||
},
|
||||
},
|
||||
|
|
@ -1478,7 +1478,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-bar": {
|
||||
Rule: "PathPrefix(`/bar`)",
|
||||
Rule: `PathPrefix("/bar")`,
|
||||
Service: "testing-service1-80",
|
||||
},
|
||||
},
|
||||
|
|
@ -1506,7 +1506,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-bar": {
|
||||
Rule: "PathPrefix(`/bar`)",
|
||||
Rule: `PathPrefix("/bar")`,
|
||||
Service: "testing-service1-80",
|
||||
},
|
||||
},
|
||||
|
|
@ -1534,7 +1534,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-bar": {
|
||||
Rule: "PathPrefix(`/bar`)",
|
||||
Rule: `PathPrefix("/bar")`,
|
||||
Service: "testing-service1-80",
|
||||
},
|
||||
},
|
||||
|
|
@ -1562,7 +1562,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-bar": {
|
||||
Rule: "PathPrefix(`/bar`)",
|
||||
Rule: `PathPrefix("/bar")`,
|
||||
Service: "testing-service1-foobar",
|
||||
},
|
||||
},
|
||||
|
|
@ -1602,7 +1602,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"default-router": {
|
||||
Rule: "PathPrefix(`/`)",
|
||||
Rule: `PathPrefix("/")`,
|
||||
Priority: math.MinInt32,
|
||||
Service: "default-backend",
|
||||
},
|
||||
|
|
@ -1622,6 +1622,28 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "Ingress with invalid pathmatcher annotation",
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{},
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing-service1-80": {
|
||||
LoadBalancer: &dynamic.ServersLoadBalancer{
|
||||
PassHostHeader: pointer(true),
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8080",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
|
|
@ -1692,7 +1714,7 @@ func TestLoadConfigurationFromIngressesWithExternalNameServices(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-traefik-tchouk-bar": {
|
||||
Rule: "Host(`traefik.tchouk`) && PathPrefix(`/bar`)",
|
||||
Rule: `Host("traefik.tchouk") && PathPrefix("/bar")`,
|
||||
Service: "testing-service1-8080",
|
||||
},
|
||||
},
|
||||
|
|
@ -1719,7 +1741,7 @@ func TestLoadConfigurationFromIngressesWithExternalNameServices(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-example-com-bar": {
|
||||
Rule: "PathPrefix(`/bar`)",
|
||||
Rule: `PathPrefix("/bar")`,
|
||||
Service: "testing-service-bar-8080",
|
||||
},
|
||||
},
|
||||
|
|
@ -1747,7 +1769,7 @@ func TestLoadConfigurationFromIngressesWithExternalNameServices(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-example-com-foo": {
|
||||
Rule: "PathPrefix(`/foo`)",
|
||||
Rule: `PathPrefix("/foo")`,
|
||||
Service: "testing-service-foo-8080",
|
||||
},
|
||||
},
|
||||
|
|
@ -1825,7 +1847,7 @@ func TestLoadConfigurationFromIngressesWithNativeLB(t *testing.T) {
|
|||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"testing-traefik-tchouk-bar": {
|
||||
Rule: "Host(`traefik.tchouk`) && PathPrefix(`/bar`)",
|
||||
Rule: `Host("traefik.tchouk") && PathPrefix("/bar")`,
|
||||
Service: "testing-service1-8080",
|
||||
},
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue