2019-01-29 16:54:05 +00:00
|
|
|
package marathon
|
|
|
|
|
|
|
|
import (
|
|
|
|
"math"
|
|
|
|
|
2019-08-03 01:58:23 +00:00
|
|
|
"github.com/containous/traefik/v2/pkg/config/label"
|
2019-01-29 16:54:05 +00:00
|
|
|
"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,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2019-06-21 07:24:04 +00:00
|
|
|
err := label.Decode(labels, &conf, "traefik.marathon.", "traefik.enable")
|
2019-01-29 16:54:05 +00:00
|
|
|
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)
|
|
|
|
}
|