2019-01-15 13:28:04 +00:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
2019-03-15 08:42:03 +00:00
|
|
|
"github.com/containous/traefik/pkg/config"
|
|
|
|
"github.com/containous/traefik/pkg/server/internal"
|
|
|
|
"github.com/containous/traefik/pkg/tls"
|
2019-01-15 13:28:04 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func mergeConfiguration(configurations config.Configurations) config.Configuration {
|
|
|
|
conf := config.Configuration{
|
2019-03-14 08:30:04 +00:00
|
|
|
HTTP: &config.HTTPConfiguration{
|
|
|
|
Routers: make(map[string]*config.Router),
|
|
|
|
Middlewares: make(map[string]*config.Middleware),
|
|
|
|
Services: make(map[string]*config.Service),
|
|
|
|
},
|
|
|
|
TCP: &config.TCPConfiguration{
|
|
|
|
Routers: make(map[string]*config.TCPRouter),
|
|
|
|
Services: make(map[string]*config.TCPService),
|
|
|
|
},
|
|
|
|
TLSOptions: make(map[string]tls.TLS),
|
|
|
|
TLSStores: make(map[string]tls.Store),
|
2019-01-15 13:28:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for provider, configuration := range configurations {
|
2019-03-14 08:30:04 +00:00
|
|
|
if configuration.HTTP != nil {
|
|
|
|
for routerName, router := range configuration.HTTP.Routers {
|
|
|
|
conf.HTTP.Routers[internal.MakeQualifiedName(provider, routerName)] = router
|
|
|
|
}
|
|
|
|
for middlewareName, middleware := range configuration.HTTP.Middlewares {
|
|
|
|
conf.HTTP.Middlewares[internal.MakeQualifiedName(provider, middlewareName)] = middleware
|
|
|
|
}
|
|
|
|
for serviceName, service := range configuration.HTTP.Services {
|
|
|
|
conf.HTTP.Services[internal.MakeQualifiedName(provider, serviceName)] = service
|
|
|
|
}
|
2019-01-15 13:28:04 +00:00
|
|
|
}
|
2019-03-14 08:30:04 +00:00
|
|
|
|
|
|
|
if configuration.TCP != nil {
|
|
|
|
for routerName, router := range configuration.TCP.Routers {
|
|
|
|
conf.TCP.Routers[internal.MakeQualifiedName(provider, routerName)] = router
|
|
|
|
}
|
|
|
|
for serviceName, service := range configuration.TCP.Services {
|
|
|
|
conf.TCP.Services[internal.MakeQualifiedName(provider, serviceName)] = service
|
|
|
|
}
|
2019-01-15 13:28:04 +00:00
|
|
|
}
|
|
|
|
conf.TLS = append(conf.TLS, configuration.TLS...)
|
2019-03-14 08:30:04 +00:00
|
|
|
|
|
|
|
for key, store := range configuration.TLSStores {
|
|
|
|
conf.TLSStores[key] = store
|
|
|
|
}
|
|
|
|
|
|
|
|
for key, config := range configuration.TLSOptions {
|
|
|
|
conf.TLSOptions[key] = config
|
|
|
|
}
|
2019-01-15 13:28:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return conf
|
|
|
|
}
|