2019-10-15 15:34:08 +00:00
|
|
|
package consulcatalog
|
|
|
|
|
|
|
|
import (
|
2020-09-16 13:46:04 +00:00
|
|
|
"github.com/traefik/traefik/v2/pkg/config/label"
|
2019-10-15 15:34:08 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// configuration Contains information from the labels that are globals (not related to the dynamic configuration) or specific to the provider.
|
|
|
|
type configuration struct {
|
2021-07-15 12:02:11 +00:00
|
|
|
Enable bool
|
|
|
|
ConsulCatalog specificConfiguration
|
2019-10-15 15:34:08 +00:00
|
|
|
}
|
|
|
|
|
2021-07-15 12:02:11 +00:00
|
|
|
type specificConfiguration struct {
|
|
|
|
Connect bool
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Provider) getConfiguration(labels map[string]string) (configuration, error) {
|
2019-10-15 15:34:08 +00:00
|
|
|
conf := configuration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Enable: p.ExposedByDefault,
|
|
|
|
ConsulCatalog: specificConfiguration{Connect: p.ConnectByDefault},
|
2019-10-15 15:34:08 +00:00
|
|
|
}
|
|
|
|
|
2021-07-15 12:02:11 +00:00
|
|
|
err := label.Decode(labels, &conf, "traefik.consulcatalog.", "traefik.enable")
|
2019-10-15 15:34:08 +00:00
|
|
|
if err != nil {
|
|
|
|
return configuration{}, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return conf, nil
|
|
|
|
}
|