Move dynamic config into a dedicated package.
This commit is contained in:
parent
09cc1161c9
commit
c8bf8e896a
102 changed files with 3170 additions and 3166 deletions
|
@ -8,7 +8,7 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/containous/traefik/pkg/config"
|
||||
"github.com/containous/traefik/pkg/config/dynamic"
|
||||
"github.com/containous/traefik/pkg/provider"
|
||||
"github.com/containous/traefik/pkg/tls"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
@ -23,36 +23,36 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
testCases := []struct {
|
||||
desc string
|
||||
ingressClass string
|
||||
expected *config.Configuration
|
||||
expected *dynamic.Configuration
|
||||
}{
|
||||
{
|
||||
desc: "Empty ingresses",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Routers: map[string]*config.Router{},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Services: map[string]*config.Service{},
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Routers: map[string]*dynamic.Router{},
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Services: map[string]*dynamic.Service{},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "Ingress with a basic rule on one path",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"/bar": {
|
||||
Rule: "PathPrefix(`/bar`)",
|
||||
Service: "testing/service1/80",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/service1/80": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8080",
|
||||
},
|
||||
|
@ -68,11 +68,11 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Ingress with two different rules with one path",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"/bar": {
|
||||
Rule: "PathPrefix(`/bar`)",
|
||||
Service: "testing/service1/80",
|
||||
|
@ -82,11 +82,11 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Service: "testing/service1/80",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/service1/80": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8080",
|
||||
},
|
||||
|
@ -102,11 +102,11 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Ingress one rule with two paths",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"/bar": {
|
||||
Rule: "PathPrefix(`/bar`)",
|
||||
Service: "testing/service1/80",
|
||||
|
@ -116,11 +116,11 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Service: "testing/service1/80",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/service1/80": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8080",
|
||||
},
|
||||
|
@ -136,21 +136,21 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Ingress one rule with one path and one host",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"traefik-tchouk/bar": {
|
||||
Rule: "Host(`traefik.tchouk`) && PathPrefix(`/bar`)",
|
||||
Service: "testing/service1/80",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/service1/80": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8080",
|
||||
},
|
||||
|
@ -165,21 +165,21 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
}, {
|
||||
desc: "Ingress with one host without path",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"example-com": {
|
||||
Rule: "Host(`example.com`)",
|
||||
Service: "testing/example-com/80",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/example-com/80": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.11.0.1:80",
|
||||
},
|
||||
|
@ -192,11 +192,11 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Ingress one rule with one host and two paths",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"traefik-tchouk/bar": {
|
||||
Rule: "Host(`traefik.tchouk`) && PathPrefix(`/bar`)",
|
||||
Service: "testing/service1/80",
|
||||
|
@ -206,11 +206,11 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Service: "testing/service1/80",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/service1/80": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8080",
|
||||
},
|
||||
|
@ -226,11 +226,11 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Ingress Two rules with one host and one path",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"traefik-tchouk/bar": {
|
||||
Rule: "Host(`traefik.tchouk`) && PathPrefix(`/bar`)",
|
||||
Service: "testing/service1/80",
|
||||
|
@ -240,11 +240,11 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Service: "testing/service1/80",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/service1/80": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8080",
|
||||
},
|
||||
|
@ -260,11 +260,11 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Ingress with a bad path syntax",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"/bar": {
|
||||
Rule: "PathPrefix(`/bar`)",
|
||||
Service: "testing/service1/80",
|
||||
|
@ -274,11 +274,11 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Service: "testing/service1/80",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/service1/80": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8080",
|
||||
},
|
||||
|
@ -294,32 +294,32 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Ingress with only a bad path syntax",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{},
|
||||
Services: map[string]*config.Service{},
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{},
|
||||
Services: map[string]*dynamic.Service{},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "Ingress with a bad host syntax",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"traefik-courgette/carotte": {
|
||||
Rule: "Host(`traefik.courgette`) && PathPrefix(`/carotte`)",
|
||||
Service: "testing/service1/80",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/service1/80": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8080",
|
||||
},
|
||||
|
@ -335,22 +335,22 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Ingress with only a bad host syntax",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{},
|
||||
Services: map[string]*config.Service{},
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{},
|
||||
Services: map[string]*dynamic.Service{},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "Ingress with two services",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"traefik-tchouk/bar": {
|
||||
Rule: "Host(`traefik.tchouk`) && PathPrefix(`/bar`)",
|
||||
Service: "testing/service1/80",
|
||||
|
@ -360,11 +360,11 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Service: "testing/service2/8082",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/service1/80": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8080",
|
||||
},
|
||||
|
@ -375,9 +375,9 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
},
|
||||
"testing/service2/8082": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.2:8080",
|
||||
},
|
||||
|
@ -393,44 +393,44 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Ingress with one service without endpoints subset",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{},
|
||||
Services: map[string]*config.Service{},
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{},
|
||||
Services: map[string]*dynamic.Service{},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "Ingress with one service without endpoint",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{},
|
||||
Services: map[string]*config.Service{},
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{},
|
||||
Services: map[string]*dynamic.Service{},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "Single Service Ingress (without any rules)",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"/": {
|
||||
Rule: "PathPrefix(`/`)",
|
||||
Service: "default-backend",
|
||||
Priority: math.MinInt32,
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"default-backend": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8080",
|
||||
},
|
||||
|
@ -446,21 +446,21 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Ingress with port value in backend and no pod replica",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"traefik-tchouk/bar": {
|
||||
Rule: "Host(`traefik.tchouk`) && PathPrefix(`/bar`)",
|
||||
Service: "testing/service1/80",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/service1/80": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8089",
|
||||
},
|
||||
|
@ -476,21 +476,21 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Ingress with port name in backend and no pod replica",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"traefik-tchouk/bar": {
|
||||
Rule: "Host(`traefik.tchouk`) && PathPrefix(`/bar`)",
|
||||
Service: "testing/service1/tchouk",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/service1/tchouk": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8089",
|
||||
},
|
||||
|
@ -506,21 +506,21 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Ingress with with port name in backend and 2 pod replica",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"traefik-tchouk/bar": {
|
||||
Rule: "Host(`traefik.tchouk`) && PathPrefix(`/bar`)",
|
||||
Service: "testing/service1/tchouk",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/service1/tchouk": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8089",
|
||||
},
|
||||
|
@ -536,11 +536,11 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Ingress with two paths using same service and different port name",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"traefik-tchouk/bar": {
|
||||
Rule: "Host(`traefik.tchouk`) && PathPrefix(`/bar`)",
|
||||
Service: "testing/service1/tchouk",
|
||||
|
@ -550,11 +550,11 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Service: "testing/service1/carotte",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/service1/tchouk": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8089",
|
||||
},
|
||||
|
@ -565,9 +565,9 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
},
|
||||
"testing/service1/carotte": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8090",
|
||||
},
|
||||
|
@ -583,11 +583,11 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "2 ingresses in different namespace with same service name",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"traefik-tchouk/bar": {
|
||||
Rule: "Host(`traefik.tchouk`) && PathPrefix(`/bar`)",
|
||||
Service: "testing/service1/tchouk",
|
||||
|
@ -597,11 +597,11 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Service: "toto/service1/tchouk",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/service1/tchouk": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8089",
|
||||
},
|
||||
|
@ -612,9 +612,9 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
},
|
||||
"toto/service1/tchouk": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.11.0.1:8089",
|
||||
},
|
||||
|
@ -630,43 +630,43 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Ingress with unknown service port name",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{},
|
||||
Services: map[string]*config.Service{},
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{},
|
||||
Services: map[string]*dynamic.Service{},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "Ingress with unknown service port",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{},
|
||||
Services: map[string]*config.Service{},
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{},
|
||||
Services: map[string]*dynamic.Service{},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "Ingress with service with externalName",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"traefik-tchouk/bar": {
|
||||
Rule: "Host(`traefik.tchouk`) && PathPrefix(`/bar`)",
|
||||
Service: "testing/service1/8080",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/service1/8080": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://traefik.wtf:8080",
|
||||
},
|
||||
|
@ -679,21 +679,21 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "TLS support",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"example-com": {
|
||||
Rule: "Host(`example.com`)",
|
||||
Service: "testing/example-com/80",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/example-com/80": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.11.0.1:80",
|
||||
},
|
||||
|
@ -702,7 +702,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
TLS: &config.TLSConfiguration{
|
||||
TLS: &dynamic.TLSConfiguration{
|
||||
Certificates: []*tls.CertAndStores{
|
||||
{
|
||||
Certificate: tls.Certificate{
|
||||
|
@ -716,21 +716,21 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Ingress with a basic rule on one path with https (port == 443)",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"/bar": {
|
||||
Rule: "PathPrefix(`/bar`)",
|
||||
Service: "testing/service1/443",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/service1/443": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "https://10.10.0.1:443",
|
||||
},
|
||||
|
@ -746,21 +746,21 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Ingress with a basic rule on one path with https (portname == https)",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"/bar": {
|
||||
Rule: "PathPrefix(`/bar`)",
|
||||
Service: "testing/service1/8443",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/service1/8443": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "https://10.10.0.1:8443",
|
||||
},
|
||||
|
@ -776,22 +776,22 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Ingress with a basic rule on one path with https (portname starts with https)",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
|
||||
Routers: map[string]*config.Router{
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"/bar": {
|
||||
Rule: "PathPrefix(`/bar`)",
|
||||
Service: "testing/service1/8443",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/service1/8443": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "https://10.10.0.1:8443",
|
||||
},
|
||||
|
@ -807,22 +807,22 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Double Single Service Ingress",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"/": {
|
||||
Rule: "PathPrefix(`/`)",
|
||||
Service: "default-backend",
|
||||
Priority: math.MinInt32,
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"default-backend": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.30.0.1:8080",
|
||||
},
|
||||
|
@ -838,21 +838,21 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Ingress with default traefik ingressClass",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"/bar": {
|
||||
Rule: "PathPrefix(`/bar`)",
|
||||
Service: "testing/service1/80",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"testing/service1/80": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8080",
|
||||
},
|
||||
|
@ -865,48 +865,48 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Ingress without provider traefik ingressClass and unknown annotation",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{},
|
||||
Services: map[string]*config.Service{},
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{},
|
||||
Services: map[string]*dynamic.Service{},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "Ingress with non matching provider traefik ingressClass and annotation",
|
||||
ingressClass: "tchouk",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{},
|
||||
Services: map[string]*config.Service{},
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{},
|
||||
Services: map[string]*dynamic.Service{},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "Ingress with ingressClass without annotation",
|
||||
ingressClass: "tchouk",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{},
|
||||
Services: map[string]*config.Service{},
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{},
|
||||
Services: map[string]*dynamic.Service{},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "Ingress with ingressClass without annotation",
|
||||
ingressClass: "toto",
|
||||
expected: &config.Configuration{
|
||||
TCP: &config.TCPConfiguration{},
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Routers: map[string]*config.Router{},
|
||||
Services: map[string]*config.Service{},
|
||||
expected: &dynamic.Configuration{
|
||||
TCP: &dynamic.TCPConfiguration{},
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
Routers: map[string]*dynamic.Router{},
|
||||
Services: map[string]*dynamic.Service{},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue