Use first port by default
If no information is given, use first index of ports
This commit is contained in:
parent
1c8d3ded3d
commit
5641af437e
|
@ -219,10 +219,7 @@ func (provider *Marathon) taskFilter(task marathon.Task, applications *marathon.
|
||||||
log.Debugf("Filtering marathon task %s specifying both traefik.portIndex and traefik.port labels", task.AppID)
|
log.Debugf("Filtering marathon task %s specifying both traefik.portIndex and traefik.port labels", task.AppID)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if portIndexLabel == "" && portValueLabel == "" && len(application.Ports) > 1 {
|
|
||||||
log.Debugf("Filtering marathon task %s with more than 1 port and no traefik.portIndex or traefik.port label", task.AppID)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if portIndexLabel != "" {
|
if portIndexLabel != "" {
|
||||||
index, err := strconv.Atoi((*application.Labels)["traefik.portIndex"])
|
index, err := strconv.Atoi((*application.Labels)["traefik.portIndex"])
|
||||||
if err != nil || index < 0 || index > len(application.Ports)-1 {
|
if err != nil || index < 0 || index > len(application.Ports)-1 {
|
||||||
|
|
|
@ -372,7 +372,7 @@ func TestMarathonTaskFilter(t *testing.T) {
|
||||||
{
|
{
|
||||||
task: marathon.Task{
|
task: marathon.Task{
|
||||||
AppID: "multiple-ports",
|
AppID: "multiple-ports",
|
||||||
Ports: []int{80},
|
Ports: []int{80, 443},
|
||||||
},
|
},
|
||||||
applications: &marathon.Applications{
|
applications: &marathon.Applications{
|
||||||
Apps: []marathon.Application{
|
Apps: []marathon.Application{
|
||||||
|
@ -383,7 +383,7 @@ func TestMarathonTaskFilter(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expected: false,
|
expected: true,
|
||||||
exposedByDefault: true,
|
exposedByDefault: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -927,12 +927,12 @@ func TestMarathonGetPort(t *testing.T) {
|
||||||
{
|
{
|
||||||
applications: []marathon.Application{
|
applications: []marathon.Application{
|
||||||
{
|
{
|
||||||
ID: "test1",
|
ID: "multiple-ports-take-first",
|
||||||
Labels: &map[string]string{},
|
Labels: &map[string]string{},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
task: marathon.Task{
|
task: marathon.Task{
|
||||||
AppID: "test1",
|
AppID: "multiple-ports-take-first",
|
||||||
Ports: []int{80, 443},
|
Ports: []int{80, 443},
|
||||||
},
|
},
|
||||||
expected: "80",
|
expected: "80",
|
||||||
|
|
Loading…
Reference in a new issue