From 5641af437e9242dce64e121eeae10e5869fd4d52 Mon Sep 17 00:00:00 2001 From: Guilhem Lettron Date: Thu, 27 Oct 2016 15:49:34 +0200 Subject: [PATCH] Use first port by default If no information is given, use first index of ports --- provider/marathon.go | 5 +---- provider/marathon_test.go | 8 ++++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/provider/marathon.go b/provider/marathon.go index f2ec40918..f6cc85563 100644 --- a/provider/marathon.go +++ b/provider/marathon.go @@ -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) 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 != "" { index, err := strconv.Atoi((*application.Labels)["traefik.portIndex"]) if err != nil || index < 0 || index > len(application.Ports)-1 { diff --git a/provider/marathon_test.go b/provider/marathon_test.go index fb2314cbb..6ce7c4009 100644 --- a/provider/marathon_test.go +++ b/provider/marathon_test.go @@ -372,7 +372,7 @@ func TestMarathonTaskFilter(t *testing.T) { { task: marathon.Task{ AppID: "multiple-ports", - Ports: []int{80}, + Ports: []int{80, 443}, }, applications: &marathon.Applications{ Apps: []marathon.Application{ @@ -383,7 +383,7 @@ func TestMarathonTaskFilter(t *testing.T) { }, }, }, - expected: false, + expected: true, exposedByDefault: true, }, { @@ -927,12 +927,12 @@ func TestMarathonGetPort(t *testing.T) { { applications: []marathon.Application{ { - ID: "test1", + ID: "multiple-ports-take-first", Labels: &map[string]string{}, }, }, task: marathon.Task{ - AppID: "test1", + AppID: "multiple-ports-take-first", Ports: []int{80, 443}, }, expected: "80",