{"action":"created","comment":{"url":"https://api.github.com/repos/containous/traefik/pulls/comments/179962180","pull_request_review_id":110300920,"id":179962180,"diff_hunk":"@@ -454,18 +458,23 @@ func getTLS(ingress *extensionsv1beta1.Ingress, k8sClient Client) ([]*tls.Config\n \treturn tlsConfigs, nil\n }\n \n-func endpointPortNumber(servicePort corev1.ServicePort, endpointPorts []corev1.EndpointPort) int {\n-\tif len(endpointPorts) > 0 {\n-\t\t// name is optional if there is only one port\n-\t\tport := endpointPorts[0]\n-\t\tfor _, endpointPort := range endpointPorts {\n-\t\t\tif servicePort.Name == endpointPort.Name {\n-\t\t\t\tport = endpointPort\n-\t\t\t}\n+// endpointPortNumber returns the port to be used for this endpoint. It is zero\n+// if the endpoint does not match the given service port.\n+func endpointPortNumber(servicePort corev1.ServicePort, endpointPorts []corev1.EndpointPort) int32 {\n+\t// Is this reasonable to assume?\n+\tif len(endpointPorts) == 0 {\n+\t\treturn servicePort.Port\n+\t}\n+\n+\tfor _, endpointPort := range endpointPorts {\n+\t\t// For matching endpoints, the port names must correspond, either by\n+\t\t// being empty or non-empty. Multi-port services mandate non-empty\n+\t\t// names and allow us to filter for the right addresses.\n+\t\tif servicePort.Name == endpointPort.Name {\n+\t\t\treturn endpointPort.Port\n \t\t}\n-\t\treturn int(port.Port)\n \t}\n-\treturn int(servicePort.Port)\n+\treturn 0","path":"provider/kubernetes/kubernetes.go","position":53,"original_position":53,"commit_id":"91a3c1caa35d1e1d64c0e3a46262ce9c1f0d4716","original_commit_id":"91a3c1caa35d1e1d64c0e3a46262ce9c1f0d4716","user":{"login":"timoreimann","id":694826,"avatar_url":"https://avatars1.githubusercontent.com/u/694826?v=4","gravatar_id":"","url":"https://api.github.com/users/timoreimann","html_url":"https://github.com/timoreimann","followers_url":"https://api.github.com/users/timoreimann/followers","following_url":"https://api.github.com/users/timoreimann/following{/other_user}","gists_url":"https://api.github.com/users/timoreimann/gists{/gist_id}","starred_url":"https://api.github.com/users/timoreimann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timoreimann/subscriptions","organizations_url":"https://api.github.com/users/timoreimann/orgs","repos_url":"https://api.github.com/users/timoreimann/repos","events_url":"https://api.github.com/users/timoreimann/events{/privacy}","received_events_url":"https://api.github.com/users/timoreimann/received_events","type":"User","site_admin":false},"body":"As [explained above](https://github.com/containous/traefik/pull/3121#discussion_r179962156), it's not an error but completely legitimate if we can't find a match. For such cases, it's common to return a special value denoting a \"not found\" state. For instance, [`strings.Index`](https://golang.org/pkg/strings/#Index) from the stdlib does the same.\r\n\r\nWe could also use the \"comma ok\" idiom (i.e., return an integer and a boolean where the latter indicates if a value was found). Looking at the stdlib again, however, that's only really used when a special value cannot be employed (such as for map lookups).\r\n\r\nPersonally, I find the chosen approach simple and idiomatic. I also made sure to document the return value semantics in the function's GoDoc.","created_at":"2018-04-08T21:36:14Z","updated_at":"2018-04-08T21:36:14Z","html_url":"https://github.com/containous/traefik/pull/3121#discussion_r179962180","pull_request_url":"https://api.github.com/repos/containous/traefik/pulls/3121","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/containous/traefik/pulls/comments/179962180"},"html":{"href":"https://github.com/containous/traefik/pull/3121#discussion_r179962180"},"pull_request":{"href":"https://api.github.com/repos/containous/traefik/pulls/3121"}},"in_reply_to_id":179901479},"pull_request":{"url":"https://api.github.com/repos/containous/traefik/pulls/3121","id":179215404,"html_url":"https://github.com/containous/traefik/pull/3121","diff_url":"https://github.com/containous/traefik/pull/3121.diff","patch_url":"https://github.com/containous/traefik/pull/3121.patch","issue_url":"https://api.github.com/repos/containous/traefik/issues/3121","number":3121,"state":"open","locked":false,"title":"Support multi-port services.","user":{"login":"timoreimann","id":694826,"avatar_url":"https://avatars1.githubusercontent.com/u/694826?v=4","gravatar_id":"","url":"https://api.github.com/users/timoreimann","html_url":"https://github.com/timoreimann","followers_url":"https://api.github.com/users/timoreimann/followers","following_url":"https://api.github.com/users/timoreimann/following{/other_user}","gists_url":"https://api.github.com/users/timoreimann/gists{/gist_id}","starred_url":"https://api.github.com/users/timoreimann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timoreimann/subscriptions","organizations_url":"https://api.github.com/users/timoreimann/orgs","repos_url":"https://api.github.com/users/timoreimann/repos","events_url":"https://api.github.com/users/timoreimann/events{/privacy}","received_events_url":"https://api.github.com/users/timoreimann/received_events","type":"User","site_admin":false},"body":"### What does this PR do?\r\n\r\nSupport Kubernetes services with multiple defined ports.\r\n\r\n### Motivation\r\n\r\n- enable more compact port definitions\r\n- be aligned with the existing Service routing behavior\r\n\r\n### More\r\n\r\n- [x] Added/updated tests\r\n- ~[ ] Added/updated documentation~ (not needed as we simply match what upstream Kubernetes already does on Service objects)\r\n\r\nFixes #3118.","created_at":"2018-04-03T20:47:06Z","updated_at":"2018-04-08T21:36:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a44383cfaf126cb0074b3ec594182454f25340b9","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":410567211,"url":"https://api.github.com/repos/containous/traefik/labels/area/provider/k8s","name":"area/provider/k8s","color":"d4c5f9","default":false},{"id":265969105,"url":"https://api.github.com/repos/containous/traefik/labels/contributor/waiting-for-corrections","name":"contributor/waiting-for-corrections","color":"0052cc","default":false},{"id":259872488,"url":"https://api.github.com/repos/containous/traefik/labels/kind/enhancement","name":"kind/enhancement","color":"84b6eb","default":false},{"id":602267762,"url":"https://api.github.com/repos/containous/traefik/labels/size/M","name":"size/M","color":"fbca04","default":false},{"id":265100437,"url":"https://api.github.com/repos/containous/traefik/labels/status/1-needs-design-review","name":"status/1-needs-design-review","color":"fef2c0","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/containous/traefik/pulls/3121/commits","review_comments_url":"https://api.github.com/repos/containous/traefik/pulls/3121/comments","review_comment_url":"https://api.github.com/repos/containous/traefik/pulls/comments{/number}","comments_url":"https://api.github.com/repos/containous/traefik/issues/3121/comments","statuses_url":"https://api.github.com/repos/containous/traefik/statuses/91a3c1caa35d1e1d64c0e3a46262ce9c1f0d4716","head":{"label":"timoreimann:kubernetes-support-multiport-services","ref":"kubernetes-support-multiport-services","sha":"91a3c1caa35d1e1d64c0e3a46262ce9c1f0d4716","user":{"login":"timoreimann","id":694826,"avatar_url":"https://avatars1.githubusercontent.com/u/694826?v=4","gravatar_id":"","url":"https://api.github.com/users/timoreimann","html_url":"https://github.com/timoreimann","followers_url":"https://api.github.com/users/timoreimann/followers","following_url":"https://api.github.com/users/timoreimann/following{/other_user}","gists_url":"https://api.github.com/users/timoreimann/gists{/gist_id}","starred_url":"https://api.github.com/users/timoreimann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timoreimann/subscriptions","organizations_url":"https://api.github.com/users/timoreimann/orgs","repos_url":"https://api.github.com/users/timoreimann/repos","events_url":"https://api.github.com/users/timoreimann/events{/privacy}","received_events_url":"https://api.github.com/users/timoreimann/received_events","type":"User","site_admin":false},"repo":{"id":79962881,"name":"traefik","full_name":"timoreimann/traefik","owner":{"login":"timoreimann","id":694826,"avatar_url":"https://avatars1.githubusercontent.com/u/694826?v=4","gravatar_id":"","url":"https://api.github.com/users/timoreimann","html_url":"https://github.com/timoreimann","followers_url":"https://api.github.com/users/timoreimann/followers","following_url":"https://api.github.com/users/timoreimann/following{/other_user}","gists_url":"https://api.github.com/users/timoreimann/gists{/gist_id}","starred_url":"https://api.github.com/users/timoreimann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timoreimann/subscriptions","organizations_url":"https://api.github.com/users/timoreimann/orgs","repos_url":"https://api.github.com/users/timoreimann/repos","events_url":"https://api.github.com/users/timoreimann/events{/privacy}","received_events_url":"https://api.github.com/users/timoreimann/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/timoreimann/traefik","description":"Træfɪk, a modern reverse proxy","fork":true,"url":"https://api.github.com/repos/timoreimann/traefik","forks_url":"https://api.github.com/repos/timoreimann/traefik/forks","keys_url":"https://api.github.com/repos/timoreimann/traefik/keys{/key_id}","collaborators_url":"https://api.github.com/repos/timoreimann/traefik/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/timoreimann/traefik/teams","hooks_url":"https://api.github.com/repos/timoreimann/traefik/hooks","issue_events_url":"https://api.github.com/repos/timoreimann/traefik/issues/events{/number}","events_url":"https://api.github.com/repos/timoreimann/traefik/events","assignees_url":"https://api.github.com/repos/timoreimann/traefik/assignees{/user}","branches_url":"https://api.github.com/repos/timoreimann/traefik/branches{/branch}","tags_url":"https://api.github.com/repos/timoreimann/traefik/tags","blobs_url":"https://api.github.com/repos/timoreimann/traefik/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/timoreimann/traefik/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/timoreimann/traefik/git/refs{/sha}","trees_url":"https://api.github.com/repos/timoreimann/traefik/git/trees{/sha}","statuses_url":"https://api.github.com/repos/timoreimann/traefik/statuses/{sha}","languages_url":"https://api.github.com/repos/timoreimann/traefik/languages","stargazers_url":"https://api.github.com/repos/timoreimann/traefik/stargazers","contributors_url":"https://api.github.com/repos/timoreimann/traefik/contributors","subscribers_url":"https://api.github.com/repos/timoreimann/traefik/subscribers","subscription_url":"https://api.github.com/repos/timoreimann/traefik/subscription","commits_url":"https://api.github.com/repos/timoreimann/traefik/commits{/sha}","git_commits_url":"https://api.github.com/repos/timoreimann/traefik/git/commits{/sha}","comments_url":"https://api.github.com/repos/timoreimann/traefik/comments{/number}","issue_comment_url":"https://api.github.com/repos/timoreimann/traefik/issues/comments{/number}","contents_url":"https://api.github.com/repos/timoreimann/traefik/contents/{+path}","compare_url":"https://api.github.com/repos/timoreimann/traefik/compare/{base}...{head}","merges_url":"https://api.github.com/repos/timoreimann/traefik/merges","archive_url":"https://api.github.com/repos/timoreimann/traefik/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/timoreimann/traefik/downloads","issues_url":"https://api.github.com/repos/timoreimann/traefik/issues{/number}","pulls_url":"https://api.github.com/repos/timoreimann/traefik/pulls{/number}","milestones_url":"https://api.github.com/repos/timoreimann/traefik/milestones{/number}","notifications_url":"https://api.github.com/repos/timoreimann/traefik/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/timoreimann/traefik/labels{/name}","releases_url":"https://api.github.com/repos/timoreimann/traefik/releases{/id}","deployments_url":"https://api.github.com/repos/timoreimann/traefik/deployments","created_at":"2017-01-24T22:56:23Z","updated_at":"2017-01-24T22:56:27Z","pushed_at":"2018-04-07T23:28:20Z","git_url":"git://github.com/timoreimann/traefik.git","ssh_url":"git@github.com:timoreimann/traefik.git","clone_url":"https://github.com/timoreimann/traefik.git","svn_url":"https://github.com/timoreimann/traefik","homepage":"https://traefik.io/","size":58037,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"containous:master","ref":"master","sha":"30b87985b720f819cf2817d1924fabe802bb1783","user":{"login":"containous","id":16349663,"avatar_url":"https://avatars3.githubusercontent.com/u/16349663?v=4","gravatar_id":"","url":"https://api.github.com/users/containous","html_url":"https://github.com/containous","followers_url":"https://api.github.com/users/containous/followers","following_url":"https://api.github.com/users/containous/following{/other_user}","gists_url":"https://api.github.com/users/containous/gists{/gist_id}","starred_url":"https://api.github.com/users/containous/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/containous/subscriptions","organizations_url":"https://api.github.com/users/containous/orgs","repos_url":"https://api.github.com/users/containous/repos","events_url":"https://api.github.com/users/containous/events{/privacy}","received_events_url":"https://api.github.com/users/containous/received_events","type":"Organization","site_admin":false},"repo":{"id":42408804,"name":"traefik","full_name":"containous/traefik","owner":{"login":"containous","id":16349663,"avatar_url":"https://avatars3.githubusercontent.com/u/16349663?v=4","gravatar_id":"","url":"https://api.github.com/users/containous","html_url":"https://github.com/containous","followers_url":"https://api.github.com/users/containous/followers","following_url":"https://api.github.com/users/containous/following{/other_user}","gists_url":"https://api.github.com/users/containous/gists{/gist_id}","starred_url":"https://api.github.com/users/containous/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/containous/subscriptions","organizations_url":"https://api.github.com/users/containous/orgs","repos_url":"https://api.github.com/users/containous/repos","events_url":"https://api.github.com/users/containous/events{/privacy}","received_events_url":"https://api.github.com/users/containous/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/containous/traefik","description":"Træfik, a modern reverse proxy","fork":false,"url":"https://api.github.com/repos/containous/traefik","forks_url":"https://api.github.com/repos/containous/traefik/forks","keys_url":"https://api.github.com/repos/containous/traefik/keys{/key_id}","collaborators_url":"https://api.github.com/repos/containous/traefik/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/containous/traefik/teams","hooks_url":"https://api.github.com/repos/containous/traefik/hooks","issue_events_url":"https://api.github.com/repos/containous/traefik/issues/events{/number}","events_url":"https://api.github.com/repos/containous/traefik/events","assignees_url":"https://api.github.com/repos/containous/traefik/assignees{/user}","branches_url":"https://api.github.com/repos/containous/traefik/branches{/branch}","tags_url":"https://api.github.com/repos/containous/traefik/tags","blobs_url":"https://api.github.com/repos/containous/traefik/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/containous/traefik/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/containous/traefik/git/refs{/sha}","trees_url":"https://api.github.com/repos/containous/traefik/git/trees{/sha}","statuses_url":"https://api.github.com/repos/containous/traefik/statuses/{sha}","languages_url":"https://api.github.com/repos/containous/traefik/languages","stargazers_url":"https://api.github.com/repos/containous/traefik/stargazers","contributors_url":"https://api.github.com/repos/containous/traefik/contributors","subscribers_url":"https://api.github.com/repos/containous/traefik/subscribers","subscription_url":"https://api.github.com/repos/containous/traefik/subscription","commits_url":"https://api.github.com/repos/containous/traefik/commits{/sha}","git_commits_url":"https://api.github.com/repos/containous/traefik/git/commits{/sha}","comments_url":"https://api.github.com/repos/containous/traefik/comments{/number}","issue_comment_url":"https://api.github.com/repos/containous/traefik/issues/comments{/number}","contents_url":"https://api.github.com/repos/containous/traefik/contents/{+path}","compare_url":"https://api.github.com/repos/containous/traefik/compare/{base}...{head}","merges_url":"https://api.github.com/repos/containous/traefik/merges","archive_url":"https://api.github.com/repos/containous/traefik/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/containous/traefik/downloads","issues_url":"https://api.github.com/repos/containous/traefik/issues{/number}","pulls_url":"https://api.github.com/repos/containous/traefik/pulls{/number}","milestones_url":"https://api.github.com/repos/containous/traefik/milestones{/number}","notifications_url":"https://api.github.com/repos/containous/traefik/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/containous/traefik/labels{/name}","releases_url":"https://api.github.com/repos/containous/traefik/releases{/id}","deployments_url":"https://api.github.com/repos/containous/traefik/deployments","created_at":"2015-09-13T19:04:02Z","updated_at":"2018-04-08T20:45:29Z","pushed_at":"2018-04-08T11:01:57Z","git_url":"git://github.com/containous/traefik.git","ssh_url":"git@github.com:containous/traefik.git","clone_url":"https://github.com/containous/traefik.git","svn_url":"https://github.com/containous/traefik","homepage":"https://traefik.io","size":26258,"stargazers_count":14319,"watchers_count":14319,"language":"Go","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1399,"mirror_url":null,"archived":false,"open_issues_count":296,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":1399,"open_issues":296,"watchers":14319,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/containous/traefik/pulls/3121"},"html":{"href":"https://github.com/containous/traefik/pull/3121"},"issue":{"href":"https://api.github.com/repos/containous/traefik/issues/3121"},"comments":{"href":"https://api.github.com/repos/containous/traefik/issues/3121/comments"},"review_comments":{"href":"https://api.github.com/repos/containous/traefik/pulls/3121/comments"},"review_comment":{"href":"https://api.github.com/repos/containous/traefik/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/containous/traefik/pulls/3121/commits"},"statuses":{"href":"https://api.github.com/repos/containous/traefik/statuses/91a3c1caa35d1e1d64c0e3a46262ce9c1f0d4716"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"timoreimann"}}