1
0
Fork 0

Move dynamic config into a dedicated package.

This commit is contained in:
Ludovic Fernandez 2019-07-10 09:26:04 +02:00 committed by Traefiker Bot
parent 09cc1161c9
commit c8bf8e896a
102 changed files with 3170 additions and 3166 deletions

View file

@ -4,7 +4,7 @@ import (
"context"
"testing"
"github.com/containous/traefik/pkg/config"
"github.com/containous/traefik/pkg/config/dynamic"
"github.com/containous/traefik/pkg/server/internal"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@ -14,7 +14,7 @@ func TestManager_BuildTCP(t *testing.T) {
testCases := []struct {
desc string
serviceName string
configs map[string]*config.TCPServiceInfo
configs map[string]*dynamic.TCPServiceInfo
providerName string
expectedError string
}{
@ -27,9 +27,9 @@ func TestManager_BuildTCP(t *testing.T) {
{
desc: "missing lb configuration",
serviceName: "test",
configs: map[string]*config.TCPServiceInfo{
configs: map[string]*dynamic.TCPServiceInfo{
"test": {
TCPService: &config.TCPService{},
TCPService: &dynamic.TCPService{},
},
},
expectedError: `the service "test" doesn't have any TCP load balancer`,
@ -37,11 +37,11 @@ func TestManager_BuildTCP(t *testing.T) {
{
desc: "no such host, server is skipped, error is logged",
serviceName: "test",
configs: map[string]*config.TCPServiceInfo{
configs: map[string]*dynamic.TCPServiceInfo{
"test": {
TCPService: &config.TCPService{
LoadBalancer: &config.TCPLoadBalancerService{
Servers: []config.TCPServer{
TCPService: &dynamic.TCPService{
LoadBalancer: &dynamic.TCPLoadBalancerService{
Servers: []dynamic.TCPServer{
{Address: "test:31"},
},
},
@ -52,11 +52,11 @@ func TestManager_BuildTCP(t *testing.T) {
{
desc: "invalid IP address, server is skipped, error is logged",
serviceName: "test",
configs: map[string]*config.TCPServiceInfo{
configs: map[string]*dynamic.TCPServiceInfo{
"test": {
TCPService: &config.TCPService{
LoadBalancer: &config.TCPLoadBalancerService{
Servers: []config.TCPServer{
TCPService: &dynamic.TCPService{
LoadBalancer: &dynamic.TCPLoadBalancerService{
Servers: []dynamic.TCPServer{
{Address: "foobar"},
},
},
@ -67,10 +67,10 @@ func TestManager_BuildTCP(t *testing.T) {
{
desc: "Simple service name",
serviceName: "serviceName",
configs: map[string]*config.TCPServiceInfo{
configs: map[string]*dynamic.TCPServiceInfo{
"serviceName": {
TCPService: &config.TCPService{
LoadBalancer: &config.TCPLoadBalancerService{},
TCPService: &dynamic.TCPService{
LoadBalancer: &dynamic.TCPLoadBalancerService{},
},
},
},
@ -78,10 +78,10 @@ func TestManager_BuildTCP(t *testing.T) {
{
desc: "Service name with provider",
serviceName: "serviceName@provider-1",
configs: map[string]*config.TCPServiceInfo{
configs: map[string]*dynamic.TCPServiceInfo{
"serviceName@provider-1": {
TCPService: &config.TCPService{
LoadBalancer: &config.TCPLoadBalancerService{},
TCPService: &dynamic.TCPService{
LoadBalancer: &dynamic.TCPLoadBalancerService{},
},
},
},
@ -89,10 +89,10 @@ func TestManager_BuildTCP(t *testing.T) {
{
desc: "Service name with provider in context",
serviceName: "serviceName",
configs: map[string]*config.TCPServiceInfo{
configs: map[string]*dynamic.TCPServiceInfo{
"serviceName@provider-1": {
TCPService: &config.TCPService{
LoadBalancer: &config.TCPLoadBalancerService{},
TCPService: &dynamic.TCPService{
LoadBalancer: &dynamic.TCPLoadBalancerService{},
},
},
},
@ -101,11 +101,11 @@ func TestManager_BuildTCP(t *testing.T) {
{
desc: "Server with correct host:port as address",
serviceName: "serviceName",
configs: map[string]*config.TCPServiceInfo{
configs: map[string]*dynamic.TCPServiceInfo{
"serviceName@provider-1": {
TCPService: &config.TCPService{
LoadBalancer: &config.TCPLoadBalancerService{
Servers: []config.TCPServer{
TCPService: &dynamic.TCPService{
LoadBalancer: &dynamic.TCPLoadBalancerService{
Servers: []dynamic.TCPServer{
{
Address: "foobar.com:80",
},
@ -119,11 +119,11 @@ func TestManager_BuildTCP(t *testing.T) {
{
desc: "Server with correct ip:port as address",
serviceName: "serviceName",
configs: map[string]*config.TCPServiceInfo{
configs: map[string]*dynamic.TCPServiceInfo{
"serviceName@provider-1": {
TCPService: &config.TCPService{
LoadBalancer: &config.TCPLoadBalancerService{
Servers: []config.TCPServer{
TCPService: &dynamic.TCPService{
LoadBalancer: &dynamic.TCPLoadBalancerService{
Servers: []dynamic.TCPServer{
{
Address: "192.168.0.12:80",
},
@ -137,11 +137,11 @@ func TestManager_BuildTCP(t *testing.T) {
{
desc: "missing port in address with hostname, server is skipped, error is logged",
serviceName: "serviceName",
configs: map[string]*config.TCPServiceInfo{
configs: map[string]*dynamic.TCPServiceInfo{
"serviceName@provider-1": {
TCPService: &config.TCPService{
LoadBalancer: &config.TCPLoadBalancerService{
Servers: []config.TCPServer{
TCPService: &dynamic.TCPService{
LoadBalancer: &dynamic.TCPLoadBalancerService{
Servers: []dynamic.TCPServer{
{
Address: "foobar.com",
},
@ -155,11 +155,11 @@ func TestManager_BuildTCP(t *testing.T) {
{
desc: "missing port in address with ip, server is skipped, error is logged",
serviceName: "serviceName",
configs: map[string]*config.TCPServiceInfo{
configs: map[string]*dynamic.TCPServiceInfo{
"serviceName@provider-1": {
TCPService: &config.TCPService{
LoadBalancer: &config.TCPLoadBalancerService{
Servers: []config.TCPServer{
TCPService: &dynamic.TCPService{
LoadBalancer: &dynamic.TCPLoadBalancerService{
Servers: []dynamic.TCPServer{
{
Address: "192.168.0.12",
},
@ -177,7 +177,7 @@ func TestManager_BuildTCP(t *testing.T) {
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
manager := NewManager(&config.RuntimeConfiguration{
manager := NewManager(&dynamic.RuntimeConfiguration{
TCPServices: test.configs,
})