traefik/pkg/provider/consulcatalog/label.go

32 lines
1,002 B
Go
Raw Normal View History

2019-10-15 15:34:08 +00:00
package consulcatalog
import (
"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.
2019-10-15 15:34:08 +00:00
type configuration struct {
Enable bool
ConsulCatalog specificConfiguration
2019-10-15 15:34:08 +00:00
}
type specificConfiguration struct {
Connect bool // <prefix>.consulcatalog.connect is the corresponding label.
Canary bool // <prefix>.consulcatalog.canary is the corresponding label.
}
// getExtraConf returns a configuration with settings which are not part of the dynamic configuration (e.g. "<prefix>.enable").
func (p *Provider) getExtraConf(labels map[string]string) (configuration, error) {
2019-10-15 15:34:08 +00:00
conf := configuration{
Enable: p.ExposedByDefault,
ConsulCatalog: specificConfiguration{Connect: p.ConnectByDefault},
2019-10-15 15:34:08 +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
}