{"action":"created","comment":{"url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/pulls/comments/114645914","pull_request_review_id":36130430,"id":114645914,"diff_hunk":"@@ -0,0 +1,91 @@\n+/*\n+Copyright 2017 The Kubernetes Authors.\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+\n+package registrar\n+\n+import (\n+\t\"fmt\"\n+\t\"sync\"\n+)\n+\n+// TODO(random-liu): Add unit test.\n+\n+// Registrar stores name to key, and key to name indexes.\n+// Names must be unique.\n+// Registrar is safe for concurrent access.\n+type Registrar struct {\n+\tsync.Mutex\n+\tnameToKey map[string]string\n+\tkeyToName map[string]string\n+}\n+\n+// NewRegistrar creates a new Registrar with the an empty index.\n+func NewRegistrar() *Registrar {\n+\treturn &Registrar{\n+\t\tnameToKey: make(map[string]string),\n+\t\tkeyToName: make(map[string]string),\n+\t}\n+}\n+\n+// Reserve registers a key to a name.\n+// Reserve is idempotent.\n+// Attempting to reserve a key to a name that already exists results in an error.\n+// A name reservation is globally unique.\n+func (r *Registrar) Reserve(name, key string) error {\n+\tr.Lock()\n+\tdefer r.Unlock()\n+\n+\tif k, exists := r.nameToKey[name]; exists {\n+\t\tif k != key {\n+\t\t\treturn fmt.Errorf(\"name %q is reserved for %q\", name, k)\n+\t\t}\n+\t\treturn nil\n+\t}\n+\n+\tr.nameToKey[name] = key\n+\tr.keyToName[key] = name\n+\treturn nil\n+}\n+\n+// Release releases the reserved name","path":"pkg/registrar/registrar.go","position":63,"original_position":63,"commit_id":"dc6180721ecd49727d6c65c1fb367167ed640445","original_commit_id":"935e0a632499edbfddcce267e78573e9ffb94d19","user":{"login":"Random-Liu","id":5821883,"avatar_url":"https://avatars0.githubusercontent.com/u/5821883?v=3","gravatar_id":"","url":"https://api.github.com/users/Random-Liu","html_url":"https://github.com/Random-Liu","followers_url":"https://api.github.com/users/Random-Liu/followers","following_url":"https://api.github.com/users/Random-Liu/following{/other_user}","gists_url":"https://api.github.com/users/Random-Liu/gists{/gist_id}","starred_url":"https://api.github.com/users/Random-Liu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Random-Liu/subscriptions","organizations_url":"https://api.github.com/users/Random-Liu/orgs","repos_url":"https://api.github.com/users/Random-Liu/repos","events_url":"https://api.github.com/users/Random-Liu/events{/privacy}","received_events_url":"https://api.github.com/users/Random-Liu/received_events","type":"User","site_admin":false},"body":"Done.","created_at":"2017-05-03T20:32:32Z","updated_at":"2017-05-03T20:32:32Z","html_url":"https://github.com/kubernetes-incubator/cri-containerd/pull/19#discussion_r114645914","pull_request_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/pulls/19","_links":{"self":{"href":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/pulls/comments/114645914"},"html":{"href":"https://github.com/kubernetes-incubator/cri-containerd/pull/19#discussion_r114645914"},"pull_request":{"href":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/pulls/19"}}},"pull_request":{"url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/pulls/19","id":117409233,"html_url":"https://github.com/kubernetes-incubator/cri-containerd/pull/19","diff_url":"https://github.com/kubernetes-incubator/cri-containerd/pull/19.diff","patch_url":"https://github.com/kubernetes-incubator/cri-containerd/pull/19.patch","issue_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/issues/19","number":19,"state":"open","locked":false,"title":"[WIP] Add sandbox implementation","user":{"login":"Random-Liu","id":5821883,"avatar_url":"https://avatars0.githubusercontent.com/u/5821883?v=3","gravatar_id":"","url":"https://api.github.com/users/Random-Liu","html_url":"https://github.com/Random-Liu","followers_url":"https://api.github.com/users/Random-Liu/followers","following_url":"https://api.github.com/users/Random-Liu/following{/other_user}","gists_url":"https://api.github.com/users/Random-Liu/gists{/gist_id}","starred_url":"https://api.github.com/users/Random-Liu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Random-Liu/subscriptions","organizations_url":"https://api.github.com/users/Random-Liu/orgs","repos_url":"https://api.github.com/users/Random-Liu/repos","events_url":"https://api.github.com/users/Random-Liu/events{/privacy}","received_events_url":"https://api.github.com/users/Random-Liu/received_events","type":"User","site_admin":false},"body":"Based on https://github.com/kubernetes-incubator/cri-containerd/pull/9.\r\n\r\nThe first 3 commits are from https://github.com/kubernetes-incubator/cri-containerd/pull/9. Please only look at the 3 new commits (including one godep update commit).\r\n\r\nThis PR added the sandbox implementation, including:\r\n* RunPodSandbox\r\n* ListPodSandbox\r\n* PodSandboxStatus\r\n* StopPodSandbox\r\n* RemovePodSandbox\r\n\r\nThe PR is marked as WIP, because unit test is needed. Actually the code is complete already.\r\n\r\nPost the PR here to:\r\n1) Get initial review. Will add unit test after the PR looks good overall.\r\n2) Demonstrate how to use the metadata store.\r\n3) Demonstrate the code style.\r\n\r\n@yujuhong @mikebrow /cc @kubernetes-incubator/maintainers-cri-containerd ","created_at":"2017-04-25T05:59:59Z","updated_at":"2017-05-03T20:32:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2294768678842f58af1ff5dfd01fdff1d866f12b","assignee":{"login":"yujuhong","id":10524058,"avatar_url":"https://avatars2.githubusercontent.com/u/10524058?v=3","gravatar_id":"","url":"https://api.github.com/users/yujuhong","html_url":"https://github.com/yujuhong","followers_url":"https://api.github.com/users/yujuhong/followers","following_url":"https://api.github.com/users/yujuhong/following{/other_user}","gists_url":"https://api.github.com/users/yujuhong/gists{/gist_id}","starred_url":"https://api.github.com/users/yujuhong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yujuhong/subscriptions","organizations_url":"https://api.github.com/users/yujuhong/orgs","repos_url":"https://api.github.com/users/yujuhong/repos","events_url":"https://api.github.com/users/yujuhong/events{/privacy}","received_events_url":"https://api.github.com/users/yujuhong/received_events","type":"User","site_admin":false},"assignees":[{"login":"yujuhong","id":10524058,"avatar_url":"https://avatars2.githubusercontent.com/u/10524058?v=3","gravatar_id":"","url":"https://api.github.com/users/yujuhong","html_url":"https://github.com/yujuhong","followers_url":"https://api.github.com/users/yujuhong/followers","following_url":"https://api.github.com/users/yujuhong/following{/other_user}","gists_url":"https://api.github.com/users/yujuhong/gists{/gist_id}","starred_url":"https://api.github.com/users/yujuhong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yujuhong/subscriptions","organizations_url":"https://api.github.com/users/yujuhong/orgs","repos_url":"https://api.github.com/users/yujuhong/repos","events_url":"https://api.github.com/users/yujuhong/events{/privacy}","received_events_url":"https://api.github.com/users/yujuhong/received_events","type":"User","site_admin":false},{"login":"mikebrow","id":12767641,"avatar_url":"https://avatars3.githubusercontent.com/u/12767641?v=3","gravatar_id":"","url":"https://api.github.com/users/mikebrow","html_url":"https://github.com/mikebrow","followers_url":"https://api.github.com/users/mikebrow/followers","following_url":"https://api.github.com/users/mikebrow/following{/other_user}","gists_url":"https://api.github.com/users/mikebrow/gists{/gist_id}","starred_url":"https://api.github.com/users/mikebrow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikebrow/subscriptions","organizations_url":"https://api.github.com/users/mikebrow/orgs","repos_url":"https://api.github.com/users/mikebrow/repos","events_url":"https://api.github.com/users/mikebrow/events{/privacy}","received_events_url":"https://api.github.com/users/mikebrow/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/pulls/19/commits","review_comments_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/pulls/19/comments","review_comment_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/issues/19/comments","statuses_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/statuses/dc6180721ecd49727d6c65c1fb367167ed640445","head":{"label":"Random-Liu:add-sandbox-implementation","ref":"add-sandbox-implementation","sha":"dc6180721ecd49727d6c65c1fb367167ed640445","user":{"login":"Random-Liu","id":5821883,"avatar_url":"https://avatars0.githubusercontent.com/u/5821883?v=3","gravatar_id":"","url":"https://api.github.com/users/Random-Liu","html_url":"https://github.com/Random-Liu","followers_url":"https://api.github.com/users/Random-Liu/followers","following_url":"https://api.github.com/users/Random-Liu/following{/other_user}","gists_url":"https://api.github.com/users/Random-Liu/gists{/gist_id}","starred_url":"https://api.github.com/users/Random-Liu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Random-Liu/subscriptions","organizations_url":"https://api.github.com/users/Random-Liu/orgs","repos_url":"https://api.github.com/users/Random-Liu/repos","events_url":"https://api.github.com/users/Random-Liu/events{/privacy}","received_events_url":"https://api.github.com/users/Random-Liu/received_events","type":"User","site_admin":false},"repo":{"id":88243482,"name":"cri-containerd","full_name":"Random-Liu/cri-containerd","owner":{"login":"Random-Liu","id":5821883,"avatar_url":"https://avatars0.githubusercontent.com/u/5821883?v=3","gravatar_id":"","url":"https://api.github.com/users/Random-Liu","html_url":"https://github.com/Random-Liu","followers_url":"https://api.github.com/users/Random-Liu/followers","following_url":"https://api.github.com/users/Random-Liu/following{/other_user}","gists_url":"https://api.github.com/users/Random-Liu/gists{/gist_id}","starred_url":"https://api.github.com/users/Random-Liu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Random-Liu/subscriptions","organizations_url":"https://api.github.com/users/Random-Liu/orgs","repos_url":"https://api.github.com/users/Random-Liu/repos","events_url":"https://api.github.com/users/Random-Liu/events{/privacy}","received_events_url":"https://api.github.com/users/Random-Liu/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Random-Liu/cri-containerd","description":"Containerd-based implementation of Kubernetes Container Runtime Interface","fork":true,"url":"https://api.github.com/repos/Random-Liu/cri-containerd","forks_url":"https://api.github.com/repos/Random-Liu/cri-containerd/forks","keys_url":"https://api.github.com/repos/Random-Liu/cri-containerd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Random-Liu/cri-containerd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Random-Liu/cri-containerd/teams","hooks_url":"https://api.github.com/repos/Random-Liu/cri-containerd/hooks","issue_events_url":"https://api.github.com/repos/Random-Liu/cri-containerd/issues/events{/number}","events_url":"https://api.github.com/repos/Random-Liu/cri-containerd/events","assignees_url":"https://api.github.com/repos/Random-Liu/cri-containerd/assignees{/user}","branches_url":"https://api.github.com/repos/Random-Liu/cri-containerd/branches{/branch}","tags_url":"https://api.github.com/repos/Random-Liu/cri-containerd/tags","blobs_url":"https://api.github.com/repos/Random-Liu/cri-containerd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Random-Liu/cri-containerd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Random-Liu/cri-containerd/git/refs{/sha}","trees_url":"https://api.github.com/repos/Random-Liu/cri-containerd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Random-Liu/cri-containerd/statuses/{sha}","languages_url":"https://api.github.com/repos/Random-Liu/cri-containerd/languages","stargazers_url":"https://api.github.com/repos/Random-Liu/cri-containerd/stargazers","contributors_url":"https://api.github.com/repos/Random-Liu/cri-containerd/contributors","subscribers_url":"https://api.github.com/repos/Random-Liu/cri-containerd/subscribers","subscription_url":"https://api.github.com/repos/Random-Liu/cri-containerd/subscription","commits_url":"https://api.github.com/repos/Random-Liu/cri-containerd/commits{/sha}","git_commits_url":"https://api.github.com/repos/Random-Liu/cri-containerd/git/commits{/sha}","comments_url":"https://api.github.com/repos/Random-Liu/cri-containerd/comments{/number}","issue_comment_url":"https://api.github.com/repos/Random-Liu/cri-containerd/issues/comments{/number}","contents_url":"https://api.github.com/repos/Random-Liu/cri-containerd/contents/{+path}","compare_url":"https://api.github.com/repos/Random-Liu/cri-containerd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Random-Liu/cri-containerd/merges","archive_url":"https://api.github.com/repos/Random-Liu/cri-containerd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Random-Liu/cri-containerd/downloads","issues_url":"https://api.github.com/repos/Random-Liu/cri-containerd/issues{/number}","pulls_url":"https://api.github.com/repos/Random-Liu/cri-containerd/pulls{/number}","milestones_url":"https://api.github.com/repos/Random-Liu/cri-containerd/milestones{/number}","notifications_url":"https://api.github.com/repos/Random-Liu/cri-containerd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Random-Liu/cri-containerd/labels{/name}","releases_url":"https://api.github.com/repos/Random-Liu/cri-containerd/releases{/id}","deployments_url":"https://api.github.com/repos/Random-Liu/cri-containerd/deployments","created_at":"2017-04-14T07:18:02Z","updated_at":"2017-04-14T07:08:52Z","pushed_at":"2017-05-03T04:48:07Z","git_url":"git://github.com/Random-Liu/cri-containerd.git","ssh_url":"git@github.com:Random-Liu/cri-containerd.git","clone_url":"https://github.com/Random-Liu/cri-containerd.git","svn_url":"https://github.com/Random-Liu/cri-containerd","homepage":"","size":1502,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_projects":true,"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-incubator:master","ref":"master","sha":"409b946be1df2a6c03b6759dd5576549ddd59654","user":{"login":"kubernetes-incubator","id":20862812,"avatar_url":"https://avatars1.githubusercontent.com/u/20862812?v=3","gravatar_id":"","url":"https://api.github.com/users/kubernetes-incubator","html_url":"https://github.com/kubernetes-incubator","followers_url":"https://api.github.com/users/kubernetes-incubator/followers","following_url":"https://api.github.com/users/kubernetes-incubator/following{/other_user}","gists_url":"https://api.github.com/users/kubernetes-incubator/gists{/gist_id}","starred_url":"https://api.github.com/users/kubernetes-incubator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kubernetes-incubator/subscriptions","organizations_url":"https://api.github.com/users/kubernetes-incubator/orgs","repos_url":"https://api.github.com/users/kubernetes-incubator/repos","events_url":"https://api.github.com/users/kubernetes-incubator/events{/privacy}","received_events_url":"https://api.github.com/users/kubernetes-incubator/received_events","type":"Organization","site_admin":false},"repo":{"id":88211060,"name":"cri-containerd","full_name":"kubernetes-incubator/cri-containerd","owner":{"login":"kubernetes-incubator","id":20862812,"avatar_url":"https://avatars1.githubusercontent.com/u/20862812?v=3","gravatar_id":"","url":"https://api.github.com/users/kubernetes-incubator","html_url":"https://github.com/kubernetes-incubator","followers_url":"https://api.github.com/users/kubernetes-incubator/followers","following_url":"https://api.github.com/users/kubernetes-incubator/following{/other_user}","gists_url":"https://api.github.com/users/kubernetes-incubator/gists{/gist_id}","starred_url":"https://api.github.com/users/kubernetes-incubator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kubernetes-incubator/subscriptions","organizations_url":"https://api.github.com/users/kubernetes-incubator/orgs","repos_url":"https://api.github.com/users/kubernetes-incubator/repos","events_url":"https://api.github.com/users/kubernetes-incubator/events{/privacy}","received_events_url":"https://api.github.com/users/kubernetes-incubator/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kubernetes-incubator/cri-containerd","description":"Containerd-based implementation of Kubernetes Container Runtime Interface","fork":false,"url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd","forks_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/forks","keys_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/teams","hooks_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/hooks","issue_events_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/issues/events{/number}","events_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/events","assignees_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/assignees{/user}","branches_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/branches{/branch}","tags_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/tags","blobs_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/git/refs{/sha}","trees_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/statuses/{sha}","languages_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/languages","stargazers_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/stargazers","contributors_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/contributors","subscribers_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/subscribers","subscription_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/subscription","commits_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/commits{/sha}","git_commits_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/git/commits{/sha}","comments_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/comments{/number}","issue_comment_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/issues/comments{/number}","contents_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/contents/{+path}","compare_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/merges","archive_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/downloads","issues_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/issues{/number}","pulls_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/pulls{/number}","milestones_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/milestones{/number}","notifications_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/labels{/name}","releases_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/releases{/id}","deployments_url":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/deployments","created_at":"2017-04-13T22:20:24Z","updated_at":"2017-05-03T08:52:39Z","pushed_at":"2017-05-03T12:38:39Z","git_url":"git://github.com/kubernetes-incubator/cri-containerd.git","ssh_url":"git@github.com:kubernetes-incubator/cri-containerd.git","clone_url":"https://github.com/kubernetes-incubator/cri-containerd.git","svn_url":"https://github.com/kubernetes-incubator/cri-containerd","homepage":"","size":777,"stargazers_count":24,"watchers_count":24,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":9,"forks":8,"open_issues":9,"watchers":24,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/pulls/19"},"html":{"href":"https://github.com/kubernetes-incubator/cri-containerd/pull/19"},"issue":{"href":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/issues/19"},"comments":{"href":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/issues/19/comments"},"review_comments":{"href":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/pulls/19/comments"},"review_comment":{"href":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/pulls/19/commits"},"statuses":{"href":"https://api.github.com/repos/kubernetes-incubator/cri-containerd/statuses/dc6180721ecd49727d6c65c1fb367167ed640445"}}}}
{"actor":{"display_login":"Random-Liu"}}