fe68e9e243
Co-authored-by: Mathieu Lonjaret <mathieu.lonjaret@gmail.com>
42 lines
791 B
Go
42 lines
791 B
Go
package marathon
|
|
|
|
import (
|
|
"math"
|
|
|
|
"github.com/containous/traefik/pkg/config/label"
|
|
"github.com/gambol99/go-marathon"
|
|
)
|
|
|
|
type configuration struct {
|
|
Enable bool
|
|
Marathon specificConfiguration
|
|
}
|
|
|
|
type specificConfiguration struct {
|
|
IPAddressIdx int
|
|
}
|
|
|
|
func (p *Provider) getConfiguration(app marathon.Application) (configuration, error) {
|
|
labels := stringValueMap(app.Labels)
|
|
|
|
conf := configuration{
|
|
Enable: p.ExposedByDefault,
|
|
Marathon: specificConfiguration{
|
|
IPAddressIdx: math.MinInt32,
|
|
},
|
|
}
|
|
|
|
err := label.Decode(labels, &conf, "traefik.marathon.", "traefik.enable")
|
|
if err != nil {
|
|
return configuration{}, err
|
|
}
|
|
|
|
return conf, nil
|
|
}
|
|
|
|
func stringValueMap(mp *map[string]string) map[string]string {
|
|
if mp != nil {
|
|
return *mp
|
|
}
|
|
return make(map[string]string)
|
|
}
|