{"action":"created","comment":{"url":"https://api.github.com/repos/emilevauge/traefik/pulls/comments/43866630","id":43866630,"diff_hunk":"@@ -1,15 +1,140 @@\n package main\n \n import (\n+\t\"encoding/json\"\n+\t\"fmt\"\n+\t\"io/ioutil\"\n \t\"net/http\"\n \t\"os\"\n \t\"os/exec\"\n \t\"time\"\n \n+\t\"github.com/docker/docker/opts\"\n+\t\"github.com/docker/docker/pkg/namesgenerator\"\n+\t\"github.com/fsouza/go-dockerclient\"\n \tchecker \"github.com/vdemeester/shakers\"\n \tcheck \"gopkg.in/check.v1\"\n )\n \n+var (\n+\t// Label added to started container to identify them as part of the integration test\n+\tTestLabel = \"io.traefik.test\"\n+\n+\t// Images to have or pull before the build in order to make it work\n+\t// FIXME handle this offline but loading them before build\n+\tRequiredImages = map[string]string{\n+\t\t\"swarm\": \"1.0.0\",\n+\t\t\"nginx\": \"1\",\n+\t}\n+)\n+\n+// Docker test suites\n+type DockerSuite struct {\n+\tBaseSuite\n+\tclient *docker.Client\n+}\n+\n+func (s *DockerSuite) startContainer(c *check.C, image string, args ...string) string {\n+\treturn s.startContainerWithConfig(c, docker.CreateContainerOptions{\n+\t\tConfig: &docker.Config{\n+\t\t\tImage: image,\n+\t\t\tCmd:   args,\n+\t\t},\n+\t})\n+}\n+\n+func (s *DockerSuite) startContainerWithLabels(c *check.C, image string, labels map[string]string, args ...string) string {\n+\treturn s.startContainerWithConfig(c, docker.CreateContainerOptions{\n+\t\tConfig: &docker.Config{\n+\t\t\tImage:  image,\n+\t\t\tCmd:    args,\n+\t\t\tLabels: labels,\n+\t\t},\n+\t})\n+}\n+\n+func (s *DockerSuite) startContainerWithConfig(c *check.C, config docker.CreateContainerOptions) string {\n+\tif config.Name == \"\" {\n+\t\tconfig.Name = namesgenerator.GetRandomName(10)\n+\t}\n+\tif config.Config.Labels == nil {\n+\t\tconfig.Config.Labels = map[string]string{}\n+\t}\n+\tconfig.Config.Labels[TestLabel] = \"true\"\n+\n+\tcontainer, err := s.client.CreateContainer(config)\n+\tc.Assert(err, checker.IsNil, check.Commentf(\"Error creating a container using config %v\", config))\n+\n+\terr = s.client.StartContainer(container.ID, &docker.HostConfig{})\n+\tc.Assert(err, checker.IsNil, check.Commentf(\"Error starting container %v\", container))\n+\n+\treturn container.Name\n+}\n+\n+func (s *DockerSuite) SetUpSuite(c *check.C) {\n+\tdockerHost := os.Getenv(\"DOCKER_HOST\")\n+\tif dockerHost == \"\" {\n+\t\t// FIXME Handle windows -- see if dockerClient already handle that or not\n+\t\tdockerHost = fmt.Sprintf(\"unix://%s\", opts.DefaultUnixSocket)\n+\t}\n+\t// Make sure we can speak to docker\n+\tdockerClient, err := docker.NewClient(dockerHost)\n+\tc.Assert(err, checker.IsNil, check.Commentf(\"Error connecting to docker daemon\"))\n+\n+\ts.client = dockerClient\n+\tc.Assert(s.client.Ping(), checker.IsNil)\n+\n+\t// Pull required images\n+\tfor repository, tag := range RequiredImages {\n+\t\timage := fmt.Sprintf(\"%s:%s\", repository, tag)\n+\t\t_, err := s.client.InspectImage(image)\n+\t\tif err != nil {\n+\t\t\tif err != docker.ErrNoSuchImage {\n+\t\t\t\tc.Fatalf(\"Error while inspect image %s\", image)\n+\t\t\t}\n+\t\t\terr = s.client.PullImage(docker.PullImageOptions{\n+\t\t\t\tRepository: repository,\n+\t\t\t\tTag:        tag,\n+\t\t\t}, docker.AuthConfiguration{})\n+\t\t\tc.Assert(err, checker.IsNil, check.Commentf(\"Error while pulling image %s\", image))\n+\t\t}\n+\t}\n+}\n+\n+func (s *DockerSuite) cleanContainers(c *check.C) {\n+\t// Clean the mess, a.k.a. the running containers with the right label\n+\tcontainerList, err := s.client.ListContainers(docker.ListContainersOptions{\n+\t\tFilters: map[string][]string{\n+\t\t\t\"label\": {fmt.Sprintf(\"%s=true\", TestLabel)},\n+\t\t},\n+\t})\n+\tc.Assert(err, checker.IsNil, check.Commentf(\"Error listing containers started by traefik\"))\n+\n+\tfor _, container := range containerList {\n+\t\terr = s.client.KillContainer(docker.KillContainerOptions{\n+\t\t\tID: container.ID,\n+\t\t})\n+\t\tc.Assert(err, checker.IsNil, check.Commentf(\"Error killing container %v\", container))\n+\t\tif os.Getenv(\"CIRCLECI\") == \"\" {","path":"integration/docker_test.go","position":118,"original_position":118,"commit_id":"31f4aa8625626205af61f72016e06c91bcda53b3","original_commit_id":"31f4aa8625626205af61f72016e06c91bcda53b3","user":{"login":"vdemeester","id":6508,"avatar_url":"https://avatars.githubusercontent.com/u/6508?v=3","gravatar_id":"","url":"https://api.github.com/users/vdemeester","html_url":"https://github.com/vdemeester","followers_url":"https://api.github.com/users/vdemeester/followers","following_url":"https://api.github.com/users/vdemeester/following{/other_user}","gists_url":"https://api.github.com/users/vdemeester/gists{/gist_id}","starred_url":"https://api.github.com/users/vdemeester/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vdemeester/subscriptions","organizations_url":"https://api.github.com/users/vdemeester/orgs","repos_url":"https://api.github.com/users/vdemeester/repos","events_url":"https://api.github.com/users/vdemeester/events{/privacy}","received_events_url":"https://api.github.com/users/vdemeester/received_events","type":"User","site_admin":false},"body":"This is *sooooo* bad :sweat: ","created_at":"2015-11-04T11:00:49Z","updated_at":"2015-11-04T11:00:49Z","html_url":"https://github.com/emilevauge/traefik/pull/94#discussion_r43866630","pull_request_url":"https://api.github.com/repos/emilevauge/traefik/pulls/94","_links":{"self":{"href":"https://api.github.com/repos/emilevauge/traefik/pulls/comments/43866630"},"html":{"href":"https://github.com/emilevauge/traefik/pull/94#discussion_r43866630"},"pull_request":{"href":"https://api.github.com/repos/emilevauge/traefik/pulls/94"}}},"pull_request":{"url":"https://api.github.com/repos/emilevauge/traefik/pulls/94","id":49673351,"html_url":"https://github.com/emilevauge/traefik/pull/94","diff_url":"https://github.com/emilevauge/traefik/pull/94.diff","patch_url":"https://github.com/emilevauge/traefik/pull/94.patch","issue_url":"https://api.github.com/repos/emilevauge/traefik/issues/94","number":94,"state":"open","locked":false,"title":"Fix docker labels (frontend.*) non-presence","user":{"login":"vdemeester","id":6508,"avatar_url":"https://avatars.githubusercontent.com/u/6508?v=3","gravatar_id":"","url":"https://api.github.com/users/vdemeester","html_url":"https://github.com/vdemeester","followers_url":"https://api.github.com/users/vdemeester/followers","following_url":"https://api.github.com/users/vdemeester/following{/other_user}","gists_url":"https://api.github.com/users/vdemeester/gists{/gist_id}","starred_url":"https://api.github.com/users/vdemeester/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vdemeester/subscriptions","organizations_url":"https://api.github.com/users/vdemeester/orgs","repos_url":"https://api.github.com/users/vdemeester/repos","events_url":"https://api.github.com/users/vdemeester/events{/privacy}","received_events_url":"https://api.github.com/users/vdemeester/received_events","type":"User","site_admin":false},"body":"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).\r\n\r\n- Fixes this behavior.\r\n- Add integration tests for it, and some helper function for DockerSuite.\r\n\r\nSigned-off-by: Vincent Demeester <vincent@sbr.pm>","created_at":"2015-11-04T10:49:51Z","updated_at":"2015-11-04T11:00:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"47d7483901b646af1f52095928a9ee2d43e59508","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/emilevauge/traefik/pulls/94/commits","review_comments_url":"https://api.github.com/repos/emilevauge/traefik/pulls/94/comments","review_comment_url":"https://api.github.com/repos/emilevauge/traefik/pulls/comments{/number}","comments_url":"https://api.github.com/repos/emilevauge/traefik/issues/94/comments","statuses_url":"https://api.github.com/repos/emilevauge/traefik/statuses/31f4aa8625626205af61f72016e06c91bcda53b3","head":{"label":"vdemeester:fix-labels-docker","ref":"fix-labels-docker","sha":"31f4aa8625626205af61f72016e06c91bcda53b3","user":{"login":"vdemeester","id":6508,"avatar_url":"https://avatars.githubusercontent.com/u/6508?v=3","gravatar_id":"","url":"https://api.github.com/users/vdemeester","html_url":"https://github.com/vdemeester","followers_url":"https://api.github.com/users/vdemeester/followers","following_url":"https://api.github.com/users/vdemeester/following{/other_user}","gists_url":"https://api.github.com/users/vdemeester/gists{/gist_id}","starred_url":"https://api.github.com/users/vdemeester/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vdemeester/subscriptions","organizations_url":"https://api.github.com/users/vdemeester/orgs","repos_url":"https://api.github.com/users/vdemeester/repos","events_url":"https://api.github.com/users/vdemeester/events{/privacy}","received_events_url":"https://api.github.com/users/vdemeester/received_events","type":"User","site_admin":false},"repo":{"id":42470355,"name":"traefik","full_name":"vdemeester/traefik","owner":{"login":"vdemeester","id":6508,"avatar_url":"https://avatars.githubusercontent.com/u/6508?v=3","gravatar_id":"","url":"https://api.github.com/users/vdemeester","html_url":"https://github.com/vdemeester","followers_url":"https://api.github.com/users/vdemeester/followers","following_url":"https://api.github.com/users/vdemeester/following{/other_user}","gists_url":"https://api.github.com/users/vdemeester/gists{/gist_id}","starred_url":"https://api.github.com/users/vdemeester/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vdemeester/subscriptions","organizations_url":"https://api.github.com/users/vdemeester/orgs","repos_url":"https://api.github.com/users/vdemeester/repos","events_url":"https://api.github.com/users/vdemeester/events{/privacy}","received_events_url":"https://api.github.com/users/vdemeester/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vdemeester/traefik","description":"Træfɪk, a modern reverse proxy","fork":true,"url":"https://api.github.com/repos/vdemeester/traefik","forks_url":"https://api.github.com/repos/vdemeester/traefik/forks","keys_url":"https://api.github.com/repos/vdemeester/traefik/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vdemeester/traefik/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vdemeester/traefik/teams","hooks_url":"https://api.github.com/repos/vdemeester/traefik/hooks","issue_events_url":"https://api.github.com/repos/vdemeester/traefik/issues/events{/number}","events_url":"https://api.github.com/repos/vdemeester/traefik/events","assignees_url":"https://api.github.com/repos/vdemeester/traefik/assignees{/user}","branches_url":"https://api.github.com/repos/vdemeester/traefik/branches{/branch}","tags_url":"https://api.github.com/repos/vdemeester/traefik/tags","blobs_url":"https://api.github.com/repos/vdemeester/traefik/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vdemeester/traefik/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vdemeester/traefik/git/refs{/sha}","trees_url":"https://api.github.com/repos/vdemeester/traefik/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vdemeester/traefik/statuses/{sha}","languages_url":"https://api.github.com/repos/vdemeester/traefik/languages","stargazers_url":"https://api.github.com/repos/vdemeester/traefik/stargazers","contributors_url":"https://api.github.com/repos/vdemeester/traefik/contributors","subscribers_url":"https://api.github.com/repos/vdemeester/traefik/subscribers","subscription_url":"https://api.github.com/repos/vdemeester/traefik/subscription","commits_url":"https://api.github.com/repos/vdemeester/traefik/commits{/sha}","git_commits_url":"https://api.github.com/repos/vdemeester/traefik/git/commits{/sha}","comments_url":"https://api.github.com/repos/vdemeester/traefik/comments{/number}","issue_comment_url":"https://api.github.com/repos/vdemeester/traefik/issues/comments{/number}","contents_url":"https://api.github.com/repos/vdemeester/traefik/contents/{+path}","compare_url":"https://api.github.com/repos/vdemeester/traefik/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vdemeester/traefik/merges","archive_url":"https://api.github.com/repos/vdemeester/traefik/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vdemeester/traefik/downloads","issues_url":"https://api.github.com/repos/vdemeester/traefik/issues{/number}","pulls_url":"https://api.github.com/repos/vdemeester/traefik/pulls{/number}","milestones_url":"https://api.github.com/repos/vdemeester/traefik/milestones{/number}","notifications_url":"https://api.github.com/repos/vdemeester/traefik/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vdemeester/traefik/labels{/name}","releases_url":"https://api.github.com/repos/vdemeester/traefik/releases{/id}","created_at":"2015-09-14T18:59:29Z","updated_at":"2015-09-14T18:59:29Z","pushed_at":"2015-11-04T10:59:43Z","git_url":"git://github.com/vdemeester/traefik.git","ssh_url":"git@github.com:vdemeester/traefik.git","clone_url":"https://github.com/vdemeester/traefik.git","svn_url":"https://github.com/vdemeester/traefik","homepage":"","size":2439,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"emilevauge:master","ref":"master","sha":"7be566ef7cd754f42978ef92d9270d6236af913b","user":{"login":"emilevauge","id":6207234,"avatar_url":"https://avatars.githubusercontent.com/u/6207234?v=3","gravatar_id":"","url":"https://api.github.com/users/emilevauge","html_url":"https://github.com/emilevauge","followers_url":"https://api.github.com/users/emilevauge/followers","following_url":"https://api.github.com/users/emilevauge/following{/other_user}","gists_url":"https://api.github.com/users/emilevauge/gists{/gist_id}","starred_url":"https://api.github.com/users/emilevauge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emilevauge/subscriptions","organizations_url":"https://api.github.com/users/emilevauge/orgs","repos_url":"https://api.github.com/users/emilevauge/repos","events_url":"https://api.github.com/users/emilevauge/events{/privacy}","received_events_url":"https://api.github.com/users/emilevauge/received_events","type":"User","site_admin":false},"repo":{"id":42408804,"name":"traefik","full_name":"emilevauge/traefik","owner":{"login":"emilevauge","id":6207234,"avatar_url":"https://avatars.githubusercontent.com/u/6207234?v=3","gravatar_id":"","url":"https://api.github.com/users/emilevauge","html_url":"https://github.com/emilevauge","followers_url":"https://api.github.com/users/emilevauge/followers","following_url":"https://api.github.com/users/emilevauge/following{/other_user}","gists_url":"https://api.github.com/users/emilevauge/gists{/gist_id}","starred_url":"https://api.github.com/users/emilevauge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emilevauge/subscriptions","organizations_url":"https://api.github.com/users/emilevauge/orgs","repos_url":"https://api.github.com/users/emilevauge/repos","events_url":"https://api.github.com/users/emilevauge/events{/privacy}","received_events_url":"https://api.github.com/users/emilevauge/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/emilevauge/traefik","description":"Træfɪk, a modern reverse proxy","fork":false,"url":"https://api.github.com/repos/emilevauge/traefik","forks_url":"https://api.github.com/repos/emilevauge/traefik/forks","keys_url":"https://api.github.com/repos/emilevauge/traefik/keys{/key_id}","collaborators_url":"https://api.github.com/repos/emilevauge/traefik/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/emilevauge/traefik/teams","hooks_url":"https://api.github.com/repos/emilevauge/traefik/hooks","issue_events_url":"https://api.github.com/repos/emilevauge/traefik/issues/events{/number}","events_url":"https://api.github.com/repos/emilevauge/traefik/events","assignees_url":"https://api.github.com/repos/emilevauge/traefik/assignees{/user}","branches_url":"https://api.github.com/repos/emilevauge/traefik/branches{/branch}","tags_url":"https://api.github.com/repos/emilevauge/traefik/tags","blobs_url":"https://api.github.com/repos/emilevauge/traefik/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/emilevauge/traefik/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/emilevauge/traefik/git/refs{/sha}","trees_url":"https://api.github.com/repos/emilevauge/traefik/git/trees{/sha}","statuses_url":"https://api.github.com/repos/emilevauge/traefik/statuses/{sha}","languages_url":"https://api.github.com/repos/emilevauge/traefik/languages","stargazers_url":"https://api.github.com/repos/emilevauge/traefik/stargazers","contributors_url":"https://api.github.com/repos/emilevauge/traefik/contributors","subscribers_url":"https://api.github.com/repos/emilevauge/traefik/subscribers","subscription_url":"https://api.github.com/repos/emilevauge/traefik/subscription","commits_url":"https://api.github.com/repos/emilevauge/traefik/commits{/sha}","git_commits_url":"https://api.github.com/repos/emilevauge/traefik/git/commits{/sha}","comments_url":"https://api.github.com/repos/emilevauge/traefik/comments{/number}","issue_comment_url":"https://api.github.com/repos/emilevauge/traefik/issues/comments{/number}","contents_url":"https://api.github.com/repos/emilevauge/traefik/contents/{+path}","compare_url":"https://api.github.com/repos/emilevauge/traefik/compare/{base}...{head}","merges_url":"https://api.github.com/repos/emilevauge/traefik/merges","archive_url":"https://api.github.com/repos/emilevauge/traefik/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/emilevauge/traefik/downloads","issues_url":"https://api.github.com/repos/emilevauge/traefik/issues{/number}","pulls_url":"https://api.github.com/repos/emilevauge/traefik/pulls{/number}","milestones_url":"https://api.github.com/repos/emilevauge/traefik/milestones{/number}","notifications_url":"https://api.github.com/repos/emilevauge/traefik/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/emilevauge/traefik/labels{/name}","releases_url":"https://api.github.com/repos/emilevauge/traefik/releases{/id}","created_at":"2015-09-13T19:04:02Z","updated_at":"2015-11-04T07:38:33Z","pushed_at":"2015-11-04T10:59:43Z","git_url":"git://github.com/emilevauge/traefik.git","ssh_url":"git@github.com:emilevauge/traefik.git","clone_url":"https://github.com/emilevauge/traefik.git","svn_url":"https://github.com/emilevauge/traefik","homepage":"http://traefik.io/","size":3388,"stargazers_count":1157,"watchers_count":1157,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":33,"mirror_url":null,"open_issues_count":18,"forks":33,"open_issues":18,"watchers":1157,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/emilevauge/traefik/pulls/94"},"html":{"href":"https://github.com/emilevauge/traefik/pull/94"},"issue":{"href":"https://api.github.com/repos/emilevauge/traefik/issues/94"},"comments":{"href":"https://api.github.com/repos/emilevauge/traefik/issues/94/comments"},"review_comments":{"href":"https://api.github.com/repos/emilevauge/traefik/pulls/94/comments"},"review_comment":{"href":"https://api.github.com/repos/emilevauge/traefik/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/emilevauge/traefik/pulls/94/commits"},"statuses":{"href":"https://api.github.com/repos/emilevauge/traefik/statuses/31f4aa8625626205af61f72016e06c91bcda53b3"}}}}