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
|
@ -1,24 +1,24 @@
|
|||
package server
|
||||
|
||||
import (
|
||||
"github.com/containous/traefik/pkg/config"
|
||||
"github.com/containous/traefik/pkg/config/dynamic"
|
||||
"github.com/containous/traefik/pkg/log"
|
||||
"github.com/containous/traefik/pkg/server/internal"
|
||||
"github.com/containous/traefik/pkg/tls"
|
||||
)
|
||||
|
||||
func mergeConfiguration(configurations config.Configurations) config.Configuration {
|
||||
conf := config.Configuration{
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Routers: make(map[string]*config.Router),
|
||||
Middlewares: make(map[string]*config.Middleware),
|
||||
Services: make(map[string]*config.Service),
|
||||
func mergeConfiguration(configurations dynamic.Configurations) dynamic.Configuration {
|
||||
conf := dynamic.Configuration{
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Routers: make(map[string]*dynamic.Router),
|
||||
Middlewares: make(map[string]*dynamic.Middleware),
|
||||
Services: make(map[string]*dynamic.Service),
|
||||
},
|
||||
TCP: &config.TCPConfiguration{
|
||||
Routers: make(map[string]*config.TCPRouter),
|
||||
Services: make(map[string]*config.TCPService),
|
||||
TCP: &dynamic.TCPConfiguration{
|
||||
Routers: make(map[string]*dynamic.TCPRouter),
|
||||
Services: make(map[string]*dynamic.TCPService),
|
||||
},
|
||||
TLS: &config.TLSConfiguration{
|
||||
TLS: &dynamic.TLSConfiguration{
|
||||
Stores: make(map[string]tls.Store),
|
||||
Options: make(map[string]tls.Options),
|
||||
},
|
||||
|
|
|
@ -3,7 +3,7 @@ package server
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/containous/traefik/pkg/config"
|
||||
"github.com/containous/traefik/pkg/config/dynamic"
|
||||
"github.com/containous/traefik/pkg/tls"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
@ -11,87 +11,87 @@ import (
|
|||
func TestAggregator(t *testing.T) {
|
||||
testCases := []struct {
|
||||
desc string
|
||||
given config.Configurations
|
||||
expected *config.HTTPConfiguration
|
||||
given dynamic.Configurations
|
||||
expected *dynamic.HTTPConfiguration
|
||||
}{
|
||||
{
|
||||
desc: "Nil returns an empty configuration",
|
||||
given: nil,
|
||||
expected: &config.HTTPConfiguration{
|
||||
Routers: make(map[string]*config.Router),
|
||||
Middlewares: make(map[string]*config.Middleware),
|
||||
Services: make(map[string]*config.Service),
|
||||
expected: &dynamic.HTTPConfiguration{
|
||||
Routers: make(map[string]*dynamic.Router),
|
||||
Middlewares: make(map[string]*dynamic.Middleware),
|
||||
Services: make(map[string]*dynamic.Service),
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "Returns fully qualified elements from a mono-provider configuration map",
|
||||
given: config.Configurations{
|
||||
"provider-1": &config.Configuration{
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Routers: map[string]*config.Router{
|
||||
given: dynamic.Configurations{
|
||||
"provider-1": &dynamic.Configuration{
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"router-1": {},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{
|
||||
Middlewares: map[string]*dynamic.Middleware{
|
||||
"middleware-1": {},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"service-1": {},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
expected: &config.HTTPConfiguration{
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.HTTPConfiguration{
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"router-1@provider-1": {},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{
|
||||
Middlewares: map[string]*dynamic.Middleware{
|
||||
"middleware-1@provider-1": {},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"service-1@provider-1": {},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "Returns fully qualified elements from a multi-provider configuration map",
|
||||
given: config.Configurations{
|
||||
"provider-1": &config.Configuration{
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Routers: map[string]*config.Router{
|
||||
given: dynamic.Configurations{
|
||||
"provider-1": &dynamic.Configuration{
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"router-1": {},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{
|
||||
Middlewares: map[string]*dynamic.Middleware{
|
||||
"middleware-1": {},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"service-1": {},
|
||||
},
|
||||
},
|
||||
},
|
||||
"provider-2": &config.Configuration{
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
Routers: map[string]*config.Router{
|
||||
"provider-2": &dynamic.Configuration{
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"router-1": {},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{
|
||||
Middlewares: map[string]*dynamic.Middleware{
|
||||
"middleware-1": {},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"service-1": {},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
expected: &config.HTTPConfiguration{
|
||||
Routers: map[string]*config.Router{
|
||||
expected: &dynamic.HTTPConfiguration{
|
||||
Routers: map[string]*dynamic.Router{
|
||||
"router-1@provider-1": {},
|
||||
"router-1@provider-2": {},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{
|
||||
Middlewares: map[string]*dynamic.Middleware{
|
||||
"middleware-1@provider-1": {},
|
||||
"middleware-1@provider-2": {},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
Services: map[string]*dynamic.Service{
|
||||
"service-1@provider-1": {},
|
||||
"service-1@provider-2": {},
|
||||
},
|
||||
|
@ -113,7 +113,7 @@ func TestAggregator(t *testing.T) {
|
|||
func TestAggregator_tlsoptions(t *testing.T) {
|
||||
testCases := []struct {
|
||||
desc string
|
||||
given config.Configurations
|
||||
given dynamic.Configurations
|
||||
expected map[string]tls.Options
|
||||
}{
|
||||
{
|
||||
|
@ -125,9 +125,9 @@ func TestAggregator_tlsoptions(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Returns fully qualified elements from a mono-provider configuration map",
|
||||
given: config.Configurations{
|
||||
"provider-1": &config.Configuration{
|
||||
TLS: &config.TLSConfiguration{
|
||||
given: dynamic.Configurations{
|
||||
"provider-1": &dynamic.Configuration{
|
||||
TLS: &dynamic.TLSConfiguration{
|
||||
Options: map[string]tls.Options{
|
||||
"foo": {
|
||||
MinVersion: "VersionTLS12",
|
||||
|
@ -145,9 +145,9 @@ func TestAggregator_tlsoptions(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Returns fully qualified elements from a multi-provider configuration map",
|
||||
given: config.Configurations{
|
||||
"provider-1": &config.Configuration{
|
||||
TLS: &config.TLSConfiguration{
|
||||
given: dynamic.Configurations{
|
||||
"provider-1": &dynamic.Configuration{
|
||||
TLS: &dynamic.TLSConfiguration{
|
||||
Options: map[string]tls.Options{
|
||||
"foo": {
|
||||
MinVersion: "VersionTLS13",
|
||||
|
@ -155,8 +155,8 @@ func TestAggregator_tlsoptions(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
"provider-2": &config.Configuration{
|
||||
TLS: &config.TLSConfiguration{
|
||||
"provider-2": &dynamic.Configuration{
|
||||
TLS: &dynamic.TLSConfiguration{
|
||||
Options: map[string]tls.Options{
|
||||
"foo": {
|
||||
MinVersion: "VersionTLS12",
|
||||
|
@ -177,9 +177,9 @@ func TestAggregator_tlsoptions(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Create a valid default tls option when appears only in one provider",
|
||||
given: config.Configurations{
|
||||
"provider-1": &config.Configuration{
|
||||
TLS: &config.TLSConfiguration{
|
||||
given: dynamic.Configurations{
|
||||
"provider-1": &dynamic.Configuration{
|
||||
TLS: &dynamic.TLSConfiguration{
|
||||
Options: map[string]tls.Options{
|
||||
"foo": {
|
||||
MinVersion: "VersionTLS13",
|
||||
|
@ -190,8 +190,8 @@ func TestAggregator_tlsoptions(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
"provider-2": &config.Configuration{
|
||||
TLS: &config.TLSConfiguration{
|
||||
"provider-2": &dynamic.Configuration{
|
||||
TLS: &dynamic.TLSConfiguration{
|
||||
Options: map[string]tls.Options{
|
||||
"foo": {
|
||||
MinVersion: "VersionTLS12",
|
||||
|
@ -214,9 +214,9 @@ func TestAggregator_tlsoptions(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "No default tls option if it is defined in multiple providers",
|
||||
given: config.Configurations{
|
||||
"provider-1": &config.Configuration{
|
||||
TLS: &config.TLSConfiguration{
|
||||
given: dynamic.Configurations{
|
||||
"provider-1": &dynamic.Configuration{
|
||||
TLS: &dynamic.TLSConfiguration{
|
||||
Options: map[string]tls.Options{
|
||||
"foo": {
|
||||
MinVersion: "VersionTLS12",
|
||||
|
@ -227,8 +227,8 @@ func TestAggregator_tlsoptions(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
"provider-2": &config.Configuration{
|
||||
TLS: &config.TLSConfiguration{
|
||||
"provider-2": &dynamic.Configuration{
|
||||
TLS: &dynamic.TLSConfiguration{
|
||||
Options: map[string]tls.Options{
|
||||
"foo": {
|
||||
MinVersion: "VersionTLS13",
|
||||
|
@ -251,9 +251,9 @@ func TestAggregator_tlsoptions(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Create a default TLS Options configuration if none was provided",
|
||||
given: config.Configurations{
|
||||
"provider-1": &config.Configuration{
|
||||
TLS: &config.TLSConfiguration{
|
||||
given: dynamic.Configurations{
|
||||
"provider-1": &dynamic.Configuration{
|
||||
TLS: &dynamic.TLSConfiguration{
|
||||
Options: map[string]tls.Options{
|
||||
"foo": {
|
||||
MinVersion: "VersionTLS12",
|
||||
|
@ -261,8 +261,8 @@ func TestAggregator_tlsoptions(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
"provider-2": &config.Configuration{
|
||||
TLS: &config.TLSConfiguration{
|
||||
"provider-2": &dynamic.Configuration{
|
||||
TLS: &dynamic.TLSConfiguration{
|
||||
Options: map[string]tls.Options{
|
||||
"foo": {
|
||||
MinVersion: "VersionTLS13",
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/containous/alice"
|
||||
"github.com/containous/traefik/pkg/config"
|
||||
"github.com/containous/traefik/pkg/config/dynamic"
|
||||
"github.com/containous/traefik/pkg/middlewares/addprefix"
|
||||
"github.com/containous/traefik/pkg/middlewares/auth"
|
||||
"github.com/containous/traefik/pkg/middlewares/buffering"
|
||||
|
@ -39,7 +39,7 @@ const (
|
|||
|
||||
// Builder the middleware builder
|
||||
type Builder struct {
|
||||
configs map[string]*config.MiddlewareInfo
|
||||
configs map[string]*dynamic.MiddlewareInfo
|
||||
serviceBuilder serviceBuilder
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ type serviceBuilder interface {
|
|||
}
|
||||
|
||||
// NewBuilder creates a new Builder
|
||||
func NewBuilder(configs map[string]*config.MiddlewareInfo, serviceBuilder serviceBuilder) *Builder {
|
||||
func NewBuilder(configs map[string]*dynamic.MiddlewareInfo, serviceBuilder serviceBuilder) *Builder {
|
||||
return &Builder{configs: configs, serviceBuilder: serviceBuilder}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,14 +7,14 @@ import (
|
|||
"net/http/httptest"
|
||||
"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"
|
||||
)
|
||||
|
||||
func TestBuilder_BuildChainNilConfig(t *testing.T) {
|
||||
testConfig := map[string]*config.MiddlewareInfo{
|
||||
testConfig := map[string]*dynamic.MiddlewareInfo{
|
||||
"empty": {},
|
||||
}
|
||||
middlewaresBuilder := NewBuilder(testConfig, nil)
|
||||
|
@ -25,7 +25,7 @@ func TestBuilder_BuildChainNilConfig(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestBuilder_BuildChainNonExistentChain(t *testing.T) {
|
||||
testConfig := map[string]*config.MiddlewareInfo{
|
||||
testConfig := map[string]*dynamic.MiddlewareInfo{
|
||||
"foobar": {},
|
||||
}
|
||||
middlewaresBuilder := NewBuilder(testConfig, nil)
|
||||
|
@ -39,7 +39,7 @@ func TestBuilder_BuildChainWithContext(t *testing.T) {
|
|||
testCases := []struct {
|
||||
desc string
|
||||
buildChain []string
|
||||
configuration map[string]*config.Middleware
|
||||
configuration map[string]*dynamic.Middleware
|
||||
expected map[string]string
|
||||
contextProvider string
|
||||
expectedError error
|
||||
|
@ -47,9 +47,9 @@ func TestBuilder_BuildChainWithContext(t *testing.T) {
|
|||
{
|
||||
desc: "Simple middleware",
|
||||
buildChain: []string{"middleware-1"},
|
||||
configuration: map[string]*config.Middleware{
|
||||
configuration: map[string]*dynamic.Middleware{
|
||||
"middleware-1": {
|
||||
Headers: &config.Headers{
|
||||
Headers: &dynamic.Headers{
|
||||
CustomRequestHeaders: map[string]string{"middleware-1": "value-middleware-1"},
|
||||
},
|
||||
},
|
||||
|
@ -59,14 +59,14 @@ func TestBuilder_BuildChainWithContext(t *testing.T) {
|
|||
{
|
||||
desc: "Middleware that references a chain",
|
||||
buildChain: []string{"middleware-chain-1"},
|
||||
configuration: map[string]*config.Middleware{
|
||||
configuration: map[string]*dynamic.Middleware{
|
||||
"middleware-1": {
|
||||
Headers: &config.Headers{
|
||||
Headers: &dynamic.Headers{
|
||||
CustomRequestHeaders: map[string]string{"middleware-1": "value-middleware-1"},
|
||||
},
|
||||
},
|
||||
"middleware-chain-1": {
|
||||
Chain: &config.Chain{
|
||||
Chain: &dynamic.Chain{
|
||||
Middlewares: []string{"middleware-1"},
|
||||
},
|
||||
},
|
||||
|
@ -76,9 +76,9 @@ func TestBuilder_BuildChainWithContext(t *testing.T) {
|
|||
{
|
||||
desc: "Should suffix the middlewareName with the provider in the context",
|
||||
buildChain: []string{"middleware-1"},
|
||||
configuration: map[string]*config.Middleware{
|
||||
configuration: map[string]*dynamic.Middleware{
|
||||
"middleware-1@provider-1": {
|
||||
Headers: &config.Headers{
|
||||
Headers: &dynamic.Headers{
|
||||
CustomRequestHeaders: map[string]string{"middleware-1@provider-1": "value-middleware-1"},
|
||||
},
|
||||
},
|
||||
|
@ -89,9 +89,9 @@ func TestBuilder_BuildChainWithContext(t *testing.T) {
|
|||
{
|
||||
desc: "Should not suffix a qualified middlewareName with the provider in the context",
|
||||
buildChain: []string{"middleware-1@provider-1"},
|
||||
configuration: map[string]*config.Middleware{
|
||||
configuration: map[string]*dynamic.Middleware{
|
||||
"middleware-1@provider-1": {
|
||||
Headers: &config.Headers{
|
||||
Headers: &dynamic.Headers{
|
||||
CustomRequestHeaders: map[string]string{"middleware-1@provider-1": "value-middleware-1"},
|
||||
},
|
||||
},
|
||||
|
@ -102,14 +102,14 @@ func TestBuilder_BuildChainWithContext(t *testing.T) {
|
|||
{
|
||||
desc: "Should be context aware if a chain references another middleware",
|
||||
buildChain: []string{"middleware-chain-1@provider-1"},
|
||||
configuration: map[string]*config.Middleware{
|
||||
configuration: map[string]*dynamic.Middleware{
|
||||
"middleware-1@provider-1": {
|
||||
Headers: &config.Headers{
|
||||
Headers: &dynamic.Headers{
|
||||
CustomRequestHeaders: map[string]string{"middleware-1": "value-middleware-1"},
|
||||
},
|
||||
},
|
||||
"middleware-chain-1@provider-1": {
|
||||
Chain: &config.Chain{
|
||||
Chain: &dynamic.Chain{
|
||||
Middlewares: []string{"middleware-1"},
|
||||
},
|
||||
},
|
||||
|
@ -119,29 +119,29 @@ func TestBuilder_BuildChainWithContext(t *testing.T) {
|
|||
{
|
||||
desc: "Should handle nested chains with different context",
|
||||
buildChain: []string{"middleware-chain-1@provider-1", "middleware-chain-1"},
|
||||
configuration: map[string]*config.Middleware{
|
||||
configuration: map[string]*dynamic.Middleware{
|
||||
"middleware-1@provider-1": {
|
||||
Headers: &config.Headers{
|
||||
Headers: &dynamic.Headers{
|
||||
CustomRequestHeaders: map[string]string{"middleware-1": "value-middleware-1"},
|
||||
},
|
||||
},
|
||||
"middleware-2@provider-1": {
|
||||
Headers: &config.Headers{
|
||||
Headers: &dynamic.Headers{
|
||||
CustomRequestHeaders: map[string]string{"middleware-2": "value-middleware-2"},
|
||||
},
|
||||
},
|
||||
"middleware-chain-1@provider-1": {
|
||||
Chain: &config.Chain{
|
||||
Chain: &dynamic.Chain{
|
||||
Middlewares: []string{"middleware-1"},
|
||||
},
|
||||
},
|
||||
"middleware-chain-2@provider-1": {
|
||||
Chain: &config.Chain{
|
||||
Chain: &dynamic.Chain{
|
||||
Middlewares: []string{"middleware-2"},
|
||||
},
|
||||
},
|
||||
"middleware-chain-1@provider-2": {
|
||||
Chain: &config.Chain{
|
||||
Chain: &dynamic.Chain{
|
||||
Middlewares: []string{"middleware-2@provider-1", "middleware-chain-2@provider-1"},
|
||||
},
|
||||
},
|
||||
|
@ -152,22 +152,22 @@ func TestBuilder_BuildChainWithContext(t *testing.T) {
|
|||
{
|
||||
desc: "Detects recursion in Middleware chain",
|
||||
buildChain: []string{"m1"},
|
||||
configuration: map[string]*config.Middleware{
|
||||
configuration: map[string]*dynamic.Middleware{
|
||||
"ok": {
|
||||
Retry: &config.Retry{},
|
||||
Retry: &dynamic.Retry{},
|
||||
},
|
||||
"m1": {
|
||||
Chain: &config.Chain{
|
||||
Chain: &dynamic.Chain{
|
||||
Middlewares: []string{"m2"},
|
||||
},
|
||||
},
|
||||
"m2": {
|
||||
Chain: &config.Chain{
|
||||
Chain: &dynamic.Chain{
|
||||
Middlewares: []string{"ok", "m3"},
|
||||
},
|
||||
},
|
||||
"m3": {
|
||||
Chain: &config.Chain{
|
||||
Chain: &dynamic.Chain{
|
||||
Middlewares: []string{"m1"},
|
||||
},
|
||||
},
|
||||
|
@ -177,22 +177,22 @@ func TestBuilder_BuildChainWithContext(t *testing.T) {
|
|||
{
|
||||
desc: "Detects recursion in Middleware chain",
|
||||
buildChain: []string{"m1@provider"},
|
||||
configuration: map[string]*config.Middleware{
|
||||
configuration: map[string]*dynamic.Middleware{
|
||||
"ok@provider2": {
|
||||
Retry: &config.Retry{},
|
||||
Retry: &dynamic.Retry{},
|
||||
},
|
||||
"m1@provider": {
|
||||
Chain: &config.Chain{
|
||||
Chain: &dynamic.Chain{
|
||||
Middlewares: []string{"m2@provider2"},
|
||||
},
|
||||
},
|
||||
"m2@provider2": {
|
||||
Chain: &config.Chain{
|
||||
Chain: &dynamic.Chain{
|
||||
Middlewares: []string{"ok", "m3@provider"},
|
||||
},
|
||||
},
|
||||
"m3@provider": {
|
||||
Chain: &config.Chain{
|
||||
Chain: &dynamic.Chain{
|
||||
Middlewares: []string{"m1"},
|
||||
},
|
||||
},
|
||||
|
@ -201,12 +201,12 @@ func TestBuilder_BuildChainWithContext(t *testing.T) {
|
|||
},
|
||||
{
|
||||
buildChain: []string{"ok", "m0"},
|
||||
configuration: map[string]*config.Middleware{
|
||||
configuration: map[string]*dynamic.Middleware{
|
||||
"ok": {
|
||||
Retry: &config.Retry{},
|
||||
Retry: &dynamic.Retry{},
|
||||
},
|
||||
"m0": {
|
||||
Chain: &config.Chain{
|
||||
Chain: &dynamic.Chain{
|
||||
Middlewares: []string{"m0"},
|
||||
},
|
||||
},
|
||||
|
@ -216,24 +216,24 @@ func TestBuilder_BuildChainWithContext(t *testing.T) {
|
|||
{
|
||||
desc: "Detects MiddlewareChain that references a Chain that references a Chain with a missing middleware",
|
||||
buildChain: []string{"m0"},
|
||||
configuration: map[string]*config.Middleware{
|
||||
configuration: map[string]*dynamic.Middleware{
|
||||
"m0": {
|
||||
Chain: &config.Chain{
|
||||
Chain: &dynamic.Chain{
|
||||
Middlewares: []string{"m1"},
|
||||
},
|
||||
},
|
||||
"m1": {
|
||||
Chain: &config.Chain{
|
||||
Chain: &dynamic.Chain{
|
||||
Middlewares: []string{"m2"},
|
||||
},
|
||||
},
|
||||
"m2": {
|
||||
Chain: &config.Chain{
|
||||
Chain: &dynamic.Chain{
|
||||
Middlewares: []string{"m3"},
|
||||
},
|
||||
},
|
||||
"m3": {
|
||||
Chain: &config.Chain{
|
||||
Chain: &dynamic.Chain{
|
||||
Middlewares: []string{"m2"},
|
||||
},
|
||||
},
|
||||
|
@ -243,9 +243,9 @@ func TestBuilder_BuildChainWithContext(t *testing.T) {
|
|||
{
|
||||
desc: "--",
|
||||
buildChain: []string{"m0"},
|
||||
configuration: map[string]*config.Middleware{
|
||||
configuration: map[string]*dynamic.Middleware{
|
||||
"m0": {
|
||||
Chain: &config.Chain{
|
||||
Chain: &dynamic.Chain{
|
||||
Middlewares: []string{"m0"},
|
||||
},
|
||||
},
|
||||
|
@ -264,8 +264,8 @@ func TestBuilder_BuildChainWithContext(t *testing.T) {
|
|||
ctx = internal.AddProviderInContext(ctx, "foobar@"+test.contextProvider)
|
||||
}
|
||||
|
||||
rtConf := config.NewRuntimeConfig(config.Configuration{
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
rtConf := dynamic.NewRuntimeConfig(dynamic.Configuration{
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: test.configuration,
|
||||
},
|
||||
})
|
||||
|
@ -292,31 +292,31 @@ func TestBuilder_BuildChainWithContext(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestBuilder_buildConstructor(t *testing.T) {
|
||||
testConfig := map[string]*config.Middleware{
|
||||
testConfig := map[string]*dynamic.Middleware{
|
||||
"cb-empty": {
|
||||
CircuitBreaker: &config.CircuitBreaker{
|
||||
CircuitBreaker: &dynamic.CircuitBreaker{
|
||||
Expression: "",
|
||||
},
|
||||
},
|
||||
"cb-foo": {
|
||||
CircuitBreaker: &config.CircuitBreaker{
|
||||
CircuitBreaker: &dynamic.CircuitBreaker{
|
||||
Expression: "NetworkErrorRatio() > 0.5",
|
||||
},
|
||||
},
|
||||
"ap-empty": {
|
||||
AddPrefix: &config.AddPrefix{
|
||||
AddPrefix: &dynamic.AddPrefix{
|
||||
Prefix: "",
|
||||
},
|
||||
},
|
||||
"ap-foo": {
|
||||
AddPrefix: &config.AddPrefix{
|
||||
AddPrefix: &dynamic.AddPrefix{
|
||||
Prefix: "foo/",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
rtConf := config.NewRuntimeConfig(config.Configuration{
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
rtConf := dynamic.NewRuntimeConfig(dynamic.Configuration{
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Middlewares: testConfig,
|
||||
},
|
||||
})
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"github.com/containous/alice"
|
||||
"github.com/containous/mux"
|
||||
"github.com/containous/traefik/pkg/api"
|
||||
"github.com/containous/traefik/pkg/config"
|
||||
"github.com/containous/traefik/pkg/config/dynamic"
|
||||
"github.com/containous/traefik/pkg/config/static"
|
||||
"github.com/containous/traefik/pkg/log"
|
||||
"github.com/containous/traefik/pkg/metrics"
|
||||
|
@ -20,7 +20,7 @@ type chainBuilder interface {
|
|||
|
||||
// NewRouteAppenderAggregator Creates a new RouteAppenderAggregator
|
||||
func NewRouteAppenderAggregator(ctx context.Context, chainBuilder chainBuilder, conf static.Configuration,
|
||||
entryPointName string, runtimeConfiguration *config.RuntimeConfiguration) *RouteAppenderAggregator {
|
||||
entryPointName string, runtimeConfiguration *dynamic.RuntimeConfiguration) *RouteAppenderAggregator {
|
||||
aggregator := &RouteAppenderAggregator{}
|
||||
|
||||
if conf.Providers != nil && conf.Providers.Rest != nil {
|
||||
|
|
|
@ -3,7 +3,7 @@ package router
|
|||
import (
|
||||
"context"
|
||||
|
||||
"github.com/containous/traefik/pkg/config"
|
||||
"github.com/containous/traefik/pkg/config/dynamic"
|
||||
"github.com/containous/traefik/pkg/config/static"
|
||||
"github.com/containous/traefik/pkg/provider/acme"
|
||||
"github.com/containous/traefik/pkg/server/middleware"
|
||||
|
@ -27,7 +27,7 @@ type RouteAppenderFactory struct {
|
|||
}
|
||||
|
||||
// NewAppender Creates a new RouteAppender
|
||||
func (r *RouteAppenderFactory) NewAppender(ctx context.Context, middlewaresBuilder *middleware.Builder, runtimeConfiguration *config.RuntimeConfiguration) types.RouteAppender {
|
||||
func (r *RouteAppenderFactory) NewAppender(ctx context.Context, middlewaresBuilder *middleware.Builder, runtimeConfiguration *dynamic.RuntimeConfiguration) types.RouteAppender {
|
||||
aggregator := NewRouteAppenderAggregator(ctx, middlewaresBuilder, r.staticConfiguration, r.entryPointName, runtimeConfiguration)
|
||||
|
||||
if r.acmeProvider != nil && r.acmeProvider.HTTPChallenge != nil && r.acmeProvider.HTTPChallenge.EntryPoint == r.entryPointName {
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"net/http"
|
||||
|
||||
"github.com/containous/alice"
|
||||
"github.com/containous/traefik/pkg/config"
|
||||
"github.com/containous/traefik/pkg/config/dynamic"
|
||||
"github.com/containous/traefik/pkg/log"
|
||||
"github.com/containous/traefik/pkg/middlewares/accesslog"
|
||||
"github.com/containous/traefik/pkg/middlewares/recovery"
|
||||
|
@ -22,7 +22,7 @@ const (
|
|||
)
|
||||
|
||||
// NewManager Creates a new Manager
|
||||
func NewManager(conf *config.RuntimeConfiguration,
|
||||
func NewManager(conf *dynamic.RuntimeConfiguration,
|
||||
serviceManager *service.Manager,
|
||||
middlewaresBuilder *middleware.Builder,
|
||||
modifierBuilder *responsemodifiers.Builder,
|
||||
|
@ -42,15 +42,15 @@ type Manager struct {
|
|||
serviceManager *service.Manager
|
||||
middlewaresBuilder *middleware.Builder
|
||||
modifierBuilder *responsemodifiers.Builder
|
||||
conf *config.RuntimeConfiguration
|
||||
conf *dynamic.RuntimeConfiguration
|
||||
}
|
||||
|
||||
func (m *Manager) getHTTPRouters(ctx context.Context, entryPoints []string, tls bool) map[string]map[string]*config.RouterInfo {
|
||||
func (m *Manager) getHTTPRouters(ctx context.Context, entryPoints []string, tls bool) map[string]map[string]*dynamic.RouterInfo {
|
||||
if m.conf != nil {
|
||||
return m.conf.GetRoutersByEntrypoints(ctx, entryPoints, tls)
|
||||
}
|
||||
|
||||
return make(map[string]map[string]*config.RouterInfo)
|
||||
return make(map[string]map[string]*dynamic.RouterInfo)
|
||||
}
|
||||
|
||||
// BuildHandlers Builds handler for all entry points
|
||||
|
@ -83,7 +83,7 @@ func (m *Manager) BuildHandlers(rootCtx context.Context, entryPoints []string, t
|
|||
return entryPointHandlers
|
||||
}
|
||||
|
||||
func (m *Manager) buildEntryPointHandler(ctx context.Context, configs map[string]*config.RouterInfo) (http.Handler, error) {
|
||||
func (m *Manager) buildEntryPointHandler(ctx context.Context, configs map[string]*dynamic.RouterInfo) (http.Handler, error) {
|
||||
router, err := rules.NewRouter()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -118,7 +118,7 @@ func (m *Manager) buildEntryPointHandler(ctx context.Context, configs map[string
|
|||
return chain.Then(router)
|
||||
}
|
||||
|
||||
func (m *Manager) buildRouterHandler(ctx context.Context, routerName string, routerConfig *config.RouterInfo) (http.Handler, error) {
|
||||
func (m *Manager) buildRouterHandler(ctx context.Context, routerName string, routerConfig *dynamic.RouterInfo) (http.Handler, error) {
|
||||
if handler, ok := m.routerHandlers[routerName]; ok {
|
||||
return handler, nil
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ func (m *Manager) buildRouterHandler(ctx context.Context, routerName string, rou
|
|||
return m.routerHandlers[routerName], nil
|
||||
}
|
||||
|
||||
func (m *Manager) buildHTTPHandler(ctx context.Context, router *config.RouterInfo, routerName string) (http.Handler, error) {
|
||||
func (m *Manager) buildHTTPHandler(ctx context.Context, router *dynamic.RouterInfo, routerName string) (http.Handler, error) {
|
||||
qualifiedNames := make([]string, len(router.Middlewares))
|
||||
for i, name := range router.Middlewares {
|
||||
qualifiedNames[i] = internal.GetQualifiedName(ctx, name)
|
||||
|
|
|
@ -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/middlewares/accesslog"
|
||||
"github.com/containous/traefik/pkg/middlewares/requestdecorator"
|
||||
"github.com/containous/traefik/pkg/responsemodifiers"
|
||||
|
@ -30,25 +30,25 @@ func TestRouterManager_Get(t *testing.T) {
|
|||
|
||||
testCases := []struct {
|
||||
desc string
|
||||
routersConfig map[string]*config.Router
|
||||
serviceConfig map[string]*config.Service
|
||||
middlewaresConfig map[string]*config.Middleware
|
||||
routersConfig map[string]*dynamic.Router
|
||||
serviceConfig map[string]*dynamic.Service
|
||||
middlewaresConfig map[string]*dynamic.Middleware
|
||||
entryPoints []string
|
||||
expected ExpectedResult
|
||||
}{
|
||||
{
|
||||
desc: "no middleware",
|
||||
routersConfig: map[string]*config.Router{
|
||||
routersConfig: map[string]*dynamic.Router{
|
||||
"foo": {
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "foo-service",
|
||||
Rule: "Host(`foo.bar`)",
|
||||
},
|
||||
},
|
||||
serviceConfig: map[string]*config.Service{
|
||||
serviceConfig: map[string]*dynamic.Service{
|
||||
"foo-service": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
Servers: []config.Server{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: server.URL,
|
||||
},
|
||||
|
@ -61,14 +61,14 @@ func TestRouterManager_Get(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "no load balancer",
|
||||
routersConfig: map[string]*config.Router{
|
||||
routersConfig: map[string]*dynamic.Router{
|
||||
"foo": {
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "foo-service",
|
||||
Rule: "Host(`foo.bar`)",
|
||||
},
|
||||
},
|
||||
serviceConfig: map[string]*config.Service{
|
||||
serviceConfig: map[string]*dynamic.Service{
|
||||
"foo-service": {},
|
||||
},
|
||||
entryPoints: []string{"web"},
|
||||
|
@ -76,16 +76,16 @@ func TestRouterManager_Get(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "no middleware, default entry point",
|
||||
routersConfig: map[string]*config.Router{
|
||||
routersConfig: map[string]*dynamic.Router{
|
||||
"foo": {
|
||||
Service: "foo-service",
|
||||
Rule: "Host(`foo.bar`)",
|
||||
},
|
||||
},
|
||||
serviceConfig: map[string]*config.Service{
|
||||
serviceConfig: map[string]*dynamic.Service{
|
||||
"foo-service": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
Servers: []config.Server{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: server.URL,
|
||||
},
|
||||
|
@ -98,17 +98,17 @@ func TestRouterManager_Get(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "no middleware, no matching",
|
||||
routersConfig: map[string]*config.Router{
|
||||
routersConfig: map[string]*dynamic.Router{
|
||||
"foo": {
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "foo-service",
|
||||
Rule: "Host(`bar.bar`)",
|
||||
},
|
||||
},
|
||||
serviceConfig: map[string]*config.Service{
|
||||
serviceConfig: map[string]*dynamic.Service{
|
||||
"foo-service": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
Servers: []config.Server{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: server.URL,
|
||||
},
|
||||
|
@ -121,7 +121,7 @@ func TestRouterManager_Get(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "middleware: headers > auth",
|
||||
routersConfig: map[string]*config.Router{
|
||||
routersConfig: map[string]*dynamic.Router{
|
||||
"foo": {
|
||||
EntryPoints: []string{"web"},
|
||||
Middlewares: []string{"headers-middle", "auth-middle"},
|
||||
|
@ -129,10 +129,10 @@ func TestRouterManager_Get(t *testing.T) {
|
|||
Rule: "Host(`foo.bar`)",
|
||||
},
|
||||
},
|
||||
serviceConfig: map[string]*config.Service{
|
||||
serviceConfig: map[string]*dynamic.Service{
|
||||
"foo-service": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
Servers: []config.Server{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: server.URL,
|
||||
},
|
||||
|
@ -140,14 +140,14 @@ func TestRouterManager_Get(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
middlewaresConfig: map[string]*config.Middleware{
|
||||
middlewaresConfig: map[string]*dynamic.Middleware{
|
||||
"auth-middle": {
|
||||
BasicAuth: &config.BasicAuth{
|
||||
BasicAuth: &dynamic.BasicAuth{
|
||||
Users: []string{"toto:titi"},
|
||||
},
|
||||
},
|
||||
"headers-middle": {
|
||||
Headers: &config.Headers{
|
||||
Headers: &dynamic.Headers{
|
||||
CustomRequestHeaders: map[string]string{"X-Apero": "beer"},
|
||||
},
|
||||
},
|
||||
|
@ -162,7 +162,7 @@ func TestRouterManager_Get(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "middleware: auth > header",
|
||||
routersConfig: map[string]*config.Router{
|
||||
routersConfig: map[string]*dynamic.Router{
|
||||
"foo": {
|
||||
EntryPoints: []string{"web"},
|
||||
Middlewares: []string{"auth-middle", "headers-middle"},
|
||||
|
@ -170,10 +170,10 @@ func TestRouterManager_Get(t *testing.T) {
|
|||
Rule: "Host(`foo.bar`)",
|
||||
},
|
||||
},
|
||||
serviceConfig: map[string]*config.Service{
|
||||
serviceConfig: map[string]*dynamic.Service{
|
||||
"foo-service": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
Servers: []config.Server{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: server.URL,
|
||||
},
|
||||
|
@ -181,14 +181,14 @@ func TestRouterManager_Get(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
middlewaresConfig: map[string]*config.Middleware{
|
||||
middlewaresConfig: map[string]*dynamic.Middleware{
|
||||
"auth-middle": {
|
||||
BasicAuth: &config.BasicAuth{
|
||||
BasicAuth: &dynamic.BasicAuth{
|
||||
Users: []string{"toto:titi"},
|
||||
},
|
||||
},
|
||||
"headers-middle": {
|
||||
Headers: &config.Headers{
|
||||
Headers: &dynamic.Headers{
|
||||
CustomRequestHeaders: map[string]string{"X-Apero": "beer"},
|
||||
},
|
||||
},
|
||||
|
@ -203,17 +203,17 @@ func TestRouterManager_Get(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "no middleware with provider name",
|
||||
routersConfig: map[string]*config.Router{
|
||||
routersConfig: map[string]*dynamic.Router{
|
||||
"foo@provider-1": {
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "foo-service",
|
||||
Rule: "Host(`foo.bar`)",
|
||||
},
|
||||
},
|
||||
serviceConfig: map[string]*config.Service{
|
||||
serviceConfig: map[string]*dynamic.Service{
|
||||
"foo-service@provider-1": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
Servers: []config.Server{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: server.URL,
|
||||
},
|
||||
|
@ -226,17 +226,17 @@ func TestRouterManager_Get(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "no middleware with specified provider name",
|
||||
routersConfig: map[string]*config.Router{
|
||||
routersConfig: map[string]*dynamic.Router{
|
||||
"foo@provider-1": {
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "foo-service@provider-2",
|
||||
Rule: "Host(`foo.bar`)",
|
||||
},
|
||||
},
|
||||
serviceConfig: map[string]*config.Service{
|
||||
serviceConfig: map[string]*dynamic.Service{
|
||||
"foo-service@provider-2": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
Servers: []config.Server{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: server.URL,
|
||||
},
|
||||
|
@ -249,7 +249,7 @@ func TestRouterManager_Get(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "middleware: chain with provider name",
|
||||
routersConfig: map[string]*config.Router{
|
||||
routersConfig: map[string]*dynamic.Router{
|
||||
"foo@provider-1": {
|
||||
EntryPoints: []string{"web"},
|
||||
Middlewares: []string{"chain-middle@provider-2", "headers-middle"},
|
||||
|
@ -257,10 +257,10 @@ func TestRouterManager_Get(t *testing.T) {
|
|||
Rule: "Host(`foo.bar`)",
|
||||
},
|
||||
},
|
||||
serviceConfig: map[string]*config.Service{
|
||||
serviceConfig: map[string]*dynamic.Service{
|
||||
"foo-service@provider-1": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
Servers: []config.Server{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: server.URL,
|
||||
},
|
||||
|
@ -268,17 +268,17 @@ func TestRouterManager_Get(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
middlewaresConfig: map[string]*config.Middleware{
|
||||
middlewaresConfig: map[string]*dynamic.Middleware{
|
||||
"chain-middle@provider-2": {
|
||||
Chain: &config.Chain{Middlewares: []string{"auth-middle"}},
|
||||
Chain: &dynamic.Chain{Middlewares: []string{"auth-middle"}},
|
||||
},
|
||||
"auth-middle@provider-2": {
|
||||
BasicAuth: &config.BasicAuth{
|
||||
BasicAuth: &dynamic.BasicAuth{
|
||||
Users: []string{"toto:titi"},
|
||||
},
|
||||
},
|
||||
"headers-middle@provider-1": {
|
||||
Headers: &config.Headers{
|
||||
Headers: &dynamic.Headers{
|
||||
CustomRequestHeaders: map[string]string{"X-Apero": "beer"},
|
||||
},
|
||||
},
|
||||
|
@ -298,8 +298,8 @@ func TestRouterManager_Get(t *testing.T) {
|
|||
t.Run(test.desc, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
rtConf := config.NewRuntimeConfig(config.Configuration{
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
rtConf := dynamic.NewRuntimeConfig(dynamic.Configuration{
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Services: test.serviceConfig,
|
||||
Routers: test.routersConfig,
|
||||
Middlewares: test.middlewaresConfig,
|
||||
|
@ -332,15 +332,15 @@ func TestAccessLog(t *testing.T) {
|
|||
|
||||
testCases := []struct {
|
||||
desc string
|
||||
routersConfig map[string]*config.Router
|
||||
serviceConfig map[string]*config.Service
|
||||
middlewaresConfig map[string]*config.Middleware
|
||||
routersConfig map[string]*dynamic.Router
|
||||
serviceConfig map[string]*dynamic.Service
|
||||
middlewaresConfig map[string]*dynamic.Middleware
|
||||
entryPoints []string
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
desc: "apply routerName in accesslog (first match)",
|
||||
routersConfig: map[string]*config.Router{
|
||||
routersConfig: map[string]*dynamic.Router{
|
||||
"foo": {
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "foo-service",
|
||||
|
@ -352,10 +352,10 @@ func TestAccessLog(t *testing.T) {
|
|||
Rule: "Host(`bar.foo`)",
|
||||
},
|
||||
},
|
||||
serviceConfig: map[string]*config.Service{
|
||||
serviceConfig: map[string]*dynamic.Service{
|
||||
"foo-service": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
Servers: []config.Server{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: server.URL,
|
||||
},
|
||||
|
@ -368,7 +368,7 @@ func TestAccessLog(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "apply routerName in accesslog (second match)",
|
||||
routersConfig: map[string]*config.Router{
|
||||
routersConfig: map[string]*dynamic.Router{
|
||||
"foo": {
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "foo-service",
|
||||
|
@ -380,10 +380,10 @@ func TestAccessLog(t *testing.T) {
|
|||
Rule: "Host(`foo.bar`)",
|
||||
},
|
||||
},
|
||||
serviceConfig: map[string]*config.Service{
|
||||
serviceConfig: map[string]*dynamic.Service{
|
||||
"foo-service": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
Servers: []config.Server{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: server.URL,
|
||||
},
|
||||
|
@ -399,8 +399,8 @@ func TestAccessLog(t *testing.T) {
|
|||
for _, test := range testCases {
|
||||
t.Run(test.desc, func(t *testing.T) {
|
||||
|
||||
rtConf := config.NewRuntimeConfig(config.Configuration{
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
rtConf := dynamic.NewRuntimeConfig(dynamic.Configuration{
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Services: test.serviceConfig,
|
||||
Routers: test.routersConfig,
|
||||
Middlewares: test.middlewaresConfig,
|
||||
|
@ -438,17 +438,17 @@ func TestAccessLog(t *testing.T) {
|
|||
func TestRuntimeConfiguration(t *testing.T) {
|
||||
testCases := []struct {
|
||||
desc string
|
||||
serviceConfig map[string]*config.Service
|
||||
routerConfig map[string]*config.Router
|
||||
middlewareConfig map[string]*config.Middleware
|
||||
serviceConfig map[string]*dynamic.Service
|
||||
routerConfig map[string]*dynamic.Router
|
||||
middlewareConfig map[string]*dynamic.Middleware
|
||||
expectedError int
|
||||
}{
|
||||
{
|
||||
desc: "No error",
|
||||
serviceConfig: map[string]*config.Service{
|
||||
serviceConfig: map[string]*dynamic.Service{
|
||||
"foo-service": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
Servers: []config.Server{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://127.0.0.1:8085",
|
||||
},
|
||||
|
@ -456,14 +456,14 @@ func TestRuntimeConfiguration(t *testing.T) {
|
|||
URL: "http://127.0.0.1:8086",
|
||||
},
|
||||
},
|
||||
HealthCheck: &config.HealthCheck{
|
||||
HealthCheck: &dynamic.HealthCheck{
|
||||
Interval: "500ms",
|
||||
Path: "/health",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
routerConfig: map[string]*config.Router{
|
||||
routerConfig: map[string]*dynamic.Router{
|
||||
"foo": {
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "foo-service",
|
||||
|
@ -479,10 +479,10 @@ func TestRuntimeConfiguration(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "One router with wrong rule",
|
||||
serviceConfig: map[string]*config.Service{
|
||||
serviceConfig: map[string]*dynamic.Service{
|
||||
"foo-service": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
Servers: []config.Server{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://127.0.0.1",
|
||||
},
|
||||
|
@ -490,7 +490,7 @@ func TestRuntimeConfiguration(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
routerConfig: map[string]*config.Router{
|
||||
routerConfig: map[string]*dynamic.Router{
|
||||
"foo": {
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "foo-service",
|
||||
|
@ -506,10 +506,10 @@ func TestRuntimeConfiguration(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "All router with wrong rule",
|
||||
serviceConfig: map[string]*config.Service{
|
||||
serviceConfig: map[string]*dynamic.Service{
|
||||
"foo-service": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
Servers: []config.Server{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://127.0.0.1",
|
||||
},
|
||||
|
@ -517,7 +517,7 @@ func TestRuntimeConfiguration(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
routerConfig: map[string]*config.Router{
|
||||
routerConfig: map[string]*dynamic.Router{
|
||||
"foo": {
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "foo-service",
|
||||
|
@ -533,10 +533,10 @@ func TestRuntimeConfiguration(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Router with unknown service",
|
||||
serviceConfig: map[string]*config.Service{
|
||||
serviceConfig: map[string]*dynamic.Service{
|
||||
"foo-service": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
Servers: []config.Server{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://127.0.0.1",
|
||||
},
|
||||
|
@ -544,7 +544,7 @@ func TestRuntimeConfiguration(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
routerConfig: map[string]*config.Router{
|
||||
routerConfig: map[string]*dynamic.Router{
|
||||
"foo": {
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "wrong-service",
|
||||
|
@ -560,12 +560,12 @@ func TestRuntimeConfiguration(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Router with broken service",
|
||||
serviceConfig: map[string]*config.Service{
|
||||
serviceConfig: map[string]*dynamic.Service{
|
||||
"foo-service": {
|
||||
LoadBalancer: nil,
|
||||
},
|
||||
},
|
||||
routerConfig: map[string]*config.Router{
|
||||
routerConfig: map[string]*dynamic.Router{
|
||||
"bar": {
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "foo-service",
|
||||
|
@ -576,10 +576,10 @@ func TestRuntimeConfiguration(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Router with middleware",
|
||||
serviceConfig: map[string]*config.Service{
|
||||
serviceConfig: map[string]*dynamic.Service{
|
||||
"foo-service": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
Servers: []config.Server{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://127.0.0.1",
|
||||
},
|
||||
|
@ -587,19 +587,19 @@ func TestRuntimeConfiguration(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
middlewareConfig: map[string]*config.Middleware{
|
||||
middlewareConfig: map[string]*dynamic.Middleware{
|
||||
"auth": {
|
||||
BasicAuth: &config.BasicAuth{
|
||||
BasicAuth: &dynamic.BasicAuth{
|
||||
Users: []string{"admin:admin"},
|
||||
},
|
||||
},
|
||||
"addPrefixTest": {
|
||||
AddPrefix: &config.AddPrefix{
|
||||
AddPrefix: &dynamic.AddPrefix{
|
||||
Prefix: "/toto",
|
||||
},
|
||||
},
|
||||
},
|
||||
routerConfig: map[string]*config.Router{
|
||||
routerConfig: map[string]*dynamic.Router{
|
||||
"bar": {
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "foo-service",
|
||||
|
@ -616,10 +616,10 @@ func TestRuntimeConfiguration(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Router with unknown middleware",
|
||||
serviceConfig: map[string]*config.Service{
|
||||
serviceConfig: map[string]*dynamic.Service{
|
||||
"foo-service": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
Servers: []config.Server{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://127.0.0.1",
|
||||
},
|
||||
|
@ -627,14 +627,14 @@ func TestRuntimeConfiguration(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
middlewareConfig: map[string]*config.Middleware{
|
||||
middlewareConfig: map[string]*dynamic.Middleware{
|
||||
"auth": {
|
||||
BasicAuth: &config.BasicAuth{
|
||||
BasicAuth: &dynamic.BasicAuth{
|
||||
Users: []string{"admin:admin"},
|
||||
},
|
||||
},
|
||||
},
|
||||
routerConfig: map[string]*config.Router{
|
||||
routerConfig: map[string]*dynamic.Router{
|
||||
"bar": {
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "foo-service",
|
||||
|
@ -647,10 +647,10 @@ func TestRuntimeConfiguration(t *testing.T) {
|
|||
|
||||
{
|
||||
desc: "Router with broken middleware",
|
||||
serviceConfig: map[string]*config.Service{
|
||||
serviceConfig: map[string]*dynamic.Service{
|
||||
"foo-service": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
Servers: []config.Server{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://127.0.0.1",
|
||||
},
|
||||
|
@ -658,14 +658,14 @@ func TestRuntimeConfiguration(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
middlewareConfig: map[string]*config.Middleware{
|
||||
middlewareConfig: map[string]*dynamic.Middleware{
|
||||
"auth": {
|
||||
BasicAuth: &config.BasicAuth{
|
||||
BasicAuth: &dynamic.BasicAuth{
|
||||
Users: []string{"foo"},
|
||||
},
|
||||
},
|
||||
},
|
||||
routerConfig: map[string]*config.Router{
|
||||
routerConfig: map[string]*dynamic.Router{
|
||||
"bar": {
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "foo-service",
|
||||
|
@ -685,8 +685,8 @@ func TestRuntimeConfiguration(t *testing.T) {
|
|||
|
||||
entryPoints := []string{"web"}
|
||||
|
||||
rtConf := config.NewRuntimeConfig(config.Configuration{
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
rtConf := dynamic.NewRuntimeConfig(dynamic.Configuration{
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Services: test.serviceConfig,
|
||||
Routers: test.routerConfig,
|
||||
Middlewares: test.middlewareConfig,
|
||||
|
@ -694,7 +694,7 @@ func TestRuntimeConfiguration(t *testing.T) {
|
|||
})
|
||||
serviceManager := service.NewManager(rtConf.Services, http.DefaultTransport)
|
||||
middlewaresBuilder := middleware.NewBuilder(rtConf.Middlewares, serviceManager)
|
||||
responseModifierFactory := responsemodifiers.NewBuilder(map[string]*config.MiddlewareInfo{})
|
||||
responseModifierFactory := responsemodifiers.NewBuilder(map[string]*dynamic.MiddlewareInfo{})
|
||||
routerManager := NewManager(rtConf, serviceManager, middlewaresBuilder, responseModifierFactory)
|
||||
|
||||
_ = routerManager.BuildHandlers(context.Background(), entryPoints, false)
|
||||
|
@ -739,17 +739,17 @@ func BenchmarkRouterServe(b *testing.B) {
|
|||
StatusCode: 200,
|
||||
Body: ioutil.NopCloser(strings.NewReader("")),
|
||||
}
|
||||
routersConfig := map[string]*config.Router{
|
||||
routersConfig := map[string]*dynamic.Router{
|
||||
"foo": {
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "foo-service",
|
||||
Rule: "Host(`foo.bar`) && Path(`/`)",
|
||||
},
|
||||
}
|
||||
serviceConfig := map[string]*config.Service{
|
||||
serviceConfig := map[string]*dynamic.Service{
|
||||
"foo-service": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
Servers: []config.Server{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: server.URL,
|
||||
},
|
||||
|
@ -759,11 +759,11 @@ func BenchmarkRouterServe(b *testing.B) {
|
|||
}
|
||||
entryPoints := []string{"web"}
|
||||
|
||||
rtConf := config.NewRuntimeConfig(config.Configuration{
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
rtConf := dynamic.NewRuntimeConfig(dynamic.Configuration{
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Services: serviceConfig,
|
||||
Routers: routersConfig,
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
Middlewares: map[string]*dynamic.Middleware{},
|
||||
},
|
||||
})
|
||||
serviceManager := service.NewManager(rtConf.Services, &staticTransport{res})
|
||||
|
@ -790,10 +790,10 @@ func BenchmarkService(b *testing.B) {
|
|||
Body: ioutil.NopCloser(strings.NewReader("")),
|
||||
}
|
||||
|
||||
serviceConfig := map[string]*config.Service{
|
||||
serviceConfig := map[string]*dynamic.Service{
|
||||
"foo-service": {
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
Servers: []config.Server{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "tchouck",
|
||||
},
|
||||
|
@ -802,8 +802,8 @@ func BenchmarkService(b *testing.B) {
|
|||
},
|
||||
}
|
||||
|
||||
rtConf := config.NewRuntimeConfig(config.Configuration{
|
||||
HTTP: &config.HTTPConfiguration{
|
||||
rtConf := dynamic.NewRuntimeConfig(dynamic.Configuration{
|
||||
HTTP: &dynamic.HTTPConfiguration{
|
||||
Services: serviceConfig,
|
||||
},
|
||||
})
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/containous/traefik/pkg/config"
|
||||
"github.com/containous/traefik/pkg/config/dynamic"
|
||||
"github.com/containous/traefik/pkg/log"
|
||||
"github.com/containous/traefik/pkg/rules"
|
||||
"github.com/containous/traefik/pkg/server/internal"
|
||||
|
@ -16,7 +16,7 @@ import (
|
|||
)
|
||||
|
||||
// NewManager Creates a new Manager
|
||||
func NewManager(conf *config.RuntimeConfiguration,
|
||||
func NewManager(conf *dynamic.RuntimeConfiguration,
|
||||
serviceManager *tcpservice.Manager,
|
||||
httpHandlers map[string]http.Handler,
|
||||
httpsHandlers map[string]http.Handler,
|
||||
|
@ -37,23 +37,23 @@ type Manager struct {
|
|||
httpHandlers map[string]http.Handler
|
||||
httpsHandlers map[string]http.Handler
|
||||
tlsManager *traefiktls.Manager
|
||||
conf *config.RuntimeConfiguration
|
||||
conf *dynamic.RuntimeConfiguration
|
||||
}
|
||||
|
||||
func (m *Manager) getTCPRouters(ctx context.Context, entryPoints []string) map[string]map[string]*config.TCPRouterInfo {
|
||||
func (m *Manager) getTCPRouters(ctx context.Context, entryPoints []string) map[string]map[string]*dynamic.TCPRouterInfo {
|
||||
if m.conf != nil {
|
||||
return m.conf.GetTCPRoutersByEntrypoints(ctx, entryPoints)
|
||||
}
|
||||
|
||||
return make(map[string]map[string]*config.TCPRouterInfo)
|
||||
return make(map[string]map[string]*dynamic.TCPRouterInfo)
|
||||
}
|
||||
|
||||
func (m *Manager) getHTTPRouters(ctx context.Context, entryPoints []string, tls bool) map[string]map[string]*config.RouterInfo {
|
||||
func (m *Manager) getHTTPRouters(ctx context.Context, entryPoints []string, tls bool) map[string]map[string]*dynamic.RouterInfo {
|
||||
if m.conf != nil {
|
||||
return m.conf.GetRoutersByEntrypoints(ctx, entryPoints, tls)
|
||||
}
|
||||
|
||||
return make(map[string]map[string]*config.RouterInfo)
|
||||
return make(map[string]map[string]*dynamic.RouterInfo)
|
||||
}
|
||||
|
||||
// BuildHandlers builds the handlers for the given entrypoints
|
||||
|
@ -79,7 +79,7 @@ func (m *Manager) BuildHandlers(rootCtx context.Context, entryPoints []string) m
|
|||
return entryPointHandlers
|
||||
}
|
||||
|
||||
func (m *Manager) buildEntryPointHandler(ctx context.Context, configs map[string]*config.TCPRouterInfo, configsHTTP map[string]*config.RouterInfo, handlerHTTP http.Handler, handlerHTTPS http.Handler) (*tcp.Router, error) {
|
||||
func (m *Manager) buildEntryPointHandler(ctx context.Context, configs map[string]*dynamic.TCPRouterInfo, configsHTTP map[string]*dynamic.RouterInfo, handlerHTTP http.Handler, handlerHTTPS http.Handler) (*tcp.Router, error) {
|
||||
router := &tcp.Router{}
|
||||
router.HTTPHandler(handlerHTTP)
|
||||
const defaultTLSConfigName = "default"
|
||||
|
|
|
@ -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/service/tcp"
|
||||
"github.com/containous/traefik/pkg/tls"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
@ -13,17 +13,17 @@ import (
|
|||
func TestRuntimeConfiguration(t *testing.T) {
|
||||
testCases := []struct {
|
||||
desc string
|
||||
serviceConfig map[string]*config.TCPServiceInfo
|
||||
routerConfig map[string]*config.TCPRouterInfo
|
||||
serviceConfig map[string]*dynamic.TCPServiceInfo
|
||||
routerConfig map[string]*dynamic.TCPRouterInfo
|
||||
expectedError int
|
||||
}{
|
||||
{
|
||||
desc: "No error",
|
||||
serviceConfig: map[string]*config.TCPServiceInfo{
|
||||
serviceConfig: map[string]*dynamic.TCPServiceInfo{
|
||||
"foo-service": {
|
||||
TCPService: &config.TCPService{
|
||||
LoadBalancer: &config.TCPLoadBalancerService{
|
||||
Servers: []config.TCPServer{
|
||||
TCPService: &dynamic.TCPService{
|
||||
LoadBalancer: &dynamic.TCPLoadBalancerService{
|
||||
Servers: []dynamic.TCPServer{
|
||||
{
|
||||
Port: "8085",
|
||||
Address: "127.0.0.1:8085",
|
||||
|
@ -37,25 +37,25 @@ func TestRuntimeConfiguration(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
routerConfig: map[string]*config.TCPRouterInfo{
|
||||
routerConfig: map[string]*dynamic.TCPRouterInfo{
|
||||
"foo": {
|
||||
TCPRouter: &config.TCPRouter{
|
||||
TCPRouter: &dynamic.TCPRouter{
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "foo-service",
|
||||
Rule: "HostSNI(`bar.foo`)",
|
||||
TLS: &config.RouterTCPTLSConfig{
|
||||
TLS: &dynamic.RouterTCPTLSConfig{
|
||||
Passthrough: false,
|
||||
Options: "foo",
|
||||
},
|
||||
},
|
||||
},
|
||||
"bar": {
|
||||
TCPRouter: &config.TCPRouter{
|
||||
TCPRouter: &dynamic.TCPRouter{
|
||||
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "foo-service",
|
||||
Rule: "HostSNI(`foo.bar`)",
|
||||
TLS: &config.RouterTCPTLSConfig{
|
||||
TLS: &dynamic.RouterTCPTLSConfig{
|
||||
Passthrough: false,
|
||||
Options: "bar",
|
||||
},
|
||||
|
@ -66,11 +66,11 @@ func TestRuntimeConfiguration(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "One router with wrong rule",
|
||||
serviceConfig: map[string]*config.TCPServiceInfo{
|
||||
serviceConfig: map[string]*dynamic.TCPServiceInfo{
|
||||
"foo-service": {
|
||||
TCPService: &config.TCPService{
|
||||
LoadBalancer: &config.TCPLoadBalancerService{
|
||||
Servers: []config.TCPServer{
|
||||
TCPService: &dynamic.TCPService{
|
||||
LoadBalancer: &dynamic.TCPLoadBalancerService{
|
||||
Servers: []dynamic.TCPServer{
|
||||
{
|
||||
Address: "127.0.0.1:80",
|
||||
},
|
||||
|
@ -79,9 +79,9 @@ func TestRuntimeConfiguration(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
routerConfig: map[string]*config.TCPRouterInfo{
|
||||
routerConfig: map[string]*dynamic.TCPRouterInfo{
|
||||
"foo": {
|
||||
TCPRouter: &config.TCPRouter{
|
||||
TCPRouter: &dynamic.TCPRouter{
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "foo-service",
|
||||
Rule: "WrongRule(`bar.foo`)",
|
||||
|
@ -89,7 +89,7 @@ func TestRuntimeConfiguration(t *testing.T) {
|
|||
},
|
||||
|
||||
"bar": {
|
||||
TCPRouter: &config.TCPRouter{
|
||||
TCPRouter: &dynamic.TCPRouter{
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "foo-service",
|
||||
Rule: "HostSNI(`foo.bar`)",
|
||||
|
@ -100,11 +100,11 @@ func TestRuntimeConfiguration(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "All router with wrong rule",
|
||||
serviceConfig: map[string]*config.TCPServiceInfo{
|
||||
serviceConfig: map[string]*dynamic.TCPServiceInfo{
|
||||
"foo-service": {
|
||||
TCPService: &config.TCPService{
|
||||
LoadBalancer: &config.TCPLoadBalancerService{
|
||||
Servers: []config.TCPServer{
|
||||
TCPService: &dynamic.TCPService{
|
||||
LoadBalancer: &dynamic.TCPLoadBalancerService{
|
||||
Servers: []dynamic.TCPServer{
|
||||
{
|
||||
Address: "127.0.0.1:80",
|
||||
},
|
||||
|
@ -113,16 +113,16 @@ func TestRuntimeConfiguration(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
routerConfig: map[string]*config.TCPRouterInfo{
|
||||
routerConfig: map[string]*dynamic.TCPRouterInfo{
|
||||
"foo": {
|
||||
TCPRouter: &config.TCPRouter{
|
||||
TCPRouter: &dynamic.TCPRouter{
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "foo-service",
|
||||
Rule: "WrongRule(`bar.foo`)",
|
||||
},
|
||||
},
|
||||
"bar": {
|
||||
TCPRouter: &config.TCPRouter{
|
||||
TCPRouter: &dynamic.TCPRouter{
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "foo-service",
|
||||
Rule: "WrongRule(`foo.bar`)",
|
||||
|
@ -133,11 +133,11 @@ func TestRuntimeConfiguration(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Router with unknown service",
|
||||
serviceConfig: map[string]*config.TCPServiceInfo{
|
||||
serviceConfig: map[string]*dynamic.TCPServiceInfo{
|
||||
"foo-service": {
|
||||
TCPService: &config.TCPService{
|
||||
LoadBalancer: &config.TCPLoadBalancerService{
|
||||
Servers: []config.TCPServer{
|
||||
TCPService: &dynamic.TCPService{
|
||||
LoadBalancer: &dynamic.TCPLoadBalancerService{
|
||||
Servers: []dynamic.TCPServer{
|
||||
{
|
||||
Address: "127.0.0.1:80",
|
||||
},
|
||||
|
@ -146,16 +146,16 @@ func TestRuntimeConfiguration(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
routerConfig: map[string]*config.TCPRouterInfo{
|
||||
routerConfig: map[string]*dynamic.TCPRouterInfo{
|
||||
"foo": {
|
||||
TCPRouter: &config.TCPRouter{
|
||||
TCPRouter: &dynamic.TCPRouter{
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "wrong-service",
|
||||
Rule: "HostSNI(`bar.foo`)",
|
||||
},
|
||||
},
|
||||
"bar": {
|
||||
TCPRouter: &config.TCPRouter{
|
||||
TCPRouter: &dynamic.TCPRouter{
|
||||
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "foo-service",
|
||||
|
@ -167,16 +167,16 @@ func TestRuntimeConfiguration(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Router with broken service",
|
||||
serviceConfig: map[string]*config.TCPServiceInfo{
|
||||
serviceConfig: map[string]*dynamic.TCPServiceInfo{
|
||||
"foo-service": {
|
||||
TCPService: &config.TCPService{
|
||||
TCPService: &dynamic.TCPService{
|
||||
LoadBalancer: nil,
|
||||
},
|
||||
},
|
||||
},
|
||||
routerConfig: map[string]*config.TCPRouterInfo{
|
||||
routerConfig: map[string]*dynamic.TCPRouterInfo{
|
||||
"bar": {
|
||||
TCPRouter: &config.TCPRouter{
|
||||
TCPRouter: &dynamic.TCPRouter{
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "foo-service",
|
||||
Rule: "HostSNI(`foo.bar`)",
|
||||
|
@ -195,7 +195,7 @@ func TestRuntimeConfiguration(t *testing.T) {
|
|||
|
||||
entryPoints := []string{"web"}
|
||||
|
||||
conf := &config.RuntimeConfiguration{
|
||||
conf := &dynamic.RuntimeConfiguration{
|
||||
TCPServices: test.serviceConfig,
|
||||
TCPRouters: test.routerConfig,
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/containous/traefik/pkg/config"
|
||||
"github.com/containous/traefik/pkg/config/dynamic"
|
||||
"github.com/containous/traefik/pkg/config/static"
|
||||
"github.com/containous/traefik/pkg/log"
|
||||
"github.com/containous/traefik/pkg/metrics"
|
||||
|
@ -27,19 +27,19 @@ import (
|
|||
// Server is the reverse-proxy/load-balancer engine
|
||||
type Server struct {
|
||||
entryPointsTCP TCPEntryPoints
|
||||
configurationChan chan config.Message
|
||||
configurationValidatedChan chan config.Message
|
||||
configurationChan chan dynamic.Message
|
||||
configurationValidatedChan chan dynamic.Message
|
||||
signals chan os.Signal
|
||||
stopChan chan bool
|
||||
currentConfigurations safe.Safe
|
||||
providerConfigUpdateMap map[string]chan config.Message
|
||||
providerConfigUpdateMap map[string]chan dynamic.Message
|
||||
accessLoggerMiddleware *accesslog.Handler
|
||||
tracer *tracing.Tracing
|
||||
routinesPool *safe.Pool
|
||||
defaultRoundTripper http.RoundTripper
|
||||
metricsRegistry metrics.Registry
|
||||
provider provider.Provider
|
||||
configurationListeners []func(config.Configuration)
|
||||
configurationListeners []func(dynamic.Configuration)
|
||||
requestDecorator *requestdecorator.RequestDecorator
|
||||
providersThrottleDuration time.Duration
|
||||
tlsManager *tls.Manager
|
||||
|
@ -47,7 +47,7 @@ type Server struct {
|
|||
|
||||
// RouteAppenderFactory the route appender factory interface
|
||||
type RouteAppenderFactory interface {
|
||||
NewAppender(ctx context.Context, middlewaresBuilder *middleware.Builder, runtimeConfiguration *config.RuntimeConfiguration) types.RouteAppender
|
||||
NewAppender(ctx context.Context, middlewaresBuilder *middleware.Builder, runtimeConfiguration *dynamic.RuntimeConfiguration) types.RouteAppender
|
||||
}
|
||||
|
||||
func setupTracing(conf *static.Tracing) tracing.Backend {
|
||||
|
@ -104,14 +104,14 @@ func NewServer(staticConfiguration static.Configuration, provider provider.Provi
|
|||
|
||||
server.provider = provider
|
||||
server.entryPointsTCP = entryPoints
|
||||
server.configurationChan = make(chan config.Message, 100)
|
||||
server.configurationValidatedChan = make(chan config.Message, 100)
|
||||
server.configurationChan = make(chan dynamic.Message, 100)
|
||||
server.configurationValidatedChan = make(chan dynamic.Message, 100)
|
||||
server.signals = make(chan os.Signal, 1)
|
||||
server.stopChan = make(chan bool, 1)
|
||||
server.configureSignals()
|
||||
currentConfigurations := make(config.Configurations)
|
||||
currentConfigurations := make(dynamic.Configurations)
|
||||
server.currentConfigurations.Set(currentConfigurations)
|
||||
server.providerConfigUpdateMap = make(map[string]chan config.Message)
|
||||
server.providerConfigUpdateMap = make(map[string]chan dynamic.Message)
|
||||
server.tlsManager = tlsManager
|
||||
|
||||
if staticConfiguration.Providers != nil {
|
||||
|
@ -236,7 +236,7 @@ func (s *Server) Close() {
|
|||
|
||||
func (s *Server) startTCPServers() {
|
||||
// Use an empty configuration in order to initialize the default handlers with internal routes
|
||||
routers := s.loadConfigurationTCP(config.Configurations{})
|
||||
routers := s.loadConfigurationTCP(dynamic.Configurations{})
|
||||
for entryPointName, router := range routers {
|
||||
s.entryPointsTCP[entryPointName].switchRouter(router)
|
||||
}
|
||||
|
@ -266,9 +266,9 @@ func (s *Server) listenProviders(stop chan bool) {
|
|||
}
|
||||
|
||||
// AddListener adds a new listener function used when new configuration is provided
|
||||
func (s *Server) AddListener(listener func(config.Configuration)) {
|
||||
func (s *Server) AddListener(listener func(dynamic.Configuration)) {
|
||||
if s.configurationListeners == nil {
|
||||
s.configurationListeners = make([]func(config.Configuration), 0)
|
||||
s.configurationListeners = make([]func(dynamic.Configuration), 0)
|
||||
}
|
||||
s.configurationListeners = append(s.configurationListeners, listener)
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
|
||||
"github.com/containous/alice"
|
||||
"github.com/containous/mux"
|
||||
"github.com/containous/traefik/pkg/config"
|
||||
"github.com/containous/traefik/pkg/config/dynamic"
|
||||
"github.com/containous/traefik/pkg/log"
|
||||
"github.com/containous/traefik/pkg/middlewares/accesslog"
|
||||
"github.com/containous/traefik/pkg/middlewares/requestdecorator"
|
||||
|
@ -26,8 +26,8 @@ import (
|
|||
)
|
||||
|
||||
// loadConfiguration manages dynamically routers, middlewares, servers and TLS configurations
|
||||
func (s *Server) loadConfiguration(configMsg config.Message) {
|
||||
currentConfigurations := s.currentConfigurations.Get().(config.Configurations)
|
||||
func (s *Server) loadConfiguration(configMsg dynamic.Message) {
|
||||
currentConfigurations := s.currentConfigurations.Get().(dynamic.Configurations)
|
||||
|
||||
// Copy configurations to new map so we don't change current if LoadConfig fails
|
||||
newConfigurations := currentConfigurations.DeepCopy()
|
||||
|
@ -53,7 +53,7 @@ func (s *Server) loadConfiguration(configMsg config.Message) {
|
|||
|
||||
// loadConfigurationTCP returns a new gorilla.mux Route from the specified global configuration and the dynamic
|
||||
// provider configurations.
|
||||
func (s *Server) loadConfigurationTCP(configurations config.Configurations) map[string]*tcpCore.Router {
|
||||
func (s *Server) loadConfigurationTCP(configurations dynamic.Configurations) map[string]*tcpCore.Router {
|
||||
ctx := context.TODO()
|
||||
|
||||
var entryPoints []string
|
||||
|
@ -65,7 +65,7 @@ func (s *Server) loadConfigurationTCP(configurations config.Configurations) map[
|
|||
|
||||
s.tlsManager.UpdateConfigs(conf.TLS.Stores, conf.TLS.Options, conf.TLS.Certificates)
|
||||
|
||||
rtConf := config.NewRuntimeConfig(conf)
|
||||
rtConf := dynamic.NewRuntimeConfig(conf)
|
||||
handlersNonTLS, handlersTLS := s.createHTTPHandlers(ctx, rtConf, entryPoints)
|
||||
routersTCP := s.createTCPRouters(ctx, rtConf, entryPoints, handlersNonTLS, handlersTLS)
|
||||
rtConf.PopulateUsedBy()
|
||||
|
@ -74,7 +74,7 @@ func (s *Server) loadConfigurationTCP(configurations config.Configurations) map[
|
|||
}
|
||||
|
||||
// the given configuration must not be nil. its fields will get mutated.
|
||||
func (s *Server) createTCPRouters(ctx context.Context, configuration *config.RuntimeConfiguration, entryPoints []string, handlers map[string]http.Handler, handlersTLS map[string]http.Handler) map[string]*tcpCore.Router {
|
||||
func (s *Server) createTCPRouters(ctx context.Context, configuration *dynamic.RuntimeConfiguration, entryPoints []string, handlers map[string]http.Handler, handlersTLS map[string]http.Handler) map[string]*tcpCore.Router {
|
||||
if configuration == nil {
|
||||
return make(map[string]*tcpCore.Router)
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ func (s *Server) createTCPRouters(ctx context.Context, configuration *config.Run
|
|||
}
|
||||
|
||||
// createHTTPHandlers returns, for the given configuration and entryPoints, the HTTP handlers for non-TLS connections, and for the TLS ones. the given configuration must not be nil. its fields will get mutated.
|
||||
func (s *Server) createHTTPHandlers(ctx context.Context, configuration *config.RuntimeConfiguration, entryPoints []string) (map[string]http.Handler, map[string]http.Handler) {
|
||||
func (s *Server) createHTTPHandlers(ctx context.Context, configuration *dynamic.RuntimeConfiguration, entryPoints []string) (map[string]http.Handler, map[string]http.Handler) {
|
||||
serviceManager := service.NewManager(configuration.Services, s.defaultRoundTripper)
|
||||
middlewaresBuilder := middleware.NewBuilder(configuration.Middlewares, serviceManager)
|
||||
responseModifierFactory := responsemodifiers.NewBuilder(configuration.Middlewares)
|
||||
|
@ -150,15 +150,15 @@ func (s *Server) createHTTPHandlers(ctx context.Context, configuration *config.R
|
|||
return routerHandlers, handlersTLS
|
||||
}
|
||||
|
||||
func isEmptyConfiguration(conf *config.Configuration) bool {
|
||||
func isEmptyConfiguration(conf *dynamic.Configuration) bool {
|
||||
if conf == nil {
|
||||
return true
|
||||
}
|
||||
if conf.TCP == nil {
|
||||
conf.TCP = &config.TCPConfiguration{}
|
||||
conf.TCP = &dynamic.TCPConfiguration{}
|
||||
}
|
||||
if conf.HTTP == nil {
|
||||
conf.HTTP = &config.HTTPConfiguration{}
|
||||
conf.HTTP = &dynamic.HTTPConfiguration{}
|
||||
}
|
||||
|
||||
return conf.HTTP.Routers == nil &&
|
||||
|
@ -169,9 +169,9 @@ func isEmptyConfiguration(conf *config.Configuration) bool {
|
|||
conf.TCP.Services == nil
|
||||
}
|
||||
|
||||
func (s *Server) preLoadConfiguration(configMsg config.Message) {
|
||||
func (s *Server) preLoadConfiguration(configMsg dynamic.Message) {
|
||||
s.defaultConfigurationValues(configMsg.Configuration.HTTP)
|
||||
currentConfigurations := s.currentConfigurations.Get().(config.Configurations)
|
||||
currentConfigurations := s.currentConfigurations.Get().(dynamic.Configurations)
|
||||
|
||||
logger := log.WithoutContext().WithField(log.ProviderName, configMsg.ProviderName)
|
||||
if log.GetLevel() == logrus.DebugLevel {
|
||||
|
@ -191,7 +191,7 @@ func (s *Server) preLoadConfiguration(configMsg config.Message) {
|
|||
|
||||
providerConfigUpdateCh, ok := s.providerConfigUpdateMap[configMsg.ProviderName]
|
||||
if !ok {
|
||||
providerConfigUpdateCh = make(chan config.Message)
|
||||
providerConfigUpdateCh = make(chan dynamic.Message)
|
||||
s.providerConfigUpdateMap[configMsg.ProviderName] = providerConfigUpdateCh
|
||||
s.routinesPool.Go(func(stop chan bool) {
|
||||
s.throttleProviderConfigReload(s.providersThrottleDuration, s.configurationValidatedChan, providerConfigUpdateCh, stop)
|
||||
|
@ -201,7 +201,7 @@ func (s *Server) preLoadConfiguration(configMsg config.Message) {
|
|||
providerConfigUpdateCh <- configMsg
|
||||
}
|
||||
|
||||
func (s *Server) defaultConfigurationValues(configuration *config.HTTPConfiguration) {
|
||||
func (s *Server) defaultConfigurationValues(configuration *dynamic.HTTPConfiguration) {
|
||||
// FIXME create a config hook
|
||||
}
|
||||
|
||||
|
@ -223,7 +223,7 @@ func (s *Server) listenConfigurations(stop chan bool) {
|
|||
// It will immediately publish a new configuration and then only publish the next configuration after the throttle duration.
|
||||
// Note that in the case it receives N new configs in the timeframe of the throttle duration after publishing,
|
||||
// it will publish the last of the newly received configurations.
|
||||
func (s *Server) throttleProviderConfigReload(throttle time.Duration, publish chan<- config.Message, in <-chan config.Message, stop chan bool) {
|
||||
func (s *Server) throttleProviderConfigReload(throttle time.Duration, publish chan<- dynamic.Message, in <-chan dynamic.Message, stop chan bool) {
|
||||
ring := channels.NewRingChannel(1)
|
||||
defer ring.Close()
|
||||
|
||||
|
@ -233,7 +233,7 @@ func (s *Server) throttleProviderConfigReload(throttle time.Duration, publish ch
|
|||
case <-stop:
|
||||
return
|
||||
case nextConfig := <-ring.Out():
|
||||
if config, ok := nextConfig.(config.Message); ok {
|
||||
if config, ok := nextConfig.(dynamic.Message); ok {
|
||||
publish <- config
|
||||
time.Sleep(throttle)
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/containous/traefik/pkg/config"
|
||||
"github.com/containous/traefik/pkg/config/dynamic"
|
||||
"github.com/containous/traefik/pkg/config/static"
|
||||
th "github.com/containous/traefik/pkg/testhelpers"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
@ -37,7 +37,7 @@ func TestReuseService(t *testing.T) {
|
|||
th.WithRouterMiddlewares("basicauth")),
|
||||
),
|
||||
th.WithMiddlewares(th.WithMiddleware("basicauth",
|
||||
th.WithBasicAuth(&config.BasicAuth{Users: []string{"foo:bar"}}),
|
||||
th.WithBasicAuth(&dynamic.BasicAuth{Users: []string{"foo:bar"}}),
|
||||
)),
|
||||
th.WithLoadBalancerServices(th.WithService("bar",
|
||||
th.WithServers(th.WithServer(testServer.URL))),
|
||||
|
@ -46,7 +46,7 @@ func TestReuseService(t *testing.T) {
|
|||
|
||||
srv := NewServer(staticConfig, nil, entryPoints, nil)
|
||||
|
||||
rtConf := config.NewRuntimeConfig(config.Configuration{HTTP: dynamicConfigs})
|
||||
rtConf := dynamic.NewRuntimeConfig(dynamic.Configuration{HTTP: dynamicConfigs})
|
||||
entrypointsHandlers, _ := srv.createHTTPHandlers(context.Background(), rtConf, []string{"http"})
|
||||
|
||||
// Test that the /ok path returns a status 200.
|
||||
|
@ -67,8 +67,8 @@ func TestReuseService(t *testing.T) {
|
|||
|
||||
func TestThrottleProviderConfigReload(t *testing.T) {
|
||||
throttleDuration := 30 * time.Millisecond
|
||||
publishConfig := make(chan config.Message)
|
||||
providerConfig := make(chan config.Message)
|
||||
publishConfig := make(chan dynamic.Message)
|
||||
providerConfig := make(chan dynamic.Message)
|
||||
stop := make(chan bool)
|
||||
defer func() {
|
||||
stop <- true
|
||||
|
@ -96,7 +96,7 @@ func TestThrottleProviderConfigReload(t *testing.T) {
|
|||
|
||||
// publish 5 new configs, one new config each 10 milliseconds
|
||||
for i := 0; i < 5; i++ {
|
||||
providerConfig <- config.Message{}
|
||||
providerConfig <- dynamic.Message{}
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/containous/traefik/pkg/config"
|
||||
"github.com/containous/traefik/pkg/config/dynamic"
|
||||
"github.com/containous/traefik/pkg/config/static"
|
||||
th "github.com/containous/traefik/pkg/testhelpers"
|
||||
"github.com/containous/traefik/pkg/types"
|
||||
|
@ -29,7 +29,7 @@ func TestListenProvidersSkipsEmptyConfigs(t *testing.T) {
|
|||
}
|
||||
}()
|
||||
|
||||
server.configurationChan <- config.Message{ProviderName: "kubernetes"}
|
||||
server.configurationChan <- dynamic.Message{ProviderName: "kubernetes"}
|
||||
|
||||
// give some time so that the configuration can be processed
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
|
@ -49,7 +49,7 @@ func TestListenProvidersSkipsSameConfigurationForProvider(t *testing.T) {
|
|||
// set the current configuration
|
||||
// this is usually done in the processing part of the published configuration
|
||||
// so we have to emulate the behavior here
|
||||
currentConfigurations := server.currentConfigurations.Get().(config.Configurations)
|
||||
currentConfigurations := server.currentConfigurations.Get().(dynamic.Configurations)
|
||||
currentConfigurations[conf.ProviderName] = conf.Configuration
|
||||
server.currentConfigurations.Set(currentConfigurations)
|
||||
|
||||
|
@ -60,20 +60,20 @@ func TestListenProvidersSkipsSameConfigurationForProvider(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}()
|
||||
conf := &config.Configuration{}
|
||||
conf := &dynamic.Configuration{}
|
||||
conf.HTTP = th.BuildConfiguration(
|
||||
th.WithRouters(th.WithRouter("foo")),
|
||||
th.WithLoadBalancerServices(th.WithService("bar")),
|
||||
)
|
||||
|
||||
// provide a configuration
|
||||
server.configurationChan <- config.Message{ProviderName: "kubernetes", Configuration: conf}
|
||||
server.configurationChan <- dynamic.Message{ProviderName: "kubernetes", Configuration: conf}
|
||||
|
||||
// give some time so that the configuration can be processed
|
||||
time.Sleep(20 * time.Millisecond)
|
||||
|
||||
// provide the same configuration a second time
|
||||
server.configurationChan <- config.Message{ProviderName: "kubernetes", Configuration: conf}
|
||||
server.configurationChan <- dynamic.Message{ProviderName: "kubernetes", Configuration: conf}
|
||||
|
||||
// give some time so that the configuration can be processed
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
|
@ -102,13 +102,13 @@ func TestListenProvidersPublishesConfigForEachProvider(t *testing.T) {
|
|||
}
|
||||
}()
|
||||
|
||||
conf := &config.Configuration{}
|
||||
conf := &dynamic.Configuration{}
|
||||
conf.HTTP = th.BuildConfiguration(
|
||||
th.WithRouters(th.WithRouter("foo")),
|
||||
th.WithLoadBalancerServices(th.WithService("bar")),
|
||||
)
|
||||
server.configurationChan <- config.Message{ProviderName: "kubernetes", Configuration: conf}
|
||||
server.configurationChan <- config.Message{ProviderName: "marathon", Configuration: conf}
|
||||
server.configurationChan <- dynamic.Message{ProviderName: "kubernetes", Configuration: conf}
|
||||
server.configurationChan <- dynamic.Message{ProviderName: "marathon", Configuration: conf}
|
||||
|
||||
select {
|
||||
case <-consumePublishedConfigsDone:
|
||||
|
@ -148,12 +148,12 @@ func TestServerResponseEmptyBackend(t *testing.T) {
|
|||
|
||||
testCases := []struct {
|
||||
desc string
|
||||
config func(testServerURL string) *config.HTTPConfiguration
|
||||
config func(testServerURL string) *dynamic.HTTPConfiguration
|
||||
expectedStatusCode int
|
||||
}{
|
||||
{
|
||||
desc: "Ok",
|
||||
config: func(testServerURL string) *config.HTTPConfiguration {
|
||||
config: func(testServerURL string) *dynamic.HTTPConfiguration {
|
||||
return th.BuildConfiguration(
|
||||
th.WithRouters(th.WithRouter("foo",
|
||||
th.WithEntryPoints("http"),
|
||||
|
@ -169,14 +169,14 @@ func TestServerResponseEmptyBackend(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "No Frontend",
|
||||
config: func(testServerURL string) *config.HTTPConfiguration {
|
||||
config: func(testServerURL string) *dynamic.HTTPConfiguration {
|
||||
return th.BuildConfiguration()
|
||||
},
|
||||
expectedStatusCode: http.StatusNotFound,
|
||||
},
|
||||
{
|
||||
desc: "Empty Backend LB",
|
||||
config: func(testServerURL string) *config.HTTPConfiguration {
|
||||
config: func(testServerURL string) *dynamic.HTTPConfiguration {
|
||||
return th.BuildConfiguration(
|
||||
th.WithRouters(th.WithRouter("foo",
|
||||
th.WithEntryPoints("http"),
|
||||
|
@ -190,7 +190,7 @@ func TestServerResponseEmptyBackend(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Empty Backend LB Sticky",
|
||||
config: func(testServerURL string) *config.HTTPConfiguration {
|
||||
config: func(testServerURL string) *dynamic.HTTPConfiguration {
|
||||
return th.BuildConfiguration(
|
||||
th.WithRouters(th.WithRouter("foo",
|
||||
th.WithEntryPoints("http"),
|
||||
|
@ -206,7 +206,7 @@ func TestServerResponseEmptyBackend(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Empty Backend LB",
|
||||
config: func(testServerURL string) *config.HTTPConfiguration {
|
||||
config: func(testServerURL string) *dynamic.HTTPConfiguration {
|
||||
return th.BuildConfiguration(
|
||||
th.WithRouters(th.WithRouter("foo",
|
||||
th.WithEntryPoints("http"),
|
||||
|
@ -220,7 +220,7 @@ func TestServerResponseEmptyBackend(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "Empty Backend LB Sticky",
|
||||
config: func(testServerURL string) *config.HTTPConfiguration {
|
||||
config: func(testServerURL string) *dynamic.HTTPConfiguration {
|
||||
return th.BuildConfiguration(
|
||||
th.WithRouters(th.WithRouter("foo",
|
||||
th.WithEntryPoints("http"),
|
||||
|
@ -253,7 +253,7 @@ func TestServerResponseEmptyBackend(t *testing.T) {
|
|||
}
|
||||
|
||||
srv := NewServer(globalConfig, nil, entryPointsConfig, nil)
|
||||
rtConf := config.NewRuntimeConfig(config.Configuration{HTTP: test.config(testServer.URL)})
|
||||
rtConf := dynamic.NewRuntimeConfig(dynamic.Configuration{HTTP: test.config(testServer.URL)})
|
||||
entryPoints, _ := srv.createHTTPHandlers(context.Background(), rtConf, []string{"http"})
|
||||
|
||||
responseRecorder := &httptest.ResponseRecorder{}
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"net/url"
|
||||
"time"
|
||||
|
||||
"github.com/containous/traefik/pkg/config"
|
||||
"github.com/containous/traefik/pkg/config/dynamic"
|
||||
"github.com/containous/traefik/pkg/log"
|
||||
"github.com/containous/traefik/pkg/types"
|
||||
)
|
||||
|
@ -21,7 +21,7 @@ const StatusClientClosedRequest = 499
|
|||
// StatusClientClosedRequestText non-standard HTTP status for client disconnection
|
||||
const StatusClientClosedRequestText = "Client Closed Request"
|
||||
|
||||
func buildProxy(passHostHeader bool, responseForwarding *config.ResponseForwarding, defaultRoundTripper http.RoundTripper, bufferPool httputil.BufferPool, responseModifier func(*http.Response) error) (http.Handler, error) {
|
||||
func buildProxy(passHostHeader bool, responseForwarding *dynamic.ResponseForwarding, defaultRoundTripper http.RoundTripper, bufferPool httputil.BufferPool, responseModifier func(*http.Response) error) (http.Handler, error) {
|
||||
var flushInterval types.Duration
|
||||
if responseForwarding != nil {
|
||||
err := flushInterval.Set(responseForwarding.FlushInterval)
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/containous/alice"
|
||||
"github.com/containous/traefik/pkg/config"
|
||||
"github.com/containous/traefik/pkg/config/dynamic"
|
||||
"github.com/containous/traefik/pkg/healthcheck"
|
||||
"github.com/containous/traefik/pkg/log"
|
||||
"github.com/containous/traefik/pkg/middlewares/accesslog"
|
||||
|
@ -26,7 +26,7 @@ const (
|
|||
)
|
||||
|
||||
// NewManager creates a new Manager
|
||||
func NewManager(configs map[string]*config.ServiceInfo, defaultRoundTripper http.RoundTripper) *Manager {
|
||||
func NewManager(configs map[string]*dynamic.ServiceInfo, defaultRoundTripper http.RoundTripper) *Manager {
|
||||
return &Manager{
|
||||
bufferPool: newBufferPool(),
|
||||
defaultRoundTripper: defaultRoundTripper,
|
||||
|
@ -40,7 +40,7 @@ type Manager struct {
|
|||
bufferPool httputil.BufferPool
|
||||
defaultRoundTripper http.RoundTripper
|
||||
balancers map[string][]healthcheck.BalancerHandler
|
||||
configs map[string]*config.ServiceInfo
|
||||
configs map[string]*dynamic.ServiceInfo
|
||||
}
|
||||
|
||||
// BuildHTTP Creates a http.Handler for a service configuration.
|
||||
|
@ -74,7 +74,7 @@ func (m *Manager) BuildHTTP(rootCtx context.Context, serviceName string, respons
|
|||
func (m *Manager) getLoadBalancerServiceHandler(
|
||||
ctx context.Context,
|
||||
serviceName string,
|
||||
service *config.LoadBalancerService,
|
||||
service *dynamic.LoadBalancerService,
|
||||
responseModifier func(*http.Response) error,
|
||||
) (http.Handler, error) {
|
||||
fwd, err := buildProxy(service.PassHostHeader, service.ResponseForwarding, m.defaultRoundTripper, m.bufferPool, responseModifier)
|
||||
|
@ -134,7 +134,7 @@ func (m *Manager) LaunchHealthCheck() {
|
|||
healthcheck.GetHealthCheck().SetBackendsConfiguration(context.TODO(), backendConfigs)
|
||||
}
|
||||
|
||||
func buildHealthCheckOptions(ctx context.Context, lb healthcheck.BalancerHandler, backend string, hc *config.HealthCheck) *healthcheck.Options {
|
||||
func buildHealthCheckOptions(ctx context.Context, lb healthcheck.BalancerHandler, backend string, hc *dynamic.HealthCheck) *healthcheck.Options {
|
||||
if hc == nil || hc.Path == "" {
|
||||
return nil
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ func buildHealthCheckOptions(ctx context.Context, lb healthcheck.BalancerHandler
|
|||
}
|
||||
}
|
||||
|
||||
func (m *Manager) getLoadBalancer(ctx context.Context, serviceName string, service *config.LoadBalancerService, fwd http.Handler) (healthcheck.BalancerHandler, error) {
|
||||
func (m *Manager) getLoadBalancer(ctx context.Context, serviceName string, service *dynamic.LoadBalancerService, fwd http.Handler) (healthcheck.BalancerHandler, error) {
|
||||
logger := log.FromContext(ctx)
|
||||
logger.Debug("Creating load-balancer")
|
||||
|
||||
|
@ -210,7 +210,7 @@ func (m *Manager) getLoadBalancer(ctx context.Context, serviceName string, servi
|
|||
return lb, nil
|
||||
}
|
||||
|
||||
func (m *Manager) upsertServers(ctx context.Context, lb healthcheck.BalancerHandler, servers []config.Server) error {
|
||||
func (m *Manager) upsertServers(ctx context.Context, lb healthcheck.BalancerHandler, servers []dynamic.Server) error {
|
||||
logger := log.FromContext(ctx)
|
||||
|
||||
for name, srv := range servers {
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/containous/traefik/pkg/config"
|
||||
"github.com/containous/traefik/pkg/config/dynamic"
|
||||
"github.com/containous/traefik/pkg/server/internal"
|
||||
"github.com/containous/traefik/pkg/testhelpers"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
@ -26,15 +26,15 @@ func TestGetLoadBalancer(t *testing.T) {
|
|||
testCases := []struct {
|
||||
desc string
|
||||
serviceName string
|
||||
service *config.LoadBalancerService
|
||||
service *dynamic.LoadBalancerService
|
||||
fwd http.Handler
|
||||
expectError bool
|
||||
}{
|
||||
{
|
||||
desc: "Fails when provided an invalid URL",
|
||||
serviceName: "test",
|
||||
service: &config.LoadBalancerService{
|
||||
Servers: []config.Server{
|
||||
service: &dynamic.LoadBalancerService{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: ":",
|
||||
},
|
||||
|
@ -46,15 +46,15 @@ func TestGetLoadBalancer(t *testing.T) {
|
|||
{
|
||||
desc: "Succeeds when there are no servers",
|
||||
serviceName: "test",
|
||||
service: &config.LoadBalancerService{},
|
||||
service: &dynamic.LoadBalancerService{},
|
||||
fwd: &MockForwarder{},
|
||||
expectError: false,
|
||||
},
|
||||
{
|
||||
desc: "Succeeds when stickiness is set",
|
||||
serviceName: "test",
|
||||
service: &config.LoadBalancerService{
|
||||
Stickiness: &config.Stickiness{},
|
||||
service: &dynamic.LoadBalancerService{
|
||||
Stickiness: &dynamic.Stickiness{},
|
||||
},
|
||||
fwd: &MockForwarder{},
|
||||
expectError: false,
|
||||
|
@ -113,7 +113,7 @@ func TestGetLoadBalancerServiceHandler(t *testing.T) {
|
|||
testCases := []struct {
|
||||
desc string
|
||||
serviceName string
|
||||
service *config.LoadBalancerService
|
||||
service *dynamic.LoadBalancerService
|
||||
responseModifier func(*http.Response) error
|
||||
|
||||
expected []ExpectedResult
|
||||
|
@ -121,8 +121,8 @@ func TestGetLoadBalancerServiceHandler(t *testing.T) {
|
|||
{
|
||||
desc: "Load balances between the two servers",
|
||||
serviceName: "test",
|
||||
service: &config.LoadBalancerService{
|
||||
Servers: []config.Server{
|
||||
service: &dynamic.LoadBalancerService{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: server1.URL,
|
||||
},
|
||||
|
@ -145,8 +145,8 @@ func TestGetLoadBalancerServiceHandler(t *testing.T) {
|
|||
{
|
||||
desc: "StatusBadGateway when the server is not reachable",
|
||||
serviceName: "test",
|
||||
service: &config.LoadBalancerService{
|
||||
Servers: []config.Server{
|
||||
service: &dynamic.LoadBalancerService{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://foo",
|
||||
},
|
||||
|
@ -161,8 +161,8 @@ func TestGetLoadBalancerServiceHandler(t *testing.T) {
|
|||
{
|
||||
desc: "ServiceUnavailable when no servers are available",
|
||||
serviceName: "test",
|
||||
service: &config.LoadBalancerService{
|
||||
Servers: []config.Server{},
|
||||
service: &dynamic.LoadBalancerService{
|
||||
Servers: []dynamic.Server{},
|
||||
},
|
||||
expected: []ExpectedResult{
|
||||
{
|
||||
|
@ -173,9 +173,9 @@ func TestGetLoadBalancerServiceHandler(t *testing.T) {
|
|||
{
|
||||
desc: "Always call the same server when stickiness is true",
|
||||
serviceName: "test",
|
||||
service: &config.LoadBalancerService{
|
||||
Stickiness: &config.Stickiness{},
|
||||
Servers: []config.Server{
|
||||
service: &dynamic.LoadBalancerService{
|
||||
Stickiness: &dynamic.Stickiness{},
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: server1.URL,
|
||||
},
|
||||
|
@ -198,9 +198,9 @@ func TestGetLoadBalancerServiceHandler(t *testing.T) {
|
|||
{
|
||||
desc: "Sticky Cookie's options set correctly",
|
||||
serviceName: "test",
|
||||
service: &config.LoadBalancerService{
|
||||
Stickiness: &config.Stickiness{HTTPOnlyCookie: true, SecureCookie: true},
|
||||
Servers: []config.Server{
|
||||
service: &dynamic.LoadBalancerService{
|
||||
Stickiness: &dynamic.Stickiness{HTTPOnlyCookie: true, SecureCookie: true},
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: server1.URL,
|
||||
},
|
||||
|
@ -218,10 +218,10 @@ func TestGetLoadBalancerServiceHandler(t *testing.T) {
|
|||
{
|
||||
desc: "PassHost passes the host instead of the IP",
|
||||
serviceName: "test",
|
||||
service: &config.LoadBalancerService{
|
||||
Stickiness: &config.Stickiness{},
|
||||
service: &dynamic.LoadBalancerService{
|
||||
Stickiness: &dynamic.Stickiness{},
|
||||
PassHostHeader: true,
|
||||
Servers: []config.Server{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: serverPassHost.URL,
|
||||
},
|
||||
|
@ -237,9 +237,9 @@ func TestGetLoadBalancerServiceHandler(t *testing.T) {
|
|||
{
|
||||
desc: "PassHost doesn't passe the host instead of the IP",
|
||||
serviceName: "test",
|
||||
service: &config.LoadBalancerService{
|
||||
Stickiness: &config.Stickiness{},
|
||||
Servers: []config.Server{
|
||||
service: &dynamic.LoadBalancerService{
|
||||
Stickiness: &dynamic.Stickiness{},
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: serverPassHostFalse.URL,
|
||||
},
|
||||
|
@ -287,16 +287,16 @@ func TestManager_Build(t *testing.T) {
|
|||
testCases := []struct {
|
||||
desc string
|
||||
serviceName string
|
||||
configs map[string]*config.ServiceInfo
|
||||
configs map[string]*dynamic.ServiceInfo
|
||||
providerName string
|
||||
}{
|
||||
{
|
||||
desc: "Simple service name",
|
||||
serviceName: "serviceName",
|
||||
configs: map[string]*config.ServiceInfo{
|
||||
configs: map[string]*dynamic.ServiceInfo{
|
||||
"serviceName": {
|
||||
Service: &config.Service{
|
||||
LoadBalancer: &config.LoadBalancerService{},
|
||||
Service: &dynamic.Service{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -304,10 +304,10 @@ func TestManager_Build(t *testing.T) {
|
|||
{
|
||||
desc: "Service name with provider",
|
||||
serviceName: "serviceName@provider-1",
|
||||
configs: map[string]*config.ServiceInfo{
|
||||
configs: map[string]*dynamic.ServiceInfo{
|
||||
"serviceName@provider-1": {
|
||||
Service: &config.Service{
|
||||
LoadBalancer: &config.LoadBalancerService{},
|
||||
Service: &dynamic.Service{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -315,10 +315,10 @@ func TestManager_Build(t *testing.T) {
|
|||
{
|
||||
desc: "Service name with provider in context",
|
||||
serviceName: "serviceName",
|
||||
configs: map[string]*config.ServiceInfo{
|
||||
configs: map[string]*dynamic.ServiceInfo{
|
||||
"serviceName@provider-1": {
|
||||
Service: &config.Service{
|
||||
LoadBalancer: &config.LoadBalancerService{},
|
||||
Service: &dynamic.Service{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"fmt"
|
||||
"net"
|
||||
|
||||
"github.com/containous/traefik/pkg/config"
|
||||
"github.com/containous/traefik/pkg/config/dynamic"
|
||||
"github.com/containous/traefik/pkg/log"
|
||||
"github.com/containous/traefik/pkg/server/internal"
|
||||
"github.com/containous/traefik/pkg/tcp"
|
||||
|
@ -13,11 +13,11 @@ import (
|
|||
|
||||
// Manager is the TCPHandlers factory
|
||||
type Manager struct {
|
||||
configs map[string]*config.TCPServiceInfo
|
||||
configs map[string]*dynamic.TCPServiceInfo
|
||||
}
|
||||
|
||||
// NewManager creates a new manager
|
||||
func NewManager(conf *config.RuntimeConfiguration) *Manager {
|
||||
func NewManager(conf *dynamic.RuntimeConfiguration) *Manager {
|
||||
return &Manager{
|
||||
configs: conf.TCPServices,
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
})
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue