Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(constraints): Supports constraints for docker backend #438

Merged
merged 2 commits into from
Jun 12, 2016

Conversation

samber
Copy link
Contributor

@samber samber commented Jun 6, 2016

Related to #311 #342

[docker]
endpoint = "unix:///var/run/docker.sock"
constraints = ["tag==api", "tag==he*ld"]
$ docker run -d -P --label traefik.tags=api,helloworld emilevauge/whoami

@samber samber mentioned this pull request Jun 6, 2016
7 tasks
@samber samber force-pushed the TRAEFIK-311--support-docker-backend branch 2 times, most recently from 74bc7bc to d469723 Compare June 7, 2016 06:19
@@ -213,6 +215,15 @@ func containerFilter(container dockertypes.ContainerJSON) bool {
return false
}

constraintTags := strings.Split(container.Config.Labels["traefik.tags"], ",")
ok, failingConstraint := provider.MatchConstraints(constraintTags)
if ok == false {
Copy link
Member

@emilevauge emilevauge Jun 7, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok == false => !ok
or even

if ok, failingConstraint := provider.MatchConstraints(constraintTags); !ok {
...
}

@emilevauge
Copy link
Member

One minor comment.
Other than that, LGTM :)
Thanks @samber !
/cc @vdemeester

@vdemeester
Copy link
Contributor

LGTM 🐼 with @emilevauge's comment taken care of and a rebase 👼

@vdemeester vdemeester added this to the 1.0 milestone Jun 7, 2016
@tiagostutz
Copy link

Humm, I'm trying to use the suggested syntax but it is not working. Error log:

Error reading TOML config file /etc/traefik/traefik.toml : Type mismatch for 'main.TraefikConfiguration.Docker': Type mismatch for 'provider.Docker.Constraints': Type mismatch for types.Constraint. Expected map but found 'string'.

But I found a workaround (maybe a workaround) configuring the Constraints globally, described at #451.

Can you point what's the correct TOML syntax to configure constraints inside [docker] section?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants