1
0
Fork 0

Fix docker labels (frontend.*)

Using Docker provider, you can specify `traefik.frontend.rule` and
`traefik.frontend.value` labels. If they are not both provided, there is
a default behavior. On the current master, if they are not defined, the
container is filtered (and thus the default behavior is broken).

Fixes that.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
Vincent Demeester 2015-11-05 15:14:25 +01:00
parent 7be566ef7c
commit 15318c4631
4 changed files with 233 additions and 18 deletions

View file

@ -151,7 +151,8 @@ func (provider *Docker) loadDockerConfig(dockerClient *docker.Client) *types.Con
return false
}
if _, err := provider.getLabels(container, []string{"traefik.frontend.rule", "traefik.frontend.value"}); err != nil {
labels, err := provider.getLabels(container, []string{"traefik.frontend.rule", "traefik.frontend.value"})
if len(labels) != 0 && err != nil {
log.Debugf("Filtering bad labeled container %s", container.Name)
return false
}
@ -225,15 +226,19 @@ func (provider *Docker) getLabel(container docker.Container, label string) (stri
}
func (provider *Docker) getLabels(container docker.Container, labels []string) (map[string]string, error) {
var globalErr error
foundLabels := map[string]string{}
for _, label := range labels {
foundLabel, err := provider.getLabel(container, label)
// Error out only if one of them is defined.
if err != nil {
return nil, errors.New("Label not found: " + label)
globalErr = errors.New("Label not found: " + label)
continue
}
foundLabels[label] = foundLabel
}
return foundLabels, nil
return foundLabels, globalErr
}
// GetFrontendValue returns the frontend value for the specified container, using