traefik/pkg/provider/consulcatalog/label.go
Ludovic Fernandez 044dc6a221
fix: go module
2023-02-03 15:24:05 +01:00

32 lines
1,002 B
Go

package consulcatalog
import (
"github.com/traefik/traefik/v3/pkg/config/label"
)
// configuration contains information from the labels that are globals (not related to the dynamic configuration) or specific to the provider.
type configuration struct {
Enable bool
ConsulCatalog specificConfiguration
}
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) {
conf := configuration{
Enable: p.ExposedByDefault,
ConsulCatalog: specificConfiguration{Connect: p.ConnectByDefault},
}
err := label.Decode(labels, &conf, "traefik.consulcatalog.", "traefik.enable")
if err != nil {
return configuration{}, err
}
return conf, nil
}