{"action":"created","comment":{"url":"https://api.github.com/repos/kubernetes/dashboard/pulls/comments/46664675","id":46664675,"diff_hunk":"@@ -0,0 +1,93 @@\n+// Copyright 2015 Google Inc. All Rights Reserved.\n+//\n+// Licensed under the Apache License, Version 2.0 (the \"License\");\n+// you may not use this file except in compliance with the License.\n+// You may obtain a copy of the License at\n+//\n+//     http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// Unless required by applicable law or agreed to in writing, software\n+// distributed under the License is distributed on an \"AS IS\" BASIS,\n+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+// See the License for the specific language governing permissions and\n+// limitations under the License.\n+\n+package main\n+\n+import (\n+\t\"k8s.io/kubernetes/pkg/api/unversioned\"\n+\tclient \"k8s.io/kubernetes/pkg/client/unversioned\"\n+\t\"k8s.io/kubernetes/pkg/fields\"\n+\t\"k8s.io/kubernetes/pkg/labels\"\n+)\n+\n+// Information about a Container that belongs to a Pod.\n+type PodContainer struct {\n+\t// Name of a Container.\n+\tName string `json:\"name\"`\n+\n+\t// Container state.\n+\tState string `json:\"state\"`\n+\n+\t// Number of restarts.\n+\tRestartCount int `json:\"restartCount\"`\n+}\n+\n+// List of pods that belongs to a Replica Set.\n+type ReplicaSetPods struct {\n+\t// List of pods that belongs to a Replica Set.\n+\tPods []ReplicaSetPodWithContainers `json:\"pods\"`\n+}\n+\n+// Detailed information about a Pod that belongs to a Replica Set.\n+type ReplicaSetPodWithContainers struct {\n+\t// Name of the Pod.\n+\tName string `json:\"name\"`\n+\n+\t// Time the Pod has started. Empty if not started.\n+\tStartTime *unversioned.Time `json:\"startTime\"`\n+\n+\t// List of Containers that belongs to particular Pod.\n+\tPodContainers []PodContainer `json:\"podContainers\"`\n+}\n+\n+// Returns list of pods with containers for the given replica set in the given namespace.\n+func GetReplicaSetPods(client *client.Client, namespace string, name string) (\n+\t*ReplicaSetPods, error) {\n+\n+\treplicaSetPods := &ReplicaSetPods{}\n+\n+\treplicaSet, err := client.ReplicationControllers(namespace).Get(name)\n+\tif err != nil {\n+\t\treturn nil, err\n+\t}\n+\n+\tlabelSelector := labels.SelectorFromSet(replicaSet.Spec.Selector)\n+\tpods, err := client.Pods(namespace).List(labelSelector, fields.Everything())\n+\tif err != nil {\n+\t\treturn nil, err\n+\t}\n+\n+\tfor _, pod := range pods.Items {\n+\t\treplicaSetPodWithContainers := ReplicaSetPodWithContainers{\n+\t\t\tName:      pod.Name,\n+\t\t\tStartTime: pod.Status.StartTime,\n+\t\t}\n+\t\tfor _, containerStatus := range pod.Status.ContainerStatuses {\n+\t\t\tpodContainer := PodContainer{\n+\t\t\t\tName:         containerStatus.Name,\n+\t\t\t\tRestartCount: containerStatus.RestartCount,\n+\t\t\t\tState:        \"Waiting\",\n+\t\t\t}\n+\t\t\tif containerStatus.State.Running != nil {\n+\t\t\t\tpodContainer.State = \"Running\"","path":"src/app/backend/replicasetpods.go","position":83,"original_position":83,"commit_id":"197f92600310d95baf8bd0063b9c26e23eed7efe","original_commit_id":"197f92600310d95baf8bd0063b9c26e23eed7efe","user":{"login":"bryk","id":1159999,"avatar_url":"https://avatars.githubusercontent.com/u/1159999?v=3","gravatar_id":"","url":"https://api.github.com/users/bryk","html_url":"https://github.com/bryk","followers_url":"https://api.github.com/users/bryk/followers","following_url":"https://api.github.com/users/bryk/following{/other_user}","gists_url":"https://api.github.com/users/bryk/gists{/gist_id}","starred_url":"https://api.github.com/users/bryk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bryk/subscriptions","organizations_url":"https://api.github.com/users/bryk/orgs","repos_url":"https://api.github.com/users/bryk/repos","events_url":"https://api.github.com/users/bryk/events{/privacy}","received_events_url":"https://api.github.com/users/bryk/received_events","type":"User","site_admin":false},"body":"Maybe can you do state checking for all three cases here. This would improve readability.\r\n\r\nif state.Running != nil {\r\n\r\n} else if (state.Terminated != nil) {\r\n\r\n} else if (state.Waiting != nil) {\r\n\r\n} else {\r\n /// panic \r\n} ","created_at":"2015-12-04T09:49:00Z","updated_at":"2015-12-04T09:49:00Z","html_url":"https://github.com/kubernetes/dashboard/pull/124#discussion_r46664675","pull_request_url":"https://api.github.com/repos/kubernetes/dashboard/pulls/124","_links":{"self":{"href":"https://api.github.com/repos/kubernetes/dashboard/pulls/comments/46664675"},"html":{"href":"https://github.com/kubernetes/dashboard/pull/124#discussion_r46664675"},"pull_request":{"href":"https://api.github.com/repos/kubernetes/dashboard/pulls/124"}}},"pull_request":{"url":"https://api.github.com/repos/kubernetes/dashboard/pulls/124","id":52642941,"html_url":"https://github.com/kubernetes/dashboard/pull/124","diff_url":"https://github.com/kubernetes/dashboard/pull/124.diff","patch_url":"https://github.com/kubernetes/dashboard/pull/124.patch","issue_url":"https://api.github.com/repos/kubernetes/dashboard/issues/124","number":124,"state":"open","locked":false,"title":"Backend api for replica set pods (pod contains containers)","user":{"login":"zreigz","id":13030040,"avatar_url":"https://avatars.githubusercontent.com/u/13030040?v=3","gravatar_id":"","url":"https://api.github.com/users/zreigz","html_url":"https://github.com/zreigz","followers_url":"https://api.github.com/users/zreigz/followers","following_url":"https://api.github.com/users/zreigz/following{/other_user}","gists_url":"https://api.github.com/users/zreigz/gists{/gist_id}","starred_url":"https://api.github.com/users/zreigz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zreigz/subscriptions","organizations_url":"https://api.github.com/users/zreigz/orgs","repos_url":"https://api.github.com/users/zreigz/repos","events_url":"https://api.github.com/users/zreigz/events{/privacy}","received_events_url":"https://api.github.com/users/zreigz/received_events","type":"User","site_admin":false},"body":"Backend API to retrieve pods with containers for replica set. Needed for this view:\r\n![logmenu](https://cloud.githubusercontent.com/assets/13030040/11585341/3dfed0cc-9a63-11e5-8f21-62095666b593.png)\r\n","created_at":"2015-12-04T08:45:12Z","updated_at":"2015-12-04T09:49:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"96ca60ebffa906cb4cac92af0c7124b93a11ddf6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/kubernetes/dashboard/pulls/124/commits","review_comments_url":"https://api.github.com/repos/kubernetes/dashboard/pulls/124/comments","review_comment_url":"https://api.github.com/repos/kubernetes/dashboard/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kubernetes/dashboard/issues/124/comments","statuses_url":"https://api.github.com/repos/kubernetes/dashboard/statuses/197f92600310d95baf8bd0063b9c26e23eed7efe","head":{"label":"zreigz:replicaSetPods","ref":"replicaSetPods","sha":"197f92600310d95baf8bd0063b9c26e23eed7efe","user":{"login":"zreigz","id":13030040,"avatar_url":"https://avatars.githubusercontent.com/u/13030040?v=3","gravatar_id":"","url":"https://api.github.com/users/zreigz","html_url":"https://github.com/zreigz","followers_url":"https://api.github.com/users/zreigz/followers","following_url":"https://api.github.com/users/zreigz/following{/other_user}","gists_url":"https://api.github.com/users/zreigz/gists{/gist_id}","starred_url":"https://api.github.com/users/zreigz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zreigz/subscriptions","organizations_url":"https://api.github.com/users/zreigz/orgs","repos_url":"https://api.github.com/users/zreigz/repos","events_url":"https://api.github.com/users/zreigz/events{/privacy}","received_events_url":"https://api.github.com/users/zreigz/received_events","type":"User","site_admin":false},"repo":{"id":45465392,"name":"dashboard","full_name":"zreigz/dashboard","owner":{"login":"zreigz","id":13030040,"avatar_url":"https://avatars.githubusercontent.com/u/13030040?v=3","gravatar_id":"","url":"https://api.github.com/users/zreigz","html_url":"https://github.com/zreigz","followers_url":"https://api.github.com/users/zreigz/followers","following_url":"https://api.github.com/users/zreigz/following{/other_user}","gists_url":"https://api.github.com/users/zreigz/gists{/gist_id}","starred_url":"https://api.github.com/users/zreigz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zreigz/subscriptions","organizations_url":"https://api.github.com/users/zreigz/orgs","repos_url":"https://api.github.com/users/zreigz/repos","events_url":"https://api.github.com/users/zreigz/events{/privacy}","received_events_url":"https://api.github.com/users/zreigz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/zreigz/dashboard","description":"","fork":true,"url":"https://api.github.com/repos/zreigz/dashboard","forks_url":"https://api.github.com/repos/zreigz/dashboard/forks","keys_url":"https://api.github.com/repos/zreigz/dashboard/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zreigz/dashboard/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zreigz/dashboard/teams","hooks_url":"https://api.github.com/repos/zreigz/dashboard/hooks","issue_events_url":"https://api.github.com/repos/zreigz/dashboard/issues/events{/number}","events_url":"https://api.github.com/repos/zreigz/dashboard/events","assignees_url":"https://api.github.com/repos/zreigz/dashboard/assignees{/user}","branches_url":"https://api.github.com/repos/zreigz/dashboard/branches{/branch}","tags_url":"https://api.github.com/repos/zreigz/dashboard/tags","blobs_url":"https://api.github.com/repos/zreigz/dashboard/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zreigz/dashboard/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zreigz/dashboard/git/refs{/sha}","trees_url":"https://api.github.com/repos/zreigz/dashboard/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zreigz/dashboard/statuses/{sha}","languages_url":"https://api.github.com/repos/zreigz/dashboard/languages","stargazers_url":"https://api.github.com/repos/zreigz/dashboard/stargazers","contributors_url":"https://api.github.com/repos/zreigz/dashboard/contributors","subscribers_url":"https://api.github.com/repos/zreigz/dashboard/subscribers","subscription_url":"https://api.github.com/repos/zreigz/dashboard/subscription","commits_url":"https://api.github.com/repos/zreigz/dashboard/commits{/sha}","git_commits_url":"https://api.github.com/repos/zreigz/dashboard/git/commits{/sha}","comments_url":"https://api.github.com/repos/zreigz/dashboard/comments{/number}","issue_comment_url":"https://api.github.com/repos/zreigz/dashboard/issues/comments{/number}","contents_url":"https://api.github.com/repos/zreigz/dashboard/contents/{+path}","compare_url":"https://api.github.com/repos/zreigz/dashboard/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zreigz/dashboard/merges","archive_url":"https://api.github.com/repos/zreigz/dashboard/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zreigz/dashboard/downloads","issues_url":"https://api.github.com/repos/zreigz/dashboard/issues{/number}","pulls_url":"https://api.github.com/repos/zreigz/dashboard/pulls{/number}","milestones_url":"https://api.github.com/repos/zreigz/dashboard/milestones{/number}","notifications_url":"https://api.github.com/repos/zreigz/dashboard/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zreigz/dashboard/labels{/name}","releases_url":"https://api.github.com/repos/zreigz/dashboard/releases{/id}","created_at":"2015-11-03T12:35:45Z","updated_at":"2015-11-03T12:35:46Z","pushed_at":"2015-12-04T09:00:27Z","git_url":"git://github.com/zreigz/dashboard.git","ssh_url":"git@github.com:zreigz/dashboard.git","clone_url":"https://github.com/zreigz/dashboard.git","svn_url":"https://github.com/zreigz/dashboard","homepage":"","size":5264,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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":"kubernetes:master","ref":"master","sha":"7749c0705b44c2e41612519c3d8e9aa579c19e28","user":{"login":"kubernetes","id":13629408,"avatar_url":"https://avatars.githubusercontent.com/u/13629408?v=3","gravatar_id":"","url":"https://api.github.com/users/kubernetes","html_url":"https://github.com/kubernetes","followers_url":"https://api.github.com/users/kubernetes/followers","following_url":"https://api.github.com/users/kubernetes/following{/other_user}","gists_url":"https://api.github.com/users/kubernetes/gists{/gist_id}","starred_url":"https://api.github.com/users/kubernetes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kubernetes/subscriptions","organizations_url":"https://api.github.com/users/kubernetes/orgs","repos_url":"https://api.github.com/users/kubernetes/repos","events_url":"https://api.github.com/users/kubernetes/events{/privacy}","received_events_url":"https://api.github.com/users/kubernetes/received_events","type":"Organization","site_admin":false},"repo":{"id":44350607,"name":"dashboard","full_name":"kubernetes/dashboard","owner":{"login":"kubernetes","id":13629408,"avatar_url":"https://avatars.githubusercontent.com/u/13629408?v=3","gravatar_id":"","url":"https://api.github.com/users/kubernetes","html_url":"https://github.com/kubernetes","followers_url":"https://api.github.com/users/kubernetes/followers","following_url":"https://api.github.com/users/kubernetes/following{/other_user}","gists_url":"https://api.github.com/users/kubernetes/gists{/gist_id}","starred_url":"https://api.github.com/users/kubernetes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kubernetes/subscriptions","organizations_url":"https://api.github.com/users/kubernetes/orgs","repos_url":"https://api.github.com/users/kubernetes/repos","events_url":"https://api.github.com/users/kubernetes/events{/privacy}","received_events_url":"https://api.github.com/users/kubernetes/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kubernetes/dashboard","description":"","fork":false,"url":"https://api.github.com/repos/kubernetes/dashboard","forks_url":"https://api.github.com/repos/kubernetes/dashboard/forks","keys_url":"https://api.github.com/repos/kubernetes/dashboard/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kubernetes/dashboard/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kubernetes/dashboard/teams","hooks_url":"https://api.github.com/repos/kubernetes/dashboard/hooks","issue_events_url":"https://api.github.com/repos/kubernetes/dashboard/issues/events{/number}","events_url":"https://api.github.com/repos/kubernetes/dashboard/events","assignees_url":"https://api.github.com/repos/kubernetes/dashboard/assignees{/user}","branches_url":"https://api.github.com/repos/kubernetes/dashboard/branches{/branch}","tags_url":"https://api.github.com/repos/kubernetes/dashboard/tags","blobs_url":"https://api.github.com/repos/kubernetes/dashboard/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kubernetes/dashboard/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kubernetes/dashboard/git/refs{/sha}","trees_url":"https://api.github.com/repos/kubernetes/dashboard/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kubernetes/dashboard/statuses/{sha}","languages_url":"https://api.github.com/repos/kubernetes/dashboard/languages","stargazers_url":"https://api.github.com/repos/kubernetes/dashboard/stargazers","contributors_url":"https://api.github.com/repos/kubernetes/dashboard/contributors","subscribers_url":"https://api.github.com/repos/kubernetes/dashboard/subscribers","subscription_url":"https://api.github.com/repos/kubernetes/dashboard/subscription","commits_url":"https://api.github.com/repos/kubernetes/dashboard/commits{/sha}","git_commits_url":"https://api.github.com/repos/kubernetes/dashboard/git/commits{/sha}","comments_url":"https://api.github.com/repos/kubernetes/dashboard/comments{/number}","issue_comment_url":"https://api.github.com/repos/kubernetes/dashboard/issues/comments{/number}","contents_url":"https://api.github.com/repos/kubernetes/dashboard/contents/{+path}","compare_url":"https://api.github.com/repos/kubernetes/dashboard/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kubernetes/dashboard/merges","archive_url":"https://api.github.com/repos/kubernetes/dashboard/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kubernetes/dashboard/downloads","issues_url":"https://api.github.com/repos/kubernetes/dashboard/issues{/number}","pulls_url":"https://api.github.com/repos/kubernetes/dashboard/pulls{/number}","milestones_url":"https://api.github.com/repos/kubernetes/dashboard/milestones{/number}","notifications_url":"https://api.github.com/repos/kubernetes/dashboard/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kubernetes/dashboard/labels{/name}","releases_url":"https://api.github.com/repos/kubernetes/dashboard/releases{/id}","created_at":"2015-10-15T23:09:14Z","updated_at":"2015-12-03T20:15:05Z","pushed_at":"2015-12-04T09:31:59Z","git_url":"git://github.com/kubernetes/dashboard.git","ssh_url":"git@github.com:kubernetes/dashboard.git","clone_url":"https://github.com/kubernetes/dashboard.git","svn_url":"https://github.com/kubernetes/dashboard","homepage":"","size":5268,"stargazers_count":58,"watchers_count":58,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":16,"mirror_url":null,"open_issues_count":19,"forks":16,"open_issues":19,"watchers":58,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kubernetes/dashboard/pulls/124"},"html":{"href":"https://github.com/kubernetes/dashboard/pull/124"},"issue":{"href":"https://api.github.com/repos/kubernetes/dashboard/issues/124"},"comments":{"href":"https://api.github.com/repos/kubernetes/dashboard/issues/124/comments"},"review_comments":{"href":"https://api.github.com/repos/kubernetes/dashboard/pulls/124/comments"},"review_comment":{"href":"https://api.github.com/repos/kubernetes/dashboard/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kubernetes/dashboard/pulls/124/commits"},"statuses":{"href":"https://api.github.com/repos/kubernetes/dashboard/statuses/197f92600310d95baf8bd0063b9c26e23eed7efe"}}}}