{"action":"created","comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments/24681498","id":24681498,"diff_hunk":"@@ -275,12 +287,50 @@ func (h *EtcdHelper) CreateObj(key string, obj runtime.Object, ttl uint64) error\n \treturn err\n }\n \n+// Create adds a new object at a key unless it already exists. 'ttl' is time-to-live in seconds,\n+// and 0 means forever. If no error is returned, out will be set to the read value from etcd.\n+func (h *EtcdHelper) Create(key string, obj, out runtime.Object, ttl uint64) error {\n+\tdata, err := h.Codec.Encode(obj)\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\tif h.ResourceVersioner != nil {\n+\t\tif version, err := h.ResourceVersioner.ResourceVersion(obj); err == nil && version != 0 {\n+\t\t\treturn errors.New(\"resourceVersion may not be set on objects to be created\")\n+\t\t}\n+\t}\n+\tresponse, err := h.Client.Create(key, string(data), ttl)\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\tif _, err := conversion.EnforcePtr(out); err != nil {\n+\t\tpanic(\"unable to convert output object to pointer\")\n+\t}\n+\t_, _, err = h.extractObj(response, err, out, false, false)\n+\treturn err\n+}\n+\n // Delete removes the specified key.\n func (h *EtcdHelper) Delete(key string, recursive bool) error {\n \t_, err := h.Client.Delete(key, recursive)\n \treturn err\n }\n \n+// DeleteObj removes the specified key and returns the value that existed at that spot.\n+func (h *EtcdHelper) DeleteObj(key string, out runtime.Object) error {\n+\tif _, err := conversion.EnforcePtr(out); err != nil {\n+\t\tpanic(\"unable to convert output object to pointer\")\n+\t}\n+\tresponse, err := h.Client.Delete(key, false)","path":"pkg/tools/etcd_tools.go","position":84,"original_position":84,"commit_id":"816b46001071bae8df257dc5ab515b5bebc600e4","original_commit_id":"816b46001071bae8df257dc5ab515b5bebc600e4","user":{"login":"smarterclayton","id":1163175,"avatar_url":"https://avatars.githubusercontent.com/u/1163175?v=3","gravatar_id":"","url":"https://api.github.com/users/smarterclayton","html_url":"https://github.com/smarterclayton","followers_url":"https://api.github.com/users/smarterclayton/followers","following_url":"https://api.github.com/users/smarterclayton/following{/other_user}","gists_url":"https://api.github.com/users/smarterclayton/gists{/gist_id}","starred_url":"https://api.github.com/users/smarterclayton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smarterclayton/subscriptions","organizations_url":"https://api.github.com/users/smarterclayton/orgs","repos_url":"https://api.github.com/users/smarterclayton/repos","events_url":"https://api.github.com/users/smarterclayton/events{/privacy}","received_events_url":"https://api.github.com/users/smarterclayton/received_events","type":"User","site_admin":false},"body":"I'll spawn a follow up for that, it's possible via compareanddelete.\n\n----- Original Message -----\n> >  // Delete removes the specified key.\n> >  func (h *EtcdHelper) Delete(key string, recursive bool) error {\n> >  \t_, err := h.Client.Delete(key, recursive)\n> >  \treturn err\n> >  }\n> >  \n> > +// DeleteObj removes the specified key and returns the value that existed\n> > at that spot.\n> > +func (h *EtcdHelper) DeleteObj(key string, out runtime.Object) error {\n> > +\tif _, err := conversion.EnforcePtr(out); err != nil {\n> > +\t\tpanic(\"unable to convert output object to pointer\")\n> > +\t}\n> > +\tresponse, err := h.Client.Delete(key, false)\n> \n> Is it possible to apply a resourceVersion precondition on delete? That would\n> be useful for delete-create races.\n> \n> ---\n> Reply to this email directly or view it on GitHub:\n> https://github.com/GoogleCloudPlatform/kubernetes/pull/4419/files#r24681391\n","created_at":"2015-02-13T17:42:47Z","updated_at":"2015-02-13T17:42:47Z","html_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/4419#discussion_r24681498","pull_request_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/4419","_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments/24681498"},"html":{"href":"https://github.com/GoogleCloudPlatform/kubernetes/pull/4419#discussion_r24681498"},"pull_request":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/4419"}}},"pull_request":{"url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/4419","id":29277613,"html_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/4419","diff_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/4419.diff","patch_url":"https://github.com/GoogleCloudPlatform/kubernetes/pull/4419.patch","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/4419","number":4419,"state":"open","locked":false,"title":"Expand the generic registry","user":{"login":"smarterclayton","id":1163175,"avatar_url":"https://avatars.githubusercontent.com/u/1163175?v=3","gravatar_id":"","url":"https://api.github.com/users/smarterclayton","html_url":"https://github.com/smarterclayton","followers_url":"https://api.github.com/users/smarterclayton/followers","following_url":"https://api.github.com/users/smarterclayton/following{/other_user}","gists_url":"https://api.github.com/users/smarterclayton/gists{/gist_id}","starred_url":"https://api.github.com/users/smarterclayton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smarterclayton/subscriptions","organizations_url":"https://api.github.com/users/smarterclayton/orgs","repos_url":"https://api.github.com/users/smarterclayton/repos","events_url":"https://api.github.com/users/smarterclayton/events{/privacy}","received_events_url":"https://api.github.com/users/smarterclayton/received_events","type":"User","site_admin":false},"body":"Allows for Pods to be folded into GenericRegistry\n\nExtracted from #4248","created_at":"2015-02-13T16:26:17Z","updated_at":"2015-02-13T17:42:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"772c2842d4564316df522358c2e2bd0787b2f42c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/4419/commits","review_comments_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/4419/comments","review_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments/{number}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/4419/comments","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/statuses/816b46001071bae8df257dc5ab515b5bebc600e4","head":{"label":"smarterclayton:expand_generic_resources","ref":"expand_generic_resources","sha":"816b46001071bae8df257dc5ab515b5bebc600e4","user":{"login":"smarterclayton","id":1163175,"avatar_url":"https://avatars.githubusercontent.com/u/1163175?v=3","gravatar_id":"","url":"https://api.github.com/users/smarterclayton","html_url":"https://github.com/smarterclayton","followers_url":"https://api.github.com/users/smarterclayton/followers","following_url":"https://api.github.com/users/smarterclayton/following{/other_user}","gists_url":"https://api.github.com/users/smarterclayton/gists{/gist_id}","starred_url":"https://api.github.com/users/smarterclayton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smarterclayton/subscriptions","organizations_url":"https://api.github.com/users/smarterclayton/orgs","repos_url":"https://api.github.com/users/smarterclayton/repos","events_url":"https://api.github.com/users/smarterclayton/events{/privacy}","received_events_url":"https://api.github.com/users/smarterclayton/received_events","type":"User","site_admin":false},"repo":{"id":21225407,"name":"kubernetes","full_name":"smarterclayton/kubernetes","owner":{"login":"smarterclayton","id":1163175,"avatar_url":"https://avatars.githubusercontent.com/u/1163175?v=3","gravatar_id":"","url":"https://api.github.com/users/smarterclayton","html_url":"https://github.com/smarterclayton","followers_url":"https://api.github.com/users/smarterclayton/followers","following_url":"https://api.github.com/users/smarterclayton/following{/other_user}","gists_url":"https://api.github.com/users/smarterclayton/gists{/gist_id}","starred_url":"https://api.github.com/users/smarterclayton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smarterclayton/subscriptions","organizations_url":"https://api.github.com/users/smarterclayton/orgs","repos_url":"https://api.github.com/users/smarterclayton/repos","events_url":"https://api.github.com/users/smarterclayton/events{/privacy}","received_events_url":"https://api.github.com/users/smarterclayton/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/smarterclayton/kubernetes","description":"Container Cluster Manager","fork":true,"url":"https://api.github.com/repos/smarterclayton/kubernetes","forks_url":"https://api.github.com/repos/smarterclayton/kubernetes/forks","keys_url":"https://api.github.com/repos/smarterclayton/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/smarterclayton/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/smarterclayton/kubernetes/teams","hooks_url":"https://api.github.com/repos/smarterclayton/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/smarterclayton/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/smarterclayton/kubernetes/events","assignees_url":"https://api.github.com/repos/smarterclayton/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/smarterclayton/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/smarterclayton/kubernetes/tags","blobs_url":"https://api.github.com/repos/smarterclayton/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/smarterclayton/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/smarterclayton/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/smarterclayton/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/smarterclayton/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/smarterclayton/kubernetes/languages","stargazers_url":"https://api.github.com/repos/smarterclayton/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/smarterclayton/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/smarterclayton/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/smarterclayton/kubernetes/subscription","commits_url":"https://api.github.com/repos/smarterclayton/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/smarterclayton/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/smarterclayton/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/smarterclayton/kubernetes/issues/comments/{number}","contents_url":"https://api.github.com/repos/smarterclayton/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/smarterclayton/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/smarterclayton/kubernetes/merges","archive_url":"https://api.github.com/repos/smarterclayton/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/smarterclayton/kubernetes/downloads","issues_url":"https://api.github.com/repos/smarterclayton/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/smarterclayton/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/smarterclayton/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/smarterclayton/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/smarterclayton/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/smarterclayton/kubernetes/releases{/id}","created_at":"2014-06-26T02:28:13Z","updated_at":"2014-06-26T01:04:38Z","pushed_at":"2015-02-13T17:12:59Z","git_url":"git://github.com/smarterclayton/kubernetes.git","ssh_url":"git@github.com:smarterclayton/kubernetes.git","clone_url":"https://github.com/smarterclayton/kubernetes.git","svn_url":"https://github.com/smarterclayton/kubernetes","homepage":null,"size":30464,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"GoogleCloudPlatform:master","ref":"master","sha":"7e6015141db7813d45bff73be939c92daa84ba82","user":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"repo":{"id":20580498,"name":"kubernetes","full_name":"GoogleCloudPlatform/kubernetes","owner":{"login":"GoogleCloudPlatform","id":2810941,"avatar_url":"https://avatars.githubusercontent.com/u/2810941?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCloudPlatform","html_url":"https://github.com/GoogleCloudPlatform","followers_url":"https://api.github.com/users/GoogleCloudPlatform/followers","following_url":"https://api.github.com/users/GoogleCloudPlatform/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCloudPlatform/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCloudPlatform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCloudPlatform/subscriptions","organizations_url":"https://api.github.com/users/GoogleCloudPlatform/orgs","repos_url":"https://api.github.com/users/GoogleCloudPlatform/repos","events_url":"https://api.github.com/users/GoogleCloudPlatform/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCloudPlatform/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GoogleCloudPlatform/kubernetes","description":"Container Cluster Manager","fork":false,"url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes","forks_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/forks","keys_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/teams","hooks_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/events","assignees_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/tags","blobs_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/languages","stargazers_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/subscription","commits_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/comments/{number}","contents_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/merges","archive_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/downloads","issues_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/releases{/id}","created_at":"2014-06-06T22:56:04Z","updated_at":"2015-02-13T17:34:53Z","pushed_at":"2015-02-13T17:34:53Z","git_url":"git://github.com/GoogleCloudPlatform/kubernetes.git","ssh_url":"git@github.com:GoogleCloudPlatform/kubernetes.git","clone_url":"https://github.com/GoogleCloudPlatform/kubernetes.git","svn_url":"https://github.com/GoogleCloudPlatform/kubernetes","homepage":"http://kubernetes.io","size":75345,"stargazers_count":6202,"watchers_count":6202,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1077,"mirror_url":null,"open_issues_count":682,"forks":1077,"open_issues":682,"watchers":6202,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/4419"},"html":{"href":"https://github.com/GoogleCloudPlatform/kubernetes/pull/4419"},"issue":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/4419"},"comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/4419/comments"},"review_comments":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/4419/comments"},"review_comment":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/pulls/4419/commits"},"statuses":{"href":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/statuses/816b46001071bae8df257dc5ab515b5bebc600e4"}}}}