New rule syntax
Co-authored-by: jbdoumenjou <jb.doumenjou@gmail.com>
This commit is contained in:
parent
7155f0d50d
commit
9ebe3c38b2
89 changed files with 1111 additions and 1357 deletions
|
@ -357,9 +357,7 @@ func (p *Provider) watchNewDomains(ctx context.Context) {
|
|||
for routerName, route := range config.Routers {
|
||||
logger := log.FromContext(ctx).WithField(log.RouterName, routerName)
|
||||
|
||||
// FIXME use new rule system
|
||||
domainRules := rules.Rules{}
|
||||
domains, err := domainRules.ParseDomains(route.Rule)
|
||||
domains, err := rules.ParseDomains(route.Rule)
|
||||
if err != nil {
|
||||
logger.Errorf("Error parsing domains in provider ACME: %v", err)
|
||||
continue
|
||||
|
|
|
@ -41,12 +41,12 @@ func TestDefaultRule(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
defaultRule: "Host:foo.bar",
|
||||
defaultRule: "Host(`foo.bar`)",
|
||||
expected: &config.Configuration{
|
||||
Routers: map[string]*config.Router{
|
||||
"Test": {
|
||||
Service: "Test",
|
||||
Rule: "Host:foo.bar",
|
||||
Rule: "Host(`foo.bar`)",
|
||||
},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
|
@ -86,12 +86,12 @@ func TestDefaultRule(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
defaultRule: "Host:{{ .Name }}.foo.bar",
|
||||
defaultRule: "Host(`{{ .Name }}.foo.bar`)",
|
||||
expected: &config.Configuration{
|
||||
Routers: map[string]*config.Router{
|
||||
"Test": {
|
||||
Service: "Test",
|
||||
Rule: "Host:Test.foo.bar",
|
||||
Rule: "Host(`Test.foo.bar`)",
|
||||
},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
|
@ -133,12 +133,12 @@ func TestDefaultRule(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
defaultRule: `Host:{{ .Name }}.{{ index .Labels "traefik.domain" }}`,
|
||||
defaultRule: `Host("{{ .Name }}.{{ index .Labels "traefik.domain" }}")`,
|
||||
expected: &config.Configuration{
|
||||
Routers: map[string]*config.Router{
|
||||
"Test": {
|
||||
Service: "Test",
|
||||
Rule: "Host:Test.foo.bar",
|
||||
Rule: `Host("Test.foo.bar")`,
|
||||
},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
|
@ -178,7 +178,7 @@ func TestDefaultRule(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
defaultRule: `Host:{{ .Toto }}`,
|
||||
defaultRule: `Host("{{ .Toto }}")`,
|
||||
expected: &config.Configuration{
|
||||
Routers: map[string]*config.Router{},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
|
@ -263,7 +263,7 @@ func TestDefaultRule(t *testing.T) {
|
|||
Routers: map[string]*config.Router{
|
||||
"Test": {
|
||||
Service: "Test",
|
||||
Rule: "Host:Test",
|
||||
Rule: "Host(`Test`)",
|
||||
},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
|
@ -343,7 +343,7 @@ func Test_buildConfiguration(t *testing.T) {
|
|||
Routers: map[string]*config.Router{
|
||||
"Test": {
|
||||
Service: "Test",
|
||||
Rule: "Host:Test.traefik.wtf",
|
||||
Rule: "Host(`Test.traefik.wtf`)",
|
||||
},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
|
@ -403,11 +403,11 @@ func Test_buildConfiguration(t *testing.T) {
|
|||
Routers: map[string]*config.Router{
|
||||
"Test": {
|
||||
Service: "Test",
|
||||
Rule: "Host:Test.traefik.wtf",
|
||||
Rule: "Host(`Test.traefik.wtf`)",
|
||||
},
|
||||
"Test2": {
|
||||
Service: "Test2",
|
||||
Rule: "Host:Test2.traefik.wtf",
|
||||
Rule: "Host(`Test2.traefik.wtf`)",
|
||||
},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
|
@ -481,7 +481,7 @@ func Test_buildConfiguration(t *testing.T) {
|
|||
Routers: map[string]*config.Router{
|
||||
"Test": {
|
||||
Service: "Test",
|
||||
Rule: "Host:Test.traefik.wtf",
|
||||
Rule: "Host(`Test.traefik.wtf`)",
|
||||
},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
|
@ -531,7 +531,7 @@ func Test_buildConfiguration(t *testing.T) {
|
|||
Routers: map[string]*config.Router{
|
||||
"Test": {
|
||||
Service: "Service1",
|
||||
Rule: "Host:Test.traefik.wtf",
|
||||
Rule: "Host(`Test.traefik.wtf`)",
|
||||
},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
|
@ -559,7 +559,7 @@ func Test_buildConfiguration(t *testing.T) {
|
|||
Name: "Test",
|
||||
Labels: map[string]string{
|
||||
"traefik.services.Service1.loadbalancer.method": "wrr",
|
||||
"traefik.routers.Router1.rule": "Host:foo.com",
|
||||
"traefik.routers.Router1.rule": "Host(`foo.com`)",
|
||||
"traefik.routers.Router1.service": "Service1",
|
||||
},
|
||||
NetworkSettings: networkSettings{
|
||||
|
@ -579,7 +579,7 @@ func Test_buildConfiguration(t *testing.T) {
|
|||
Routers: map[string]*config.Router{
|
||||
"Router1": {
|
||||
Service: "Service1",
|
||||
Rule: "Host:foo.com",
|
||||
Rule: "Host(`foo.com`)",
|
||||
},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
|
@ -606,7 +606,7 @@ func Test_buildConfiguration(t *testing.T) {
|
|||
ServiceName: "Test",
|
||||
Name: "Test",
|
||||
Labels: map[string]string{
|
||||
"traefik.routers.Router1.rule": "Host:foo.com",
|
||||
"traefik.routers.Router1.rule": "Host(`foo.com`)",
|
||||
},
|
||||
NetworkSettings: networkSettings{
|
||||
Ports: nat.PortMap{
|
||||
|
@ -640,7 +640,7 @@ func Test_buildConfiguration(t *testing.T) {
|
|||
Routers: map[string]*config.Router{
|
||||
"Router1": {
|
||||
Service: "Test",
|
||||
Rule: "Host:foo.com",
|
||||
Rule: "Host(`foo.com`)",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -652,7 +652,7 @@ func Test_buildConfiguration(t *testing.T) {
|
|||
ServiceName: "Test",
|
||||
Name: "Test",
|
||||
Labels: map[string]string{
|
||||
"traefik.routers.Router1.rule": "Host:foo.com",
|
||||
"traefik.routers.Router1.rule": "Host(`foo.com`)",
|
||||
"traefik.services.Service1.loadbalancer.method": "wrr",
|
||||
},
|
||||
NetworkSettings: networkSettings{
|
||||
|
@ -672,7 +672,7 @@ func Test_buildConfiguration(t *testing.T) {
|
|||
Routers: map[string]*config.Router{
|
||||
"Router1": {
|
||||
Service: "Service1",
|
||||
Rule: "Host:foo.com",
|
||||
Rule: "Host(`foo.com`)",
|
||||
},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
|
@ -699,7 +699,7 @@ func Test_buildConfiguration(t *testing.T) {
|
|||
ServiceName: "Test",
|
||||
Name: "Test",
|
||||
Labels: map[string]string{
|
||||
"traefik.routers.Router1.rule": "Host:foo.com",
|
||||
"traefik.routers.Router1.rule": "Host(`foo.com`)",
|
||||
"traefik.services.Service1.loadbalancer.method": "wrr",
|
||||
"traefik.services.Service2.loadbalancer.method": "wrr",
|
||||
},
|
||||
|
@ -793,7 +793,7 @@ func Test_buildConfiguration(t *testing.T) {
|
|||
Routers: map[string]*config.Router{
|
||||
"Test": {
|
||||
Service: "Service1",
|
||||
Rule: "Host:Test.traefik.wtf",
|
||||
Rule: "Host(`Test.traefik.wtf`)",
|
||||
},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
|
@ -865,7 +865,7 @@ func Test_buildConfiguration(t *testing.T) {
|
|||
Routers: map[string]*config.Router{
|
||||
"Test": {
|
||||
Service: "Service1",
|
||||
Rule: "Host:Test.traefik.wtf",
|
||||
Rule: "Host(`Test.traefik.wtf`)",
|
||||
},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
|
@ -918,7 +918,7 @@ func Test_buildConfiguration(t *testing.T) {
|
|||
Routers: map[string]*config.Router{
|
||||
"Test": {
|
||||
Service: "Service1",
|
||||
Rule: "Host:Test.traefik.wtf",
|
||||
Rule: "Host(`Test.traefik.wtf`)",
|
||||
},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
|
@ -968,7 +968,7 @@ func Test_buildConfiguration(t *testing.T) {
|
|||
Routers: map[string]*config.Router{
|
||||
"Test": {
|
||||
Service: "Test",
|
||||
Rule: "Host:Test.traefik.wtf",
|
||||
Rule: "Host(`Test.traefik.wtf`)",
|
||||
},
|
||||
},
|
||||
Services: map[string]*config.Service{
|
||||
|
@ -1041,7 +1041,7 @@ func Test_buildConfiguration(t *testing.T) {
|
|||
Routers: map[string]*config.Router{
|
||||
"Test": {
|
||||
Service: "Test",
|
||||
Rule: "Host:Test.traefik.wtf",
|
||||
Rule: "Host(`Test.traefik.wtf`)",
|
||||
},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{
|
||||
|
@ -1118,7 +1118,7 @@ func Test_buildConfiguration(t *testing.T) {
|
|||
Routers: map[string]*config.Router{
|
||||
"Test": {
|
||||
Service: "Test",
|
||||
Rule: "Host:Test.traefik.wtf",
|
||||
Rule: "Host(`Test.traefik.wtf`)",
|
||||
},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
|
@ -1207,7 +1207,7 @@ func Test_buildConfiguration(t *testing.T) {
|
|||
Routers: map[string]*config.Router{
|
||||
"Test": {
|
||||
Service: "Test",
|
||||
Rule: "Host:Test.traefik.wtf",
|
||||
Rule: "Host(`Test.traefik.wtf`)",
|
||||
},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
|
@ -1243,7 +1243,7 @@ func Test_buildConfiguration(t *testing.T) {
|
|||
ServiceName: "Test",
|
||||
Name: "Test",
|
||||
Labels: map[string]string{
|
||||
"traefik.routers.Router1.rule": "Host:foo.com",
|
||||
"traefik.routers.Router1.rule": "Host(`foo.com`)",
|
||||
},
|
||||
NetworkSettings: networkSettings{
|
||||
Ports: nat.PortMap{
|
||||
|
@ -1262,7 +1262,7 @@ func Test_buildConfiguration(t *testing.T) {
|
|||
ServiceName: "Test",
|
||||
Name: "Test",
|
||||
Labels: map[string]string{
|
||||
"traefik.routers.Router1.rule": "Host:bar.com",
|
||||
"traefik.routers.Router1.rule": "Host(`bar.com`)",
|
||||
},
|
||||
NetworkSettings: networkSettings{
|
||||
Ports: nat.PortMap{
|
||||
|
@ -1308,7 +1308,7 @@ func Test_buildConfiguration(t *testing.T) {
|
|||
ServiceName: "Test",
|
||||
Name: "Test",
|
||||
Labels: map[string]string{
|
||||
"traefik.routers.Router1.rule": "Host:foo.com",
|
||||
"traefik.routers.Router1.rule": "Host(`foo.com`)",
|
||||
},
|
||||
NetworkSettings: networkSettings{
|
||||
Ports: nat.PortMap{
|
||||
|
@ -1327,7 +1327,7 @@ func Test_buildConfiguration(t *testing.T) {
|
|||
ServiceName: "Test",
|
||||
Name: "Test",
|
||||
Labels: map[string]string{
|
||||
"traefik.routers.Router1.rule": "Host:bar.com",
|
||||
"traefik.routers.Router1.rule": "Host(`bar.com`)",
|
||||
},
|
||||
NetworkSettings: networkSettings{
|
||||
Ports: nat.PortMap{
|
||||
|
@ -1346,7 +1346,7 @@ func Test_buildConfiguration(t *testing.T) {
|
|||
ServiceName: "Test",
|
||||
Name: "Test",
|
||||
Labels: map[string]string{
|
||||
"traefik.routers.Router1.rule": "Host:foobar.com",
|
||||
"traefik.routers.Router1.rule": "Host(`foobar.com`)",
|
||||
},
|
||||
NetworkSettings: networkSettings{
|
||||
Ports: nat.PortMap{
|
||||
|
@ -1396,7 +1396,7 @@ func Test_buildConfiguration(t *testing.T) {
|
|||
ServiceName: "Test",
|
||||
Name: "Test",
|
||||
Labels: map[string]string{
|
||||
"traefik.routers.Router1.rule": "Host:foo.com",
|
||||
"traefik.routers.Router1.rule": "Host(`foo.com`)",
|
||||
},
|
||||
NetworkSettings: networkSettings{
|
||||
Ports: nat.PortMap{
|
||||
|
@ -1415,7 +1415,7 @@ func Test_buildConfiguration(t *testing.T) {
|
|||
ServiceName: "Test",
|
||||
Name: "Test",
|
||||
Labels: map[string]string{
|
||||
"traefik.routers.Router1.rule": "Host:foo.com",
|
||||
"traefik.routers.Router1.rule": "Host(`foo.com`)",
|
||||
},
|
||||
NetworkSettings: networkSettings{
|
||||
Ports: nat.PortMap{
|
||||
|
@ -1434,7 +1434,7 @@ func Test_buildConfiguration(t *testing.T) {
|
|||
Routers: map[string]*config.Router{
|
||||
"Router1": {
|
||||
Service: "Test",
|
||||
Rule: "Host:foo.com",
|
||||
Rule: "Host(`foo.com`)",
|
||||
},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
|
@ -1465,7 +1465,7 @@ func Test_buildConfiguration(t *testing.T) {
|
|||
ServiceName: "Test",
|
||||
Name: "Test",
|
||||
Labels: map[string]string{
|
||||
"traefik.routers.Router1.rule": "Host:foo.com",
|
||||
"traefik.routers.Router1.rule": "Host(`foo.com`)",
|
||||
},
|
||||
NetworkSettings: networkSettings{
|
||||
Ports: nat.PortMap{
|
||||
|
@ -1483,7 +1483,7 @@ func Test_buildConfiguration(t *testing.T) {
|
|||
ServiceName: "Test2",
|
||||
Name: "Test",
|
||||
Labels: map[string]string{
|
||||
"traefik.routers.Router1.rule": "Host:foo.com",
|
||||
"traefik.routers.Router1.rule": "Host(`foo.com`)",
|
||||
},
|
||||
NetworkSettings: networkSettings{
|
||||
Ports: nat.PortMap{
|
||||
|
@ -1555,7 +1555,7 @@ func Test_buildConfiguration(t *testing.T) {
|
|||
Routers: map[string]*config.Router{
|
||||
"Test": {
|
||||
Service: "Test",
|
||||
Rule: "Host:Test.traefik.wtf",
|
||||
Rule: "Host(`Test.traefik.wtf`)",
|
||||
},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
|
@ -1602,7 +1602,7 @@ func Test_buildConfiguration(t *testing.T) {
|
|||
Routers: map[string]*config.Router{
|
||||
"Test": {
|
||||
Service: "Service1",
|
||||
Rule: "Host:Test.traefik.wtf",
|
||||
Rule: "Host(`Test.traefik.wtf`)",
|
||||
},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
|
@ -1849,7 +1849,7 @@ func Test_buildConfiguration(t *testing.T) {
|
|||
Routers: map[string]*config.Router{
|
||||
"Test": {
|
||||
Service: "Test",
|
||||
Rule: "Host:Test.traefik.wtf",
|
||||
Rule: "Host(`Test.traefik.wtf`)",
|
||||
},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
|
@ -1896,7 +1896,7 @@ func Test_buildConfiguration(t *testing.T) {
|
|||
Routers: map[string]*config.Router{
|
||||
"Test": {
|
||||
Service: "Test",
|
||||
Rule: "Host:Test.traefik.wtf",
|
||||
Rule: "Host(`Test.traefik.wtf`)",
|
||||
Middlewares: []string{"Middleware1"},
|
||||
},
|
||||
},
|
||||
|
@ -1936,7 +1936,7 @@ func Test_buildConfiguration(t *testing.T) {
|
|||
|
||||
p := Provider{
|
||||
ExposedByDefault: true,
|
||||
DefaultRule: "Host:{{ normalize .Name }}.traefik.wtf",
|
||||
DefaultRule: "Host(`{{ normalize .Name }}.traefik.wtf`)",
|
||||
}
|
||||
p.Constraints = test.constraints
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ const (
|
|||
// SwarmAPIVersion is a constant holding the version of the Provider API traefik will use.
|
||||
SwarmAPIVersion = "1.24"
|
||||
// DefaultTemplateRule The default template for the default rule.
|
||||
DefaultTemplateRule = "Host:{{ normalize .Name }}"
|
||||
DefaultTemplateRule = "Host(`{{ normalize .Name }}`)"
|
||||
)
|
||||
|
||||
var _ provider.Provider = (*Provider)(nil)
|
||||
|
|
|
@ -132,7 +132,6 @@ func (c *fakeServicesClient) TaskList(ctx context.Context, options dockertypes.T
|
|||
func TestListServices(t *testing.T) {
|
||||
testCases := []struct {
|
||||
desc string
|
||||
extraConf configuration
|
||||
services []swarm.Service
|
||||
tasks []swarm.Task
|
||||
dockerVersion string
|
||||
|
|
|
@ -48,7 +48,7 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
Routers: map[string]*config.Router{
|
||||
"app": {
|
||||
Service: "app",
|
||||
Rule: "Host:app.marathon.localhost",
|
||||
Rule: "Host(`app.marathon.localhost`)",
|
||||
},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
|
@ -92,7 +92,7 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
Routers: map[string]*config.Router{
|
||||
"app": {
|
||||
Service: "app",
|
||||
Rule: "Host:app.marathon.localhost",
|
||||
Rule: "Host(`app.marathon.localhost`)",
|
||||
},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
|
@ -124,7 +124,7 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
Routers: map[string]*config.Router{
|
||||
"app": {
|
||||
Service: "app",
|
||||
Rule: "Host:app.marathon.localhost",
|
||||
Rule: "Host(`app.marathon.localhost`)",
|
||||
Middlewares: []string{"Middleware1"},
|
||||
},
|
||||
},
|
||||
|
@ -160,21 +160,21 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
withTasks(localhostTask(taskPorts(8080))),
|
||||
|
||||
withLabel("traefik.services.Service1.LoadBalancer.server.port", "index:0"),
|
||||
withLabel("traefik.routers.Router1.rule", "Host:app.marathon.localhost"),
|
||||
withLabel("traefik.routers.Router1.rule", "Host(`app.marathon.localhost`)"),
|
||||
),
|
||||
application(
|
||||
appID("/foo-v001"),
|
||||
withTasks(localhostTask(taskPorts(8081))),
|
||||
|
||||
withLabel("traefik.services.Service1.LoadBalancer.server.port", "index:0"),
|
||||
withLabel("traefik.routers.Router1.rule", "Host:app.marathon.localhost"),
|
||||
withLabel("traefik.routers.Router1.rule", "Host(`app.marathon.localhost`)"),
|
||||
),
|
||||
),
|
||||
expected: &config.Configuration{
|
||||
Routers: map[string]*config.Router{
|
||||
"Router1": {
|
||||
Service: "Service1",
|
||||
Rule: "Host:app.marathon.localhost",
|
||||
Rule: "Host(`app.marathon.localhost`)",
|
||||
},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
|
@ -205,7 +205,7 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
withTasks(localhostTask(taskPorts(8081))),
|
||||
|
||||
withLabel("traefik.services.Service1.LoadBalancer.server.port", "index:0"),
|
||||
withLabel("traefik.routers.Router1.rule", "Host:app.marathon.localhost"),
|
||||
withLabel("traefik.routers.Router1.rule", "Host(`app.marathon.localhost`)"),
|
||||
),
|
||||
application(
|
||||
appID("/foo-v001"),
|
||||
|
@ -213,14 +213,14 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
withTasks(localhostTask(taskPorts(8083))),
|
||||
|
||||
withLabel("traefik.services.Service1.LoadBalancer.server.port", "index:0"),
|
||||
withLabel("traefik.routers.Router1.rule", "Host:app.marathon.localhost"),
|
||||
withLabel("traefik.routers.Router1.rule", "Host(`app.marathon.localhost`)"),
|
||||
),
|
||||
),
|
||||
expected: &config.Configuration{
|
||||
Routers: map[string]*config.Router{
|
||||
"Router1": {
|
||||
Service: "Service1",
|
||||
Rule: "Host:app.marathon.localhost",
|
||||
Rule: "Host(`app.marathon.localhost`)",
|
||||
},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
|
@ -266,11 +266,11 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
Routers: map[string]*config.Router{
|
||||
"foo": {
|
||||
Service: "foo",
|
||||
Rule: "Host:foo.marathon.localhost",
|
||||
Rule: "Host(`foo.marathon.localhost`)",
|
||||
},
|
||||
"bar": {
|
||||
Service: "bar",
|
||||
Rule: "Host:bar.marathon.localhost",
|
||||
Rule: "Host(`bar.marathon.localhost`)",
|
||||
},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
|
@ -310,7 +310,7 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
Routers: map[string]*config.Router{
|
||||
"app": {
|
||||
Service: "app",
|
||||
Rule: "Host:app.marathon.localhost",
|
||||
Rule: "Host(`app.marathon.localhost`)",
|
||||
},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
|
@ -347,7 +347,7 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
Routers: map[string]*config.Router{
|
||||
"app": {
|
||||
Service: "Service1",
|
||||
Rule: "Host:app.marathon.localhost",
|
||||
Rule: "Host(`app.marathon.localhost`)",
|
||||
},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
|
@ -373,14 +373,14 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
appPorts(80, 81),
|
||||
withTasks(localhostTask(taskPorts(80, 81))),
|
||||
withLabel("traefik.services.Service1.loadbalancer.method", "wrr"),
|
||||
withLabel("traefik.routers.Router1.rule", "Host:foo.com"),
|
||||
withLabel("traefik.routers.Router1.rule", "Host(`foo.com`)"),
|
||||
withLabel("traefik.routers.Router1.service", "Service1"),
|
||||
)),
|
||||
expected: &config.Configuration{
|
||||
Routers: map[string]*config.Router{
|
||||
"Router1": {
|
||||
Service: "Service1",
|
||||
Rule: "Host:foo.com",
|
||||
Rule: "Host(`foo.com`)",
|
||||
},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
|
@ -407,7 +407,7 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
appID("/app"),
|
||||
appPorts(80, 81),
|
||||
withTasks(localhostTask(taskPorts(80, 81))),
|
||||
withLabel("traefik.routers.Router1.rule", "Host:foo.com"),
|
||||
withLabel("traefik.routers.Router1.rule", "Host(`foo.com`)"),
|
||||
)),
|
||||
expected: &config.Configuration{
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
|
@ -428,7 +428,7 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
Routers: map[string]*config.Router{
|
||||
"Router1": {
|
||||
Service: "app",
|
||||
Rule: "Host:foo.com",
|
||||
Rule: "Host(`foo.com`)",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -440,14 +440,14 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
appID("/app"),
|
||||
appPorts(80, 81),
|
||||
withTasks(localhostTask(taskPorts(80, 81))),
|
||||
withLabel("traefik.routers.Router1.rule", "Host:foo.com"),
|
||||
withLabel("traefik.routers.Router1.rule", "Host(`foo.com`)"),
|
||||
withLabel("traefik.services.Service1.loadbalancer.method", "wrr"),
|
||||
)),
|
||||
expected: &config.Configuration{
|
||||
Routers: map[string]*config.Router{
|
||||
"Router1": {
|
||||
Service: "Service1",
|
||||
Rule: "Host:foo.com",
|
||||
Rule: "Host(`foo.com`)",
|
||||
},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
|
@ -474,7 +474,7 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
appID("/app"),
|
||||
appPorts(80, 81),
|
||||
withTasks(localhostTask(taskPorts(80, 81))),
|
||||
withLabel("traefik.routers.Router1.rule", "Host:foo.com"),
|
||||
withLabel("traefik.routers.Router1.rule", "Host(`foo.com`)"),
|
||||
withLabel("traefik.services.Service1.loadbalancer.method", "wrr"),
|
||||
withLabel("traefik.services.Service2.loadbalancer.method", "wrr"),
|
||||
)),
|
||||
|
@ -528,11 +528,11 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
Routers: map[string]*config.Router{
|
||||
"app": {
|
||||
Service: "Service1",
|
||||
Rule: "Host:app.marathon.localhost",
|
||||
Rule: "Host(`app.marathon.localhost`)",
|
||||
},
|
||||
"app2": {
|
||||
Service: "Service1",
|
||||
Rule: "Host:app2.marathon.localhost",
|
||||
Rule: "Host(`app2.marathon.localhost`)",
|
||||
},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
|
@ -558,11 +558,11 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
Routers: map[string]*config.Router{
|
||||
"app": {
|
||||
Service: "app",
|
||||
Rule: "Host:app.marathon.localhost",
|
||||
Rule: "Host(`app.marathon.localhost`)",
|
||||
},
|
||||
"app2": {
|
||||
Service: "app2",
|
||||
Rule: "Host:app2.marathon.localhost",
|
||||
Rule: "Host(`app2.marathon.localhost`)",
|
||||
},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{
|
||||
|
@ -620,11 +620,11 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
Routers: map[string]*config.Router{
|
||||
"app": {
|
||||
Service: "app",
|
||||
Rule: "Host:app.marathon.localhost",
|
||||
Rule: "Host(`app.marathon.localhost`)",
|
||||
},
|
||||
"app2": {
|
||||
Service: "app2",
|
||||
Rule: "Host:app2.marathon.localhost",
|
||||
Rule: "Host(`app2.marathon.localhost`)",
|
||||
},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
|
@ -663,13 +663,13 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
appID("/app"),
|
||||
appPorts(80, 81),
|
||||
withTasks(localhostTask(taskPorts(80, 81))),
|
||||
withLabel("traefik.routers.Router1.rule", "Host:foo.com"),
|
||||
withLabel("traefik.routers.Router1.rule", "Host(`foo.com`)"),
|
||||
),
|
||||
application(
|
||||
appID("/app2"),
|
||||
appPorts(80, 81),
|
||||
withTasks(localhostTask(taskPorts(80, 81))),
|
||||
withLabel("traefik.routers.Router1.rule", "Host:bar.com"),
|
||||
withLabel("traefik.routers.Router1.rule", "Host(`bar.com`)"),
|
||||
)),
|
||||
expected: &config.Configuration{
|
||||
Routers: map[string]*config.Router{},
|
||||
|
@ -709,21 +709,21 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
appID("/app"),
|
||||
appPorts(80, 81),
|
||||
withTasks(localhostTask(taskPorts(80, 81))),
|
||||
withLabel("traefik.routers.Router1.rule", "Host:foo.com"),
|
||||
withLabel("traefik.routers.Router1.rule", "Host(`foo.com`)"),
|
||||
withLabel("traefik.services.Service1.LoadBalancer.method", "wrr"),
|
||||
),
|
||||
application(
|
||||
appID("/app2"),
|
||||
appPorts(80, 81),
|
||||
withTasks(localhostTask(taskPorts(80, 81))),
|
||||
withLabel("traefik.routers.Router1.rule", "Host:foo.com"),
|
||||
withLabel("traefik.routers.Router1.rule", "Host(`foo.com`)"),
|
||||
withLabel("traefik.services.Service1.LoadBalancer.method", "wrr"),
|
||||
)),
|
||||
expected: &config.Configuration{
|
||||
Routers: map[string]*config.Router{
|
||||
"Router1": {
|
||||
Service: "Service1",
|
||||
Rule: "Host:foo.com",
|
||||
Rule: "Host(`foo.com`)",
|
||||
},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
|
@ -754,13 +754,13 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
appID("/app"),
|
||||
appPorts(80, 81),
|
||||
withTasks(localhostTask(taskPorts(80, 81))),
|
||||
withLabel("traefik.routers.Router1.rule", "Host:foo.com"),
|
||||
withLabel("traefik.routers.Router1.rule", "Host(`foo.com`)"),
|
||||
),
|
||||
application(
|
||||
appID("/app2"),
|
||||
appPorts(80, 81),
|
||||
withTasks(localhostTask(taskPorts(80, 81))),
|
||||
withLabel("traefik.routers.Router1.rule", "Host:foo.com"),
|
||||
withLabel("traefik.routers.Router1.rule", "Host(`foo.com`)"),
|
||||
)),
|
||||
expected: &config.Configuration{
|
||||
Routers: map[string]*config.Router{},
|
||||
|
@ -806,7 +806,7 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
Routers: map[string]*config.Router{
|
||||
"app": {
|
||||
Service: "app",
|
||||
Rule: "Host:app.marathon.localhost",
|
||||
Rule: "Host(`app.marathon.localhost`)",
|
||||
},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
|
@ -840,7 +840,7 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
Routers: map[string]*config.Router{
|
||||
"app": {
|
||||
Service: "Service1",
|
||||
Rule: "Host:app.marathon.localhost",
|
||||
Rule: "Host(`app.marathon.localhost`)",
|
||||
},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
|
@ -1026,7 +1026,7 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
Routers: map[string]*config.Router{
|
||||
"app": {
|
||||
Service: "app",
|
||||
Rule: "Host:app.marathon.localhost",
|
||||
Rule: "Host(`app.marathon.localhost`)",
|
||||
},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
|
@ -1067,7 +1067,7 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
Routers: map[string]*config.Router{
|
||||
"app": {
|
||||
Service: "app",
|
||||
Rule: "Host:app.marathon.localhost",
|
||||
Rule: "Host(`app.marathon.localhost`)",
|
||||
},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
|
@ -1089,7 +1089,7 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
},
|
||||
{
|
||||
desc: "one app with group as subdomain rule",
|
||||
defaultRule: `Host:{{ .Name | trimPrefix "/" | splitList "/" | strsToItfs | reverse | join "." }}.marathon.localhost`,
|
||||
defaultRule: `Host("{{ .Name | trimPrefix "/" | splitList "/" | strsToItfs | reverse | join "." }}.marathon.localhost")`,
|
||||
applications: withApplications(
|
||||
application(
|
||||
appID("/a/b/app"),
|
||||
|
@ -1100,7 +1100,7 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
Routers: map[string]*config.Router{
|
||||
"a_b_app": {
|
||||
Service: "a_b_app",
|
||||
Rule: "Host:app.b.a.marathon.localhost",
|
||||
Rule: `Host("app.b.a.marathon.localhost")`,
|
||||
},
|
||||
},
|
||||
Middlewares: map[string]*config.Middleware{},
|
||||
|
@ -1127,7 +1127,7 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
t.Run(test.desc, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
defaultRule := DefaultTemplateRule + ".marathon.localhost"
|
||||
defaultRule := "Host(`{{ normalize .Name }}.marathon.localhost`)"
|
||||
if len(test.defaultRule) > 0 {
|
||||
defaultRule = test.defaultRule
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import (
|
|||
|
||||
const (
|
||||
// DefaultTemplateRule The default template for the default rule.
|
||||
DefaultTemplateRule = "Host:{{ normalize .Name }}"
|
||||
DefaultTemplateRule = "Host(`{{ normalize .Name }}`)"
|
||||
traceMaxScanTokenSize = 1024 * 1024
|
||||
marathonEventIDs = marathon.EventIDApplications |
|
||||
marathon.EventIDAddHealthCheck |
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue