1
0
Fork 0

Factorize labels

* refactor(accesslog): factorize file name.
* traefik.frontend.rule
* traefik.frontend.value
* traefik.backend.circuitbreaker.expression
* traefik.enable
* traefik.backend.loadbalancer.method
* traefik.backend.loadbalancer.sticky
* traefik.backend.maxconn.amount
* traefik.backend.maxconn.extractorfunc
* traefik.port
* traefik.tags
* traefik.backend
* traefik.weight
* traefik.domain
* traefik.protocol
* traefik.frontend.passHostHeader
* traefik.frontend.whitelistSourceRange
* traefik.frontend.priority
* traefik.frontend.entryPoints
* traefik.frontend.auth.basic
* traefik.backend.id
* traefik.backend.circuitbreaker
* traefik.frontend.rule.type
* traefik.portIndex
* refactor(docker): specific labels
* refactor(rancher): specific labels
* traefik.backend.healthcheck.*
* refactor(providers): factorize labels.
This commit is contained in:
Ludovic Fernandez 2017-07-10 16:58:12 +02:00 committed by SALLEYRON Julien
parent 2e84b1e556
commit d653a348b1
20 changed files with 390 additions and 330 deletions

View file

@ -390,7 +390,7 @@ func (p *Provider) filterInstance(i ecsInstance) bool {
return false
}
label := i.label("traefik.enable")
label := i.label(types.LabelEnable)
enabled := p.ExposedByDefault && label != "false" || label == "true"
if !enabled {
log.Debugf("Filtering disabled ecs instance %s (%s) (traefik.enabled = '%s')", i.Name, i.ID, label)
@ -414,7 +414,7 @@ func (p *Provider) filterFrontends(instances []ecsInstance) []ecsInstance {
}
func (p *Provider) getFrontendRule(i ecsInstance) string {
if label := i.label("traefik.frontend.rule"); label != "" {
if label := i.label(types.LabelFrontendRule); label != "" {
return label
}
return "Host:" + strings.ToLower(strings.Replace(i.Name, "_", "-", -1)) + "." + p.Domain
@ -437,7 +437,7 @@ func (p *Provider) chunkedTaskArns(tasks []*string) [][]*string {
}
func (i ecsInstance) Protocol() string {
if label := i.label("traefik.protocol"); label != "" {
if label := i.label(types.LabelProtocol); label != "" {
return label
}
return "http"
@ -452,28 +452,28 @@ func (i ecsInstance) Port() string {
}
func (i ecsInstance) Weight() string {
if label := i.label("traefik.weight"); label != "" {
if label := i.label(types.LabelWeight); label != "" {
return label
}
return "0"
}
func (i ecsInstance) PassHostHeader() string {
if label := i.label("traefik.frontend.passHostHeader"); label != "" {
if label := i.label(types.LabelFrontendPassHostHeader); label != "" {
return label
}
return "true"
}
func (i ecsInstance) Priority() string {
if label := i.label("traefik.frontend.priority"); label != "" {
if label := i.label(types.LabelFrontendPriority); label != "" {
return label
}
return "0"
}
func (i ecsInstance) EntryPoints() []string {
if label := i.label("traefik.frontend.entryPoints"); label != "" {
if label := i.label(types.LabelFrontendEntryPoints); label != "" {
return strings.Split(label, ",")
}
return []string{}

View file

@ -7,6 +7,7 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/aws/aws-sdk-go/service/ecs"
"github.com/containous/traefik/types"
)
func makeEcsInstance(containerDef *ecs.ContainerDefinition) ecsInstance {
@ -68,7 +69,7 @@ func TestEcsProtocol(t *testing.T) {
{
expected: "https",
instanceInfo: simpleEcsInstance(map[string]*string{
"traefik.protocol": aws.String("https"),
types.LabelProtocol: aws.String("https"),
}),
},
}
@ -131,7 +132,7 @@ func TestEcsWeight(t *testing.T) {
{
expected: "10",
instanceInfo: simpleEcsInstance(map[string]*string{
"traefik.weight": aws.String("10"),
types.LabelWeight: aws.String("10"),
}),
},
}
@ -156,7 +157,7 @@ func TestEcsPassHostHeader(t *testing.T) {
{
expected: "false",
instanceInfo: simpleEcsInstance(map[string]*string{
"traefik.frontend.passHostHeader": aws.String("false"),
types.LabelFrontendPassHostHeader: aws.String("false"),
}),
},
}
@ -181,7 +182,7 @@ func TestEcsPriority(t *testing.T) {
{
expected: "10",
instanceInfo: simpleEcsInstance(map[string]*string{
"traefik.frontend.priority": aws.String("10"),
types.LabelFrontendPriority: aws.String("10"),
}),
},
}
@ -206,13 +207,13 @@ func TestEcsEntryPoints(t *testing.T) {
{
expected: []string{"http"},
instanceInfo: simpleEcsInstance(map[string]*string{
"traefik.frontend.entryPoints": aws.String("http"),
types.LabelFrontendEntryPoints: aws.String("http"),
}),
},
{
expected: []string{"http", "https"},
instanceInfo: simpleEcsInstance(map[string]*string{
"traefik.frontend.entryPoints": aws.String("http,https"),
types.LabelFrontendEntryPoints: aws.String("http,https"),
}),
},
}
@ -261,14 +262,14 @@ func TestFilterInstance(t *testing.T) {
expected: false,
exposedByDefault: true,
instanceInfo: simpleEcsInstance(map[string]*string{
"traefik.enable": aws.String("false"),
types.LabelEnable: aws.String("false"),
}),
},
{
expected: true,
exposedByDefault: false,
instanceInfo: simpleEcsInstance(map[string]*string{
"traefik.enable": aws.String("true"),
types.LabelEnable: aws.String("true"),
}),
},
{