2019-01-18 14:18:04 +00:00
|
|
|
package docker
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"strconv"
|
|
|
|
"testing"
|
2022-11-16 10:38:07 +00:00
|
|
|
"time"
|
2019-01-18 14:18:04 +00:00
|
|
|
|
|
|
|
docker "github.com/docker/docker/api/types"
|
|
|
|
"github.com/docker/docker/api/types/swarm"
|
|
|
|
"github.com/docker/go-connections/nat"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/require"
|
2022-11-16 10:38:07 +00:00
|
|
|
ptypes "github.com/traefik/paerser/types"
|
2023-02-03 14:24:05 +00:00
|
|
|
"github.com/traefik/traefik/v3/pkg/config/dynamic"
|
2024-03-12 09:38:29 +00:00
|
|
|
"github.com/traefik/traefik/v3/pkg/tls"
|
|
|
|
"github.com/traefik/traefik/v3/pkg/types"
|
2019-01-18 14:18:04 +00:00
|
|
|
)
|
|
|
|
|
2023-05-10 13:28:05 +00:00
|
|
|
func TestDynConfBuilder_DefaultRule(t *testing.T) {
|
2019-01-21 18:06:02 +00:00
|
|
|
testCases := []struct {
|
|
|
|
desc string
|
|
|
|
containers []dockerData
|
|
|
|
defaultRule string
|
2019-07-10 07:26:04 +00:00
|
|
|
expected *dynamic.Configuration
|
2019-01-21 18:06:02 +00:00
|
|
|
}{
|
|
|
|
{
|
|
|
|
desc: "default rule with no variable",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-01-30 15:24:07 +00:00
|
|
|
defaultRule: "Host(`foo.bar`)",
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2023-11-21 14:08:06 +00:00
|
|
|
Service: "Test",
|
|
|
|
Rule: "Host(`foo.bar`)",
|
|
|
|
DefaultRule: true,
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-21 14:22:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.1:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2019-01-21 18:06:02 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-21 18:06:02 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-21 18:06:02 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-01-21 18:06:02 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "default rule with service name",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-01-30 15:24:07 +00:00
|
|
|
defaultRule: "Host(`{{ .Name }}.foo.bar`)",
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2023-11-21 14:08:06 +00:00
|
|
|
Service: "Test",
|
|
|
|
Rule: "Host(`Test.foo.bar`)",
|
|
|
|
DefaultRule: true,
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-21 14:22:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.1:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2019-01-21 18:06:02 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-21 18:06:02 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-21 18:06:02 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-01-21 18:06:02 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "default rule with label",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
|
|
|
"traefik.domain": "foo.bar",
|
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-01-30 15:24:07 +00:00
|
|
|
defaultRule: `Host("{{ .Name }}.{{ index .Labels "traefik.domain" }}")`,
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2023-11-21 14:08:06 +00:00
|
|
|
Service: "Test",
|
|
|
|
Rule: `Host("Test.foo.bar")`,
|
|
|
|
DefaultRule: true,
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-21 14:22:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.1:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2019-01-21 18:06:02 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-21 18:06:02 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-21 18:06:02 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-01-21 18:06:02 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "invalid rule",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-01-30 15:24:07 +00:00
|
|
|
defaultRule: `Host("{{ .Toto }}")`,
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-07-10 07:26:04 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-21 14:22:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.1:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2019-01-21 18:06:02 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-21 18:06:02 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-21 18:06:02 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-01-21 18:06:02 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "undefined rule",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
defaultRule: ``,
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-07-10 07:26:04 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-21 14:22:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.1:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2019-01-21 18:06:02 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-21 18:06:02 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-21 18:06:02 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-01-21 18:06:02 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "default template rule",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
defaultRule: DefaultTemplateRule,
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2023-11-21 14:08:06 +00:00
|
|
|
Service: "Test",
|
|
|
|
Rule: "Host(`Test`)",
|
|
|
|
DefaultRule: true,
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-21 14:22:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.1:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2019-01-21 18:06:02 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-21 18:06:02 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-21 18:06:02 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-01-21 18:06:02 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range testCases {
|
|
|
|
test := test
|
|
|
|
t.Run(test.desc, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
p := Provider{
|
2023-05-10 13:28:05 +00:00
|
|
|
Shared: Shared{
|
|
|
|
ExposedByDefault: true,
|
|
|
|
DefaultRule: test.defaultRule,
|
|
|
|
},
|
2019-01-21 18:06:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
err := p.Init()
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2024-02-19 14:44:03 +00:00
|
|
|
for i := range len(test.containers) {
|
2019-01-21 18:06:02 +00:00
|
|
|
var err error
|
2023-05-10 13:28:05 +00:00
|
|
|
test.containers[i].ExtraConf, err = p.extractLabels(test.containers[i])
|
2019-01-21 18:06:02 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
}
|
|
|
|
|
2023-05-10 13:28:05 +00:00
|
|
|
builder := NewDynConfBuilder(p.Shared, nil)
|
|
|
|
|
|
|
|
configuration := builder.build(context.Background(), test.containers)
|
2019-01-21 18:06:02 +00:00
|
|
|
|
2019-03-21 14:22:06 +00:00
|
|
|
assert.Equal(t, test.expected, configuration)
|
2019-01-21 18:06:02 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-10 13:28:05 +00:00
|
|
|
func TestDynConfBuilder_build(t *testing.T) {
|
2019-01-18 14:18:04 +00:00
|
|
|
testCases := []struct {
|
2022-07-06 08:24:08 +00:00
|
|
|
desc string
|
|
|
|
containers []dockerData
|
|
|
|
useBindPortIP bool
|
|
|
|
constraints string
|
|
|
|
expected *dynamic.Configuration
|
|
|
|
allowEmptyServices bool
|
2019-01-18 14:18:04 +00:00
|
|
|
}{
|
2020-01-20 14:28:06 +00:00
|
|
|
{
|
|
|
|
desc: "invalid HTTP service definition",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
|
|
|
"traefik.http.services.test": "",
|
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-01-20 14:28:06 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2020-01-20 14:28:06 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-01-20 14:28:06 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2020-01-20 14:28:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "invalid TCP service definition",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
|
|
|
"traefik.tcp.services.test": "",
|
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-01-20 14:28:06 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2020-01-20 14:28:06 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-01-20 14:28:06 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2020-01-20 14:28:06 +00:00
|
|
|
},
|
|
|
|
},
|
2020-02-20 21:24:05 +00:00
|
|
|
{
|
|
|
|
desc: "invalid UDP service definition",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
|
|
|
"traefik.udp.services.test": "",
|
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/udp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-02-20 21:24:05 +00:00
|
|
|
},
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-02-20 21:24:05 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2020-02-20 21:24:05 +00:00
|
|
|
},
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
{
|
|
|
|
desc: "one container no label",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2023-11-21 14:08:06 +00:00
|
|
|
Service: "Test",
|
|
|
|
Rule: "Host(`Test.traefik.wtf`)",
|
|
|
|
DefaultRule: true,
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-21 14:22:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.1:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "two containers no label",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
ServiceName: "Test2",
|
|
|
|
Name: "Test2",
|
|
|
|
Labels: map[string]string{},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.2",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2023-11-21 14:08:06 +00:00
|
|
|
Service: "Test",
|
|
|
|
Rule: "Host(`Test.traefik.wtf`)",
|
|
|
|
DefaultRule: true,
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
"Test2": {
|
2023-11-21 14:08:06 +00:00
|
|
|
Service: "Test2",
|
|
|
|
Rule: "Host(`Test2.traefik.wtf`)",
|
|
|
|
DefaultRule: true,
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-21 14:22:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.1:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test2": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-21 14:22:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.2:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "two containers with same service name no label",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ID: "1",
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
ID: "2",
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.2",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2023-11-21 14:08:06 +00:00
|
|
|
Service: "Test",
|
|
|
|
Rule: "Host(`Test.traefik.wtf`)",
|
|
|
|
DefaultRule: true,
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-21 14:22:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.1:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.2:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one container with label (not on server)",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
2019-06-05 20:18:06 +00:00
|
|
|
"traefik.http.services.Service1.loadbalancer.passhostheader": "true",
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2023-11-21 14:08:06 +00:00
|
|
|
Service: "Service1",
|
|
|
|
Rule: "Host(`Test.traefik.wtf`)",
|
|
|
|
DefaultRule: true,
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Service1": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-21 14:22:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.1:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one container with labels",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
2019-06-05 20:18:06 +00:00
|
|
|
"traefik.http.services.Service1.loadbalancer.passhostheader": "true",
|
|
|
|
"traefik.http.routers.Router1.rule": "Host(`foo.com`)",
|
|
|
|
"traefik.http.routers.Router1.service": "Service1",
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Router1": {
|
|
|
|
Service: "Service1",
|
|
|
|
Rule: "Host(`foo.com`)",
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Service1": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-21 14:22:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.1:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one container with rule label",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
2019-03-14 08:30:04 +00:00
|
|
|
"traefik.http.routers.Router1.rule": "Host(`foo.com`)",
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-21 14:22:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.1:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Router1": {
|
|
|
|
Service: "Test",
|
|
|
|
Rule: "Host(`foo.com`)",
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one container with rule label and one service",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
2019-06-05 20:18:06 +00:00
|
|
|
"traefik.http.routers.Router1.rule": "Host(`foo.com`)",
|
|
|
|
"traefik.http.services.Service1.loadbalancer.passhostheader": "true",
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Router1": {
|
|
|
|
Service: "Service1",
|
|
|
|
Rule: "Host(`foo.com`)",
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Service1": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-21 14:22:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.1:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one container with rule label and two services",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
2019-06-05 20:18:06 +00:00
|
|
|
"traefik.http.routers.Router1.rule": "Host(`foo.com`)",
|
|
|
|
"traefik.http.services.Service1.loadbalancer.passhostheader": "true",
|
|
|
|
"traefik.http.services.Service2.loadbalancer.passhostheader": "true",
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Service1": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-21 14:22:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.1:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
2019-03-21 14:22:06 +00:00
|
|
|
"Service2": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-21 14:22:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.1:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
2019-09-26 10:48:05 +00:00
|
|
|
{
|
|
|
|
desc: "one router, one specified but undefined service -> specified one is assigned, but automatic is created instead",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
|
|
|
"traefik.http.routers.Router1.rule": "Host(`foo.com`)",
|
|
|
|
"traefik.http.routers.Router1.service": "Service1",
|
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-09-26 10:48:05 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-09-26 10:48:05 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"Router1": {
|
|
|
|
Service: "Service1",
|
|
|
|
Rule: "Host(`foo.com`)",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"Test": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://127.0.0.1:80",
|
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-09-26 10:48:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-09-26 10:48:05 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-09-26 10:48:05 +00:00
|
|
|
},
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
desc: "two containers with same service name and different passhostheader",
|
2019-01-18 14:18:04 +00:00
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ID: "1",
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
2019-06-05 20:18:06 +00:00
|
|
|
"traefik.http.services.Service1.loadbalancer.passhostheader": "true",
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
ID: "2",
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
2019-06-05 20:18:06 +00:00
|
|
|
"traefik.http.services.Service1.loadbalancer.passhostheader": "false",
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.2",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2023-11-21 14:08:06 +00:00
|
|
|
Service: "Service1",
|
|
|
|
Rule: "Host(`Test.traefik.wtf`)",
|
|
|
|
DefaultRule: true,
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
desc: "three containers with same service name and different passhostheader",
|
2019-01-18 14:18:04 +00:00
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ID: "1",
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
2019-06-05 20:18:06 +00:00
|
|
|
"traefik.http.services.Service1.loadbalancer.passhostheader": "false",
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
ID: "2",
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
2019-06-05 20:18:06 +00:00
|
|
|
"traefik.http.services.Service1.loadbalancer.passhostheader": "true",
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.2",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
ID: "3",
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
2019-06-05 20:18:06 +00:00
|
|
|
"traefik.http.services.Service1.loadbalancer.passhostheader": "true",
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.2",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2023-11-21 14:08:06 +00:00
|
|
|
Service: "Service1",
|
|
|
|
Rule: "Host(`Test.traefik.wtf`)",
|
|
|
|
DefaultRule: true,
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "two containers with same service name and same LB methods",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ID: "1",
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
2019-06-05 20:18:06 +00:00
|
|
|
"traefik.http.services.Service1.loadbalancer.passhostheader": "true",
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
ID: "2",
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
2019-06-05 20:18:06 +00:00
|
|
|
"traefik.http.services.Service1.loadbalancer.passhostheader": "true",
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.2",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2023-11-21 14:08:06 +00:00
|
|
|
Service: "Service1",
|
|
|
|
Rule: "Host(`Test.traefik.wtf`)",
|
|
|
|
DefaultRule: true,
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Service1": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-21 14:22:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.1:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.2:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2019-08-26 10:20:06 +00:00
|
|
|
desc: "one container with InFlightReq in label (default value)",
|
2019-01-18 14:18:04 +00:00
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
2019-08-26 10:20:06 +00:00
|
|
|
"traefik.http.middlewares.Middleware1.inflightreq.amount": "42",
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2023-11-21 14:08:06 +00:00
|
|
|
Service: "Test",
|
|
|
|
Rule: "Host(`Test.traefik.wtf`)",
|
|
|
|
DefaultRule: true,
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Services: map[string]*dynamic.Service{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-21 14:22:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.1:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Middleware1": {
|
2019-08-26 10:20:06 +00:00
|
|
|
InFlightReq: &dynamic.InFlightReq{
|
|
|
|
Amount: 42,
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "two containers with two identical middlewares",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ID: "1",
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
2019-08-26 10:20:06 +00:00
|
|
|
"traefik.http.middlewares.Middleware1.inflightreq.amount": "42",
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
ID: "2",
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
2019-08-26 10:20:06 +00:00
|
|
|
"traefik.http.middlewares.Middleware1.inflightreq.amount": "42",
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.2",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2023-11-21 14:08:06 +00:00
|
|
|
Service: "Test",
|
|
|
|
Rule: "Host(`Test.traefik.wtf`)",
|
|
|
|
DefaultRule: true,
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Middleware1": {
|
2019-08-26 10:20:06 +00:00
|
|
|
InFlightReq: &dynamic.InFlightReq{
|
|
|
|
Amount: 42,
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Services: map[string]*dynamic.Service{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-21 14:22:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.1:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.2:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "two containers with two different middlewares with same name",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ID: "1",
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
2019-08-26 10:20:06 +00:00
|
|
|
"traefik.http.middlewares.Middleware1.inflightreq.amount": "42",
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
ID: "2",
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
2019-08-26 10:20:06 +00:00
|
|
|
"traefik.http.middlewares.Middleware1.inflightreq.amount": "41",
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.2",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2023-11-21 14:08:06 +00:00
|
|
|
Service: "Test",
|
|
|
|
Rule: "Host(`Test.traefik.wtf`)",
|
|
|
|
DefaultRule: true,
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-21 14:22:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.1:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.2:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "three containers with different middlewares with same name",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ID: "1",
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
2019-08-26 10:20:06 +00:00
|
|
|
"traefik.http.middlewares.Middleware1.inflightreq.amount": "42",
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
ID: "2",
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
2019-08-26 10:20:06 +00:00
|
|
|
"traefik.http.middlewares.Middleware1.inflightreq.amount": "41",
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.2",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
ID: "3",
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
2019-08-26 10:20:06 +00:00
|
|
|
"traefik.http.middlewares.Middleware1.inflightreq.amount": "40",
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.3",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2023-11-21 14:08:06 +00:00
|
|
|
Service: "Test",
|
|
|
|
Rule: "Host(`Test.traefik.wtf`)",
|
|
|
|
DefaultRule: true,
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-21 14:22:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.1:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.2:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.3:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "two containers with two different routers with same name",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ID: "1",
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
2019-03-14 08:30:04 +00:00
|
|
|
"traefik.http.routers.Router1.rule": "Host(`foo.com`)",
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
ID: "2",
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
2019-03-14 08:30:04 +00:00
|
|
|
"traefik.http.routers.Router1.rule": "Host(`bar.com`)",
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.2",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-21 14:22:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.1:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.2:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "three containers with different routers with same name",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ID: "1",
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
2019-03-14 08:30:04 +00:00
|
|
|
"traefik.http.routers.Router1.rule": "Host(`foo.com`)",
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
ID: "2",
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
2019-03-14 08:30:04 +00:00
|
|
|
"traefik.http.routers.Router1.rule": "Host(`bar.com`)",
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.2",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
ID: "3",
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
2019-03-14 08:30:04 +00:00
|
|
|
"traefik.http.routers.Router1.rule": "Host(`foobar.com`)",
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.3",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-21 14:22:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.1:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.2:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.3:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "two containers with two identical routers",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ID: "1",
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
2019-03-14 08:30:04 +00:00
|
|
|
"traefik.http.routers.Router1.rule": "Host(`foo.com`)",
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
ID: "2",
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
2019-03-14 08:30:04 +00:00
|
|
|
"traefik.http.routers.Router1.rule": "Host(`foo.com`)",
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.2",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Router1": {
|
|
|
|
Service: "Test",
|
|
|
|
Rule: "Host(`foo.com`)",
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-21 14:22:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.1:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.2:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "two containers with two identical router rules and different service names",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
2019-03-14 08:30:04 +00:00
|
|
|
"traefik.http.routers.Router1.rule": "Host(`foo.com`)",
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
ServiceName: "Test2",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
2019-03-14 08:30:04 +00:00
|
|
|
"traefik.http.routers.Router1.rule": "Host(`foo.com`)",
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.2",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-21 14:22:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.1:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test2": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-21 14:22:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.2:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one container with bad label",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
|
|
|
"traefik.wrong.label": "42",
|
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2023-11-21 14:08:06 +00:00
|
|
|
Service: "Test",
|
|
|
|
Rule: "Host(`Test.traefik.wtf`)",
|
|
|
|
DefaultRule: true,
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-21 14:22:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.1:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one container with label port",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
2019-03-14 08:30:04 +00:00
|
|
|
"traefik.http.services.Service1.LoadBalancer.server.scheme": "h2c",
|
|
|
|
"traefik.http.services.Service1.LoadBalancer.server.port": "8080",
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2023-11-21 14:08:06 +00:00
|
|
|
Service: "Service1",
|
|
|
|
Rule: "Host(`Test.traefik.wtf`)",
|
|
|
|
DefaultRule: true,
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Service1": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-21 14:22:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "h2c://127.0.0.1:8080",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one container with label port on two services",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
2019-03-14 08:30:04 +00:00
|
|
|
"traefik.http.services.Service1.LoadBalancer.server.port": "",
|
|
|
|
"traefik.http.services.Service2.LoadBalancer.server.port": "8080",
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Service1": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-21 14:22:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.1:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
2019-03-21 14:22:06 +00:00
|
|
|
"Service2": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-21 14:22:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.1:8080",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one container without port",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one container without port with middleware",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
2019-08-26 10:20:06 +00:00
|
|
|
"traefik.http.middlewares.Middleware1.inflightreq.amount": "42",
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one container with traefik.enable false",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
|
|
|
"traefik.enable": "false",
|
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2022-07-06 08:24:08 +00:00
|
|
|
desc: "one unhealthy HTTP container",
|
2019-01-18 14:18:04 +00:00
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
2022-07-06 08:24:08 +00:00
|
|
|
Health: docker.Unhealthy,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2022-07-06 08:24:08 +00:00
|
|
|
},
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2022-07-06 08:24:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one unhealthy HTTP container with allowEmptyServices",
|
|
|
|
allowEmptyServices: true,
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Health: docker.Unhealthy,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2022-07-06 08:24:08 +00:00
|
|
|
},
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"Test": {
|
2023-11-21 14:08:06 +00:00
|
|
|
Service: "Test",
|
|
|
|
Rule: "Host(`Test.traefik.wtf`)",
|
|
|
|
DefaultRule: true,
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2022-07-06 08:24:08 +00:00
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"Test": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2022-07-06 08:24:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2022-07-06 08:24:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one unhealthy TCP container",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Health: docker.Unhealthy,
|
|
|
|
Labels: map[string]string{
|
|
|
|
"traefik.tcp.routers.foo.rule": "HostSNI(`foo.bar`)",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2022-07-06 08:24:08 +00:00
|
|
|
},
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2022-07-06 08:24:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one unhealthy TCP container with allowEmptyServices",
|
|
|
|
allowEmptyServices: true,
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Health: docker.Unhealthy,
|
|
|
|
Labels: map[string]string{
|
|
|
|
"traefik.tcp.routers.foo.rule": "HostSNI(`foo.bar`)",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
|
|
|
"foo": {
|
|
|
|
Service: "Test",
|
|
|
|
Rule: "HostSNI(`foo.bar`)",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{
|
|
|
|
"Test": {
|
2022-12-09 08:58:05 +00:00
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2022-07-06 08:24:08 +00:00
|
|
|
},
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2022-07-06 08:24:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one unhealthy UDP container",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Health: docker.Unhealthy,
|
|
|
|
Labels: map[string]string{
|
|
|
|
"traefik.udp.routers.foo": "true",
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
2022-07-06 08:24:08 +00:00
|
|
|
{
|
|
|
|
desc: "one unhealthy UDP container with allowEmptyServices",
|
|
|
|
allowEmptyServices: true,
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
|
|
|
"traefik.udp.routers.foo": "true",
|
|
|
|
},
|
|
|
|
Health: docker.Unhealthy,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2022-07-06 08:24:08 +00:00
|
|
|
},
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{
|
|
|
|
"foo": {
|
|
|
|
Service: "Test",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.UDPService{
|
|
|
|
"Test": {
|
|
|
|
LoadBalancer: &dynamic.UDPServersLoadBalancer{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2022-07-06 08:24:08 +00:00
|
|
|
},
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
{
|
|
|
|
desc: "one container with non matching constraints",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
|
|
|
"traefik.tags": "foo",
|
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-06-21 07:24:04 +00:00
|
|
|
constraints: `Label("traefik.tags", "bar")`,
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one container with matching constraints",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
|
|
|
"traefik.tags": "foo",
|
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-06-21 07:24:04 +00:00
|
|
|
constraints: `Label("traefik.tags", "foo")`,
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2023-11-21 14:08:06 +00:00
|
|
|
Service: "Test",
|
|
|
|
Rule: "Host(`Test.traefik.wtf`)",
|
|
|
|
DefaultRule: true,
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-21 14:22:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.1:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Middlewares used in router",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
2019-03-14 08:30:04 +00:00
|
|
|
"traefik.http.middlewares.Middleware1.basicauth.users": "test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/,test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0",
|
|
|
|
"traefik.http.routers.Test.middlewares": "Middleware1",
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
|
|
|
Service: "Test",
|
|
|
|
Rule: "Host(`Test.traefik.wtf`)",
|
|
|
|
Middlewares: []string{"Middleware1"},
|
2023-11-21 14:08:06 +00:00
|
|
|
DefaultRule: true,
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Middleware1": {
|
2019-07-10 07:26:04 +00:00
|
|
|
BasicAuth: &dynamic.BasicAuth{
|
2019-03-21 14:22:06 +00:00
|
|
|
Users: []string{
|
|
|
|
"test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/",
|
|
|
|
"test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Services: map[string]*dynamic.Service{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-21 14:22:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.1:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
{
|
|
|
|
desc: "Middlewares used in TCP router",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
|
|
|
"traefik.tcp.routers.Test.rule": "HostSNI(`foo.bar`)",
|
2022-10-26 15:16:05 +00:00
|
|
|
"traefik.tcp.middlewares.Middleware1.ipallowlist.sourcerange": "foobar, fiibar",
|
2021-06-11 13:30:05 +00:00
|
|
|
"traefik.tcp.routers.Test.middlewares": "Middleware1",
|
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
|
|
|
"Test": {
|
|
|
|
Service: "Test",
|
|
|
|
Rule: "HostSNI(`foo.bar`)",
|
|
|
|
Middlewares: []string{"Middleware1"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{
|
|
|
|
"Middleware1": {
|
2022-10-26 15:16:05 +00:00
|
|
|
IPAllowList: &dynamic.TCPIPAllowList{
|
2021-06-11 13:30:05 +00:00
|
|
|
SourceRange: []string{"foobar", "fiibar"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.TCPService{
|
|
|
|
"Test": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "127.0.0.1:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-06-11 13:30:05 +00:00
|
|
|
},
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-06-11 13:30:05 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
},
|
|
|
|
},
|
2019-03-21 14:22:06 +00:00
|
|
|
{
|
|
|
|
desc: "tcp with label",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
|
|
|
"traefik.tcp.routers.foo.rule": "HostSNI(`foo.bar`)",
|
|
|
|
"traefik.tcp.routers.foo.tls": "true",
|
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2019-03-21 14:22:06 +00:00
|
|
|
"foo": {
|
|
|
|
Service: "Test",
|
|
|
|
Rule: "HostSNI(`foo.bar`)",
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2019-07-10 07:26:04 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2019-09-13 18:00:06 +00:00
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.TCPServer{
|
2019-03-21 14:22:06 +00:00
|
|
|
{
|
|
|
|
Address: "127.0.0.1:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
},
|
2020-02-20 21:24:05 +00:00
|
|
|
{
|
|
|
|
desc: "udp with label",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
|
|
|
"traefik.udp.routers.foo.entrypoints": "mydns",
|
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{
|
|
|
|
"foo": {
|
|
|
|
Service: "Test",
|
|
|
|
EntryPoints: []string{"mydns"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.UDPService{
|
|
|
|
"Test": {
|
|
|
|
LoadBalancer: &dynamic.UDPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.UDPServer{
|
|
|
|
{
|
|
|
|
Address: "127.0.0.1:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-02-20 21:24:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-02-20 21:24:05 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2020-02-20 21:24:05 +00:00
|
|
|
},
|
|
|
|
},
|
2019-03-21 14:22:06 +00:00
|
|
|
{
|
|
|
|
desc: "tcp with label without rule",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
|
|
|
"traefik.tcp.routers.foo.tls": "true",
|
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2021-06-11 13:30:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2019-07-10 07:26:04 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2019-09-13 18:00:06 +00:00
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.TCPServer{
|
2019-03-21 14:22:06 +00:00
|
|
|
{
|
|
|
|
Address: "127.0.0.1:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "tcp with label and port",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
|
|
|
"traefik.tcp.routers.foo.rule": "HostSNI(`foo.bar`)",
|
2019-06-17 16:14:08 +00:00
|
|
|
"traefik.tcp.routers.foo.tls.options": "foo",
|
2019-03-21 14:22:06 +00:00
|
|
|
"traefik.tcp.services.foo.loadbalancer.server.port": "8080",
|
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2019-03-21 14:22:06 +00:00
|
|
|
"foo": {
|
|
|
|
Service: "foo",
|
|
|
|
Rule: "HostSNI(`foo.bar`)",
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{
|
2019-06-17 16:14:08 +00:00
|
|
|
Options: "foo",
|
|
|
|
},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2019-07-10 07:26:04 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2019-03-21 14:22:06 +00:00
|
|
|
"foo": {
|
2019-09-13 18:00:06 +00:00
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.TCPServer{
|
2019-03-21 14:22:06 +00:00
|
|
|
{
|
|
|
|
Address: "127.0.0.1:8080",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2020-02-20 21:24:05 +00:00
|
|
|
desc: "udp with label and port",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
|
|
|
"traefik.udp.routers.foo.entrypoints": "mydns",
|
|
|
|
"traefik.udp.services.foo.loadbalancer.server.port": "8080",
|
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{
|
|
|
|
"foo": {
|
|
|
|
Service: "foo",
|
|
|
|
EntryPoints: []string{"mydns"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.UDPService{
|
|
|
|
"foo": {
|
|
|
|
LoadBalancer: &dynamic.UDPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.UDPServer{
|
|
|
|
{
|
|
|
|
Address: "127.0.0.1:8080",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-02-20 21:24:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-02-20 21:24:05 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2020-02-20 21:24:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "udp with label and port and http service",
|
2019-03-21 14:22:06 +00:00
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
2020-02-20 21:24:05 +00:00
|
|
|
"traefik.udp.routers.foo.entrypoints": "mydns",
|
|
|
|
"traefik.udp.services.foo.loadbalancer.server.port": "8080",
|
2019-06-05 20:18:06 +00:00
|
|
|
"traefik.http.services.Service1.loadbalancer.passhostheader": "true",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
ID: "2",
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
2020-02-20 21:24:05 +00:00
|
|
|
"traefik.udp.routers.foo.entrypoints": "mydns",
|
|
|
|
"traefik.udp.services.foo.loadbalancer.server.port": "8080",
|
2019-06-05 20:18:06 +00:00
|
|
|
"traefik.http.services.Service1.loadbalancer.passhostheader": "true",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.2",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
2020-02-20 21:24:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{
|
2019-03-21 14:22:06 +00:00
|
|
|
"foo": {
|
2020-02-20 21:24:05 +00:00
|
|
|
Service: "foo",
|
|
|
|
EntryPoints: []string{"mydns"},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
},
|
2020-02-20 21:24:05 +00:00
|
|
|
Services: map[string]*dynamic.UDPService{
|
2019-03-21 14:22:06 +00:00
|
|
|
"foo": {
|
2020-02-20 21:24:05 +00:00
|
|
|
LoadBalancer: &dynamic.UDPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.UDPServer{
|
2019-03-21 14:22:06 +00:00
|
|
|
{
|
|
|
|
Address: "127.0.0.1:8080",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "127.0.0.2:8080",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-02-20 21:24:05 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-02-11 00:26:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Test": {
|
2023-11-21 14:08:06 +00:00
|
|
|
Service: "Service1",
|
|
|
|
Rule: "Host(`Test.traefik.wtf`)",
|
|
|
|
DefaultRule: true,
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-03-21 14:22:06 +00:00
|
|
|
"Service1": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-21 14:22:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.1:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://127.0.0.2:80",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2020-02-20 21:24:05 +00:00
|
|
|
desc: "udp with label for tcp service",
|
2019-03-21 14:22:06 +00:00
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
2020-02-20 21:24:05 +00:00
|
|
|
"traefik.udp.services.foo.loadbalancer.server.port": "8080",
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
2020-02-20 21:24:05 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{
|
2019-03-21 14:22:06 +00:00
|
|
|
"foo": {
|
2020-02-20 21:24:05 +00:00
|
|
|
LoadBalancer: &dynamic.UDPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.UDPServer{
|
2019-03-21 14:22:06 +00:00
|
|
|
{
|
|
|
|
Address: "127.0.0.1:8080",
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2019-09-13 15:46:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-02-20 21:24:05 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-02-11 00:26:04 +00:00
|
|
|
},
|
2019-09-13 15:46:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-09-13 15:46:04 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-09-13 15:46:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2022-12-09 08:58:05 +00:00
|
|
|
// TODO: replace or delete?
|
2019-09-13 15:46:04 +00:00
|
|
|
desc: "tcp with label for tcp service, with termination delay",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
2022-12-09 08:58:05 +00:00
|
|
|
"traefik.tcp.services.foo.loadbalancer.server.port": "8080",
|
2019-09-13 15:46:04 +00:00
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2021-06-11 13:30:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2019-09-13 15:46:04 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
|
|
|
"foo": {
|
2019-09-13 18:00:06 +00:00
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
2019-09-13 15:46:04 +00:00
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "127.0.0.1:8080",
|
|
|
|
},
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2019-03-21 14:22:06 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
2020-01-20 14:56:05 +00:00
|
|
|
{
|
|
|
|
desc: "useBindPortIP with LblPort | ExtIp:ExtPort:LblPort => ExtIp:ExtPort",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
|
|
|
"traefik.http.services.Test.loadbalancer.server.port": "80",
|
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("79/tcp"): []nat.PortBinding{{
|
|
|
|
HostIP: "192.168.0.1",
|
|
|
|
HostPort: "8080",
|
|
|
|
}},
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{{
|
|
|
|
HostIP: "192.168.0.1",
|
|
|
|
HostPort: "8081",
|
|
|
|
}},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
useBindPortIP: true,
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-01-20 14:56:05 +00:00
|
|
|
},
|
2020-02-11 00:26:04 +00:00
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
2020-01-20 14:56:05 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"Test": {
|
2023-11-21 14:08:06 +00:00
|
|
|
Service: "Test",
|
|
|
|
Rule: "Host(`Test.traefik.wtf`)",
|
|
|
|
DefaultRule: true,
|
2020-01-20 14:56:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"Test": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://192.168.0.1:8081",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2020-01-20 14:56:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-01-20 14:56:05 +00:00
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one container with default generated certificate labels",
|
|
|
|
containers: []dockerData{
|
|
|
|
{
|
|
|
|
ServiceName: "Test",
|
|
|
|
Name: "Test",
|
|
|
|
Labels: map[string]string{
|
|
|
|
"traefik.tls.stores.default.defaultgeneratedcert.resolver": "foobar",
|
|
|
|
"traefik.tls.stores.default.defaultgeneratedcert.domain.main": "foobar",
|
|
|
|
"traefik.tls.stores.default.defaultgeneratedcert.domain.sans": "foobar, fiibar",
|
|
|
|
},
|
|
|
|
NetworkSettings: networkSettings{
|
|
|
|
Ports: nat.PortMap{
|
|
|
|
nat.Port("79/tcp"): []nat.PortBinding{{
|
|
|
|
HostIP: "192.168.0.1",
|
|
|
|
HostPort: "8080",
|
|
|
|
}},
|
|
|
|
nat.Port("80/tcp"): []nat.PortBinding{{
|
|
|
|
HostIP: "192.168.0.1",
|
|
|
|
HostPort: "8081",
|
|
|
|
}},
|
|
|
|
},
|
|
|
|
Networks: map[string]*networkData{
|
|
|
|
"bridge": {
|
|
|
|
Name: "bridge",
|
|
|
|
Addr: "127.0.0.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"Test": {
|
|
|
|
Service: "Test",
|
|
|
|
Rule: "Host(`Test.traefik.wtf`)",
|
|
|
|
DefaultRule: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"Test": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://127.0.0.1:79",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: Bool(true),
|
2024-03-12 09:38:29 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2024-02-26 09:02:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2024-03-12 09:38:29 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2024-02-26 09:02:06 +00:00
|
|
|
},
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Stores: map[string]tls.Store{
|
|
|
|
"default": {
|
|
|
|
DefaultGeneratedCert: &tls.GeneratedCert{
|
|
|
|
Resolver: "foobar",
|
|
|
|
Domain: &types.Domain{
|
|
|
|
Main: "foobar",
|
|
|
|
SANs: []string{"foobar", "fiibar"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-01-20 14:56:05 +00:00
|
|
|
},
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range testCases {
|
|
|
|
test := test
|
|
|
|
|
|
|
|
t.Run(test.desc, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
p := Provider{
|
2023-05-10 13:28:05 +00:00
|
|
|
Shared: Shared{
|
|
|
|
AllowEmptyServices: test.allowEmptyServices,
|
|
|
|
ExposedByDefault: true,
|
|
|
|
UseBindPortIP: test.useBindPortIP,
|
|
|
|
DefaultRule: "Host(`{{ normalize .Name }}.traefik.wtf`)",
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
}
|
|
|
|
p.Constraints = test.constraints
|
|
|
|
|
2019-01-21 18:06:02 +00:00
|
|
|
err := p.Init()
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2024-02-19 14:44:03 +00:00
|
|
|
for i := range len(test.containers) {
|
2019-01-18 14:18:04 +00:00
|
|
|
var err error
|
2023-05-10 13:28:05 +00:00
|
|
|
test.containers[i].ExtraConf, err = p.extractLabels(test.containers[i])
|
2019-01-18 14:18:04 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
}
|
|
|
|
|
2023-05-10 13:28:05 +00:00
|
|
|
builder := NewDynConfBuilder(p.Shared, nil)
|
|
|
|
|
|
|
|
configuration := builder.build(context.Background(), test.containers)
|
2019-01-18 14:18:04 +00:00
|
|
|
|
2019-03-21 14:22:06 +00:00
|
|
|
assert.Equal(t, test.expected, configuration)
|
2019-01-18 14:18:04 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-10 13:28:05 +00:00
|
|
|
func TestDynConfBuilder_getIPPort_docker(t *testing.T) {
|
2019-01-18 14:18:04 +00:00
|
|
|
type expected struct {
|
|
|
|
ip string
|
|
|
|
port string
|
|
|
|
error bool
|
|
|
|
}
|
|
|
|
|
|
|
|
testCases := []struct {
|
|
|
|
desc string
|
|
|
|
container docker.ContainerJSON
|
|
|
|
serverPort string
|
|
|
|
expected expected
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
desc: "label traefik.port not set, no binding, falling back on the container's IP/Port",
|
|
|
|
container: containerJSON(
|
|
|
|
ports(nat.PortMap{
|
|
|
|
"8080/tcp": {},
|
|
|
|
}),
|
|
|
|
withNetwork("testnet", ipv4("10.11.12.13"))),
|
|
|
|
expected: expected{
|
|
|
|
ip: "10.11.12.13",
|
|
|
|
port: "8080",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "label traefik.port not set, single binding with port only, falling back on the container's IP/Port",
|
|
|
|
container: containerJSON(
|
|
|
|
withNetwork("testnet", ipv4("10.11.12.13")),
|
|
|
|
ports(nat.PortMap{
|
|
|
|
"80/tcp": []nat.PortBinding{
|
|
|
|
{
|
|
|
|
HostPort: "8082",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
),
|
|
|
|
expected: expected{
|
|
|
|
ip: "10.11.12.13",
|
|
|
|
port: "80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "label traefik.port not set, binding with ip:port should create a route to the bound ip:port",
|
|
|
|
container: containerJSON(
|
|
|
|
ports(nat.PortMap{
|
|
|
|
"80/tcp": []nat.PortBinding{
|
|
|
|
{
|
|
|
|
HostIP: "1.2.3.4",
|
|
|
|
HostPort: "8081",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
withNetwork("testnet", ipv4("10.11.12.13"))),
|
|
|
|
expected: expected{
|
|
|
|
ip: "1.2.3.4",
|
|
|
|
port: "8081",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "label traefik.port set, no binding, falling back on the container's IP/traefik.port",
|
|
|
|
container: containerJSON(withNetwork("testnet", ipv4("10.11.12.13"))),
|
|
|
|
serverPort: "80",
|
|
|
|
expected: expected{
|
|
|
|
ip: "10.11.12.13",
|
|
|
|
port: "80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "label traefik.port set, single binding with ip:port for the label, creates the route",
|
|
|
|
container: containerJSON(
|
|
|
|
ports(nat.PortMap{
|
|
|
|
"443/tcp": []nat.PortBinding{
|
|
|
|
{
|
|
|
|
HostIP: "5.6.7.8",
|
|
|
|
HostPort: "8082",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
withNetwork("testnet", ipv4("10.11.12.13"))),
|
|
|
|
serverPort: "443",
|
|
|
|
expected: expected{
|
|
|
|
ip: "5.6.7.8",
|
|
|
|
port: "8082",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "label traefik.port set, no binding on the corresponding port, falling back on the container's IP/label.port",
|
|
|
|
container: containerJSON(
|
|
|
|
ports(nat.PortMap{
|
|
|
|
"443/tcp": []nat.PortBinding{
|
|
|
|
{
|
|
|
|
HostIP: "5.6.7.8",
|
|
|
|
HostPort: "8082",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
withNetwork("testnet", ipv4("10.11.12.13"))),
|
|
|
|
serverPort: "80",
|
|
|
|
expected: expected{
|
|
|
|
ip: "10.11.12.13",
|
|
|
|
port: "80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "label traefik.port set, multiple bindings on different ports, uses the label to select the correct (first) binding",
|
|
|
|
container: containerJSON(
|
|
|
|
ports(nat.PortMap{
|
|
|
|
"80/tcp": []nat.PortBinding{
|
|
|
|
{
|
|
|
|
HostIP: "1.2.3.4",
|
|
|
|
HostPort: "8081",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"443/tcp": []nat.PortBinding{
|
|
|
|
{
|
|
|
|
HostIP: "5.6.7.8",
|
|
|
|
HostPort: "8082",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
withNetwork("testnet", ipv4("10.11.12.13"))),
|
|
|
|
serverPort: "80",
|
|
|
|
expected: expected{
|
|
|
|
ip: "1.2.3.4",
|
|
|
|
port: "8081",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "label traefik.port set, multiple bindings on different ports, uses the label to select the correct (second) binding",
|
|
|
|
container: containerJSON(
|
|
|
|
ports(nat.PortMap{
|
|
|
|
"80/tcp": []nat.PortBinding{
|
|
|
|
{
|
|
|
|
HostIP: "1.2.3.4",
|
|
|
|
HostPort: "8081",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"443/tcp": []nat.PortBinding{
|
|
|
|
{
|
|
|
|
HostIP: "5.6.7.8",
|
|
|
|
HostPort: "8082",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
withNetwork("testnet", ipv4("10.11.12.13"))),
|
|
|
|
serverPort: "443",
|
|
|
|
expected: expected{
|
|
|
|
ip: "5.6.7.8",
|
|
|
|
port: "8082",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range testCases {
|
|
|
|
test := test
|
|
|
|
t.Run(test.desc, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
dData := parseContainer(test.container)
|
|
|
|
|
2023-05-10 13:28:05 +00:00
|
|
|
builder := NewDynConfBuilder(Shared{
|
2019-01-18 14:18:04 +00:00
|
|
|
Network: "testnet",
|
|
|
|
UseBindPortIP: true,
|
2023-05-10 13:28:05 +00:00
|
|
|
}, nil)
|
2019-01-18 14:18:04 +00:00
|
|
|
|
2023-05-10 13:28:05 +00:00
|
|
|
actualIP, actualPort, actualError := builder.getIPPort(context.Background(), dData, test.serverPort)
|
2019-01-18 14:18:04 +00:00
|
|
|
if test.expected.error {
|
|
|
|
require.Error(t, actualError)
|
|
|
|
} else {
|
|
|
|
require.NoError(t, actualError)
|
|
|
|
}
|
|
|
|
assert.Equal(t, test.expected.ip, actualIP)
|
|
|
|
assert.Equal(t, test.expected.port, actualPort)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-10 13:28:05 +00:00
|
|
|
func TestDynConfBuilder_getIPAddress_docker(t *testing.T) {
|
2019-01-18 14:18:04 +00:00
|
|
|
testCases := []struct {
|
|
|
|
desc string
|
|
|
|
container docker.ContainerJSON
|
|
|
|
network string
|
|
|
|
expected string
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
desc: "one network, no network label",
|
|
|
|
container: containerJSON(withNetwork("testnet", ipv4("10.11.12.13"))),
|
|
|
|
expected: "10.11.12.13",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "one network, network label",
|
|
|
|
container: containerJSON(
|
|
|
|
withNetwork("testnet", ipv4("10.11.12.13")),
|
|
|
|
),
|
|
|
|
network: "testnet",
|
|
|
|
expected: "10.11.12.13",
|
|
|
|
},
|
2022-09-08 09:20:09 +00:00
|
|
|
{
|
|
|
|
desc: "one ipv6 network, network label",
|
|
|
|
container: containerJSON(
|
|
|
|
withNetwork("testnet", ipv6("fd00:1:2:3:4::")),
|
|
|
|
),
|
|
|
|
network: "testnet",
|
|
|
|
expected: "fd00:1:2:3:4::",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "two network ipv4 + ipv6, network label",
|
|
|
|
container: containerJSON(
|
|
|
|
withNetwork("testnet", ipv4("10.11.12.13"), ipv6("fd00:1:2:3:4::")),
|
|
|
|
),
|
|
|
|
network: "testnet",
|
|
|
|
expected: "10.11.12.13",
|
|
|
|
},
|
2019-01-18 14:18:04 +00:00
|
|
|
{
|
|
|
|
desc: "two networks, network label",
|
|
|
|
container: containerJSON(
|
|
|
|
withNetwork("testnet", ipv4("10.11.12.13")),
|
|
|
|
withNetwork("testnet2", ipv4("10.11.12.14")),
|
|
|
|
),
|
|
|
|
network: "testnet2",
|
|
|
|
expected: "10.11.12.14",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "two networks, no network label, mode host",
|
|
|
|
container: containerJSON(
|
|
|
|
networkMode("host"),
|
|
|
|
withNetwork("testnet", ipv4("10.11.12.13")),
|
|
|
|
withNetwork("testnet2", ipv4("10.11.12.14")),
|
|
|
|
),
|
|
|
|
expected: "127.0.0.1",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "two networks, no network label, mode host, use provider network",
|
|
|
|
container: containerJSON(
|
|
|
|
networkMode("host"),
|
|
|
|
withNetwork("testnet", ipv4("10.11.12.13")),
|
|
|
|
withNetwork("webnet", ipv4("10.11.12.14")),
|
|
|
|
),
|
|
|
|
expected: "10.11.12.14",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "two networks, network label",
|
|
|
|
container: containerJSON(
|
|
|
|
withNetwork("testnet", ipv4("10.11.12.13")),
|
|
|
|
withNetwork("webnet", ipv4("10.11.12.14")),
|
|
|
|
),
|
|
|
|
network: "testnet",
|
|
|
|
expected: "10.11.12.13",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "no network, no network label, mode host",
|
|
|
|
container: containerJSON(
|
|
|
|
networkMode("host"),
|
|
|
|
),
|
|
|
|
expected: "127.0.0.1",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "no network, no network label, mode host, node IP",
|
|
|
|
container: containerJSON(
|
|
|
|
networkMode("host"),
|
|
|
|
nodeIP("10.0.0.5"),
|
|
|
|
),
|
|
|
|
expected: "10.0.0.5",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range testCases {
|
|
|
|
test := test
|
|
|
|
t.Run(test.desc, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
2023-05-10 13:28:05 +00:00
|
|
|
conf := Shared{
|
2019-01-18 14:18:04 +00:00
|
|
|
Network: "webnet",
|
|
|
|
}
|
|
|
|
|
|
|
|
dData := parseContainer(test.container)
|
|
|
|
|
2023-05-10 13:28:05 +00:00
|
|
|
dData.ExtraConf.Docker.Network = conf.Network
|
2019-01-18 14:18:04 +00:00
|
|
|
if len(test.network) > 0 {
|
|
|
|
dData.ExtraConf.Docker.Network = test.network
|
|
|
|
}
|
|
|
|
|
2023-05-10 13:28:05 +00:00
|
|
|
builder := NewDynConfBuilder(conf, nil)
|
|
|
|
|
|
|
|
actual := builder.getIPAddress(context.Background(), dData)
|
2019-01-18 14:18:04 +00:00
|
|
|
assert.Equal(t, test.expected, actual)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-10 13:28:05 +00:00
|
|
|
func TestDynConfBuilder_getIPAddress_swarm(t *testing.T) {
|
2019-01-18 14:18:04 +00:00
|
|
|
testCases := []struct {
|
|
|
|
service swarm.Service
|
|
|
|
expected string
|
|
|
|
networks map[string]*docker.NetworkResource
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
service: swarmService(withEndpointSpec(modeDNSSR)),
|
|
|
|
expected: "",
|
|
|
|
networks: map[string]*docker.NetworkResource{},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
service: swarmService(
|
|
|
|
withEndpointSpec(modeVIP),
|
|
|
|
withEndpoint(virtualIP("1", "10.11.12.13/24")),
|
|
|
|
),
|
|
|
|
expected: "10.11.12.13",
|
|
|
|
networks: map[string]*docker.NetworkResource{
|
|
|
|
"1": {
|
|
|
|
Name: "foo",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
service: swarmService(
|
|
|
|
serviceLabels(map[string]string{
|
|
|
|
"traefik.docker.network": "barnet",
|
|
|
|
}),
|
|
|
|
withEndpointSpec(modeVIP),
|
|
|
|
withEndpoint(
|
|
|
|
virtualIP("1", "10.11.12.13/24"),
|
|
|
|
virtualIP("2", "10.11.12.99/24"),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
expected: "10.11.12.99",
|
|
|
|
networks: map[string]*docker.NetworkResource{
|
|
|
|
"1": {
|
|
|
|
Name: "foonet",
|
|
|
|
},
|
|
|
|
"2": {
|
|
|
|
Name: "barnet",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for serviceID, test := range testCases {
|
|
|
|
test := test
|
|
|
|
t.Run(strconv.Itoa(serviceID), func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
2023-05-10 13:28:05 +00:00
|
|
|
p := &SwarmProvider{}
|
2019-01-18 14:18:04 +00:00
|
|
|
|
|
|
|
dData, err := p.parseService(context.Background(), test.service, test.networks)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2023-05-10 13:28:05 +00:00
|
|
|
builder := NewDynConfBuilder(p.Shared, nil)
|
|
|
|
actual := builder.getIPAddress(context.Background(), dData)
|
2019-01-18 14:18:04 +00:00
|
|
|
assert.Equal(t, test.expected, actual)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2022-07-06 08:24:08 +00:00
|
|
|
|
|
|
|
func Int(v int) *int { return &v }
|
|
|
|
|
|
|
|
func Bool(v bool) *bool { return &v }
|