{"action":"created","comment":{"url":"https://api.github.com/repos/coreos/etcd-operator/pulls/comments/90565497","pull_request_review_id":11085091,"id":90565497,"diff_hunk":"@@ -0,0 +1,76 @@\n+// Copyright 2016 The etcd-operator 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+package backup\n+\n+import (\n+\t\"fmt\"\n+\t\"io\"\n+\t\"log\"\n+\t\"os\"\n+\t\"path/filepath\"\n+\n+\t\"github.com/coreos/etcd-operator/pkg/backup/s3\"\n+)\n+\n+// ensure s3Backend satisfies backend interface.\n+var _ backend = &s3Backend{}\n+\n+type s3Backend struct {\n+\tS3 *s3.S3\n+\t// dir to temporarily store backup files before upload it to S3.\n+\tdir string\n+}\n+\n+func (sb *s3Backend) save(version string, snapRev int64, rc io.ReadCloser) error {\n+\t// make a local file copy of the backup first, since s3 requires io.ReadSeeker.\n+\tkey := makeBackupName(version, snapRev)\n+\ttmpfile, err := os.OpenFile(filepath.Join(sb.dir, key), os.O_RDWR|os.O_CREATE, backupFilePerm)\n+\tif err != nil {\n+\t\treturn fmt.Errorf(\"failed to create snapshot tempfile: %v\", err)\n+\t}\n+\tdefer func() {\n+\t\ttmpfile.Close()\n+\t\tos.Remove(tmpfile.Name())\n+\t}()\n+\n+\tn, err := io.Copy(tmpfile, rc)\n+\tif err != nil {\n+\t\treturn fmt.Errorf(\"failed to save snapshot: %v\", err)\n+\t}\n+\trc.Close()","path":"pkg/backup/s3.go","position":52,"original_position":52,"commit_id":"7f6cebcbb488fede218efc598fe48ef38ff060dd","original_commit_id":"7f6cebcbb488fede218efc598fe48ef38ff060dd","user":{"login":"hongchaodeng","id":920884,"avatar_url":"https://avatars.githubusercontent.com/u/920884?v=3","gravatar_id":"","url":"https://api.github.com/users/hongchaodeng","html_url":"https://github.com/hongchaodeng","followers_url":"https://api.github.com/users/hongchaodeng/followers","following_url":"https://api.github.com/users/hongchaodeng/following{/other_user}","gists_url":"https://api.github.com/users/hongchaodeng/gists{/gist_id}","starred_url":"https://api.github.com/users/hongchaodeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hongchaodeng/subscriptions","organizations_url":"https://api.github.com/users/hongchaodeng/orgs","repos_url":"https://api.github.com/users/hongchaodeng/repos","events_url":"https://api.github.com/users/hongchaodeng/events{/privacy}","received_events_url":"https://api.github.com/users/hongchaodeng/received_events","type":"User","site_admin":false},"body":"This is closed outside in writeSnap()","created_at":"2016-12-02T00:12:50Z","updated_at":"2016-12-02T00:12:50Z","html_url":"https://github.com/coreos/etcd-operator/pull/418#discussion_r90565497","pull_request_url":"https://api.github.com/repos/coreos/etcd-operator/pulls/418","_links":{"self":{"href":"https://api.github.com/repos/coreos/etcd-operator/pulls/comments/90565497"},"html":{"href":"https://github.com/coreos/etcd-operator/pull/418#discussion_r90565497"},"pull_request":{"href":"https://api.github.com/repos/coreos/etcd-operator/pulls/418"}}},"pull_request":{"url":"https://api.github.com/repos/coreos/etcd-operator/pulls/418","id":96195149,"html_url":"https://github.com/coreos/etcd-operator/pull/418","diff_url":"https://github.com/coreos/etcd-operator/pull/418.diff","patch_url":"https://github.com/coreos/etcd-operator/pull/418.patch","issue_url":"https://api.github.com/repos/coreos/etcd-operator/issues/418","number":418,"state":"open","locked":false,"title":"backup: add s3 backend","user":{"login":"xiang90","id":4479947,"avatar_url":"https://avatars.githubusercontent.com/u/4479947?v=3","gravatar_id":"","url":"https://api.github.com/users/xiang90","html_url":"https://github.com/xiang90","followers_url":"https://api.github.com/users/xiang90/followers","following_url":"https://api.github.com/users/xiang90/following{/other_user}","gists_url":"https://api.github.com/users/xiang90/gists{/gist_id}","starred_url":"https://api.github.com/users/xiang90/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiang90/subscriptions","organizations_url":"https://api.github.com/users/xiang90/orgs","repos_url":"https://api.github.com/users/xiang90/repos","events_url":"https://api.github.com/users/xiang90/events{/privacy}","received_events_url":"https://api.github.com/users/xiang90/received_events","type":"User","site_admin":false},"body":"/cc @hongchaodeng ","created_at":"2016-12-01T23:50:35Z","updated_at":"2016-12-02T00:12:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cb620efdc7858a92739f9cb761587a3b8bdb0a55","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/coreos/etcd-operator/pulls/418/commits","review_comments_url":"https://api.github.com/repos/coreos/etcd-operator/pulls/418/comments","review_comment_url":"https://api.github.com/repos/coreos/etcd-operator/pulls/comments{/number}","comments_url":"https://api.github.com/repos/coreos/etcd-operator/issues/418/comments","statuses_url":"https://api.github.com/repos/coreos/etcd-operator/statuses/7f6cebcbb488fede218efc598fe48ef38ff060dd","head":{"label":"coreos:s3","ref":"s3","sha":"7f6cebcbb488fede218efc598fe48ef38ff060dd","user":{"login":"coreos","id":3730757,"avatar_url":"https://avatars.githubusercontent.com/u/3730757?v=3","gravatar_id":"","url":"https://api.github.com/users/coreos","html_url":"https://github.com/coreos","followers_url":"https://api.github.com/users/coreos/followers","following_url":"https://api.github.com/users/coreos/following{/other_user}","gists_url":"https://api.github.com/users/coreos/gists{/gist_id}","starred_url":"https://api.github.com/users/coreos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coreos/subscriptions","organizations_url":"https://api.github.com/users/coreos/orgs","repos_url":"https://api.github.com/users/coreos/repos","events_url":"https://api.github.com/users/coreos/events{/privacy}","received_events_url":"https://api.github.com/users/coreos/received_events","type":"Organization","site_admin":false},"repo":{"id":64974719,"name":"etcd-operator","full_name":"coreos/etcd-operator","owner":{"login":"coreos","id":3730757,"avatar_url":"https://avatars.githubusercontent.com/u/3730757?v=3","gravatar_id":"","url":"https://api.github.com/users/coreos","html_url":"https://github.com/coreos","followers_url":"https://api.github.com/users/coreos/followers","following_url":"https://api.github.com/users/coreos/following{/other_user}","gists_url":"https://api.github.com/users/coreos/gists{/gist_id}","starred_url":"https://api.github.com/users/coreos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coreos/subscriptions","organizations_url":"https://api.github.com/users/coreos/orgs","repos_url":"https://api.github.com/users/coreos/repos","events_url":"https://api.github.com/users/coreos/events{/privacy}","received_events_url":"https://api.github.com/users/coreos/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/coreos/etcd-operator","description":"etcd Operator creates/configures/manages etcd clusters atop Kubernetes","fork":false,"url":"https://api.github.com/repos/coreos/etcd-operator","forks_url":"https://api.github.com/repos/coreos/etcd-operator/forks","keys_url":"https://api.github.com/repos/coreos/etcd-operator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/coreos/etcd-operator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/coreos/etcd-operator/teams","hooks_url":"https://api.github.com/repos/coreos/etcd-operator/hooks","issue_events_url":"https://api.github.com/repos/coreos/etcd-operator/issues/events{/number}","events_url":"https://api.github.com/repos/coreos/etcd-operator/events","assignees_url":"https://api.github.com/repos/coreos/etcd-operator/assignees{/user}","branches_url":"https://api.github.com/repos/coreos/etcd-operator/branches{/branch}","tags_url":"https://api.github.com/repos/coreos/etcd-operator/tags","blobs_url":"https://api.github.com/repos/coreos/etcd-operator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/coreos/etcd-operator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/coreos/etcd-operator/git/refs{/sha}","trees_url":"https://api.github.com/repos/coreos/etcd-operator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/coreos/etcd-operator/statuses/{sha}","languages_url":"https://api.github.com/repos/coreos/etcd-operator/languages","stargazers_url":"https://api.github.com/repos/coreos/etcd-operator/stargazers","contributors_url":"https://api.github.com/repos/coreos/etcd-operator/contributors","subscribers_url":"https://api.github.com/repos/coreos/etcd-operator/subscribers","subscription_url":"https://api.github.com/repos/coreos/etcd-operator/subscription","commits_url":"https://api.github.com/repos/coreos/etcd-operator/commits{/sha}","git_commits_url":"https://api.github.com/repos/coreos/etcd-operator/git/commits{/sha}","comments_url":"https://api.github.com/repos/coreos/etcd-operator/comments{/number}","issue_comment_url":"https://api.github.com/repos/coreos/etcd-operator/issues/comments{/number}","contents_url":"https://api.github.com/repos/coreos/etcd-operator/contents/{+path}","compare_url":"https://api.github.com/repos/coreos/etcd-operator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/coreos/etcd-operator/merges","archive_url":"https://api.github.com/repos/coreos/etcd-operator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/coreos/etcd-operator/downloads","issues_url":"https://api.github.com/repos/coreos/etcd-operator/issues{/number}","pulls_url":"https://api.github.com/repos/coreos/etcd-operator/pulls{/number}","milestones_url":"https://api.github.com/repos/coreos/etcd-operator/milestones{/number}","notifications_url":"https://api.github.com/repos/coreos/etcd-operator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/coreos/etcd-operator/labels{/name}","releases_url":"https://api.github.com/repos/coreos/etcd-operator/releases{/id}","deployments_url":"https://api.github.com/repos/coreos/etcd-operator/deployments","created_at":"2016-08-04T23:54:58Z","updated_at":"2016-12-01T05:53:10Z","pushed_at":"2016-12-01T23:54:19Z","git_url":"git://github.com/coreos/etcd-operator.git","ssh_url":"git@github.com:coreos/etcd-operator.git","clone_url":"https://github.com/coreos/etcd-operator.git","svn_url":"https://github.com/coreos/etcd-operator","homepage":"https://coreos.com/blog/introducing-the-etcd-operator.html","size":595,"stargazers_count":125,"watchers_count":125,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":11,"mirror_url":null,"open_issues_count":20,"forks":11,"open_issues":20,"watchers":125,"default_branch":"master"}},"base":{"label":"coreos:master","ref":"master","sha":"c8c4d0104be643379b845a67aef9a3d105fc3c30","user":{"login":"coreos","id":3730757,"avatar_url":"https://avatars.githubusercontent.com/u/3730757?v=3","gravatar_id":"","url":"https://api.github.com/users/coreos","html_url":"https://github.com/coreos","followers_url":"https://api.github.com/users/coreos/followers","following_url":"https://api.github.com/users/coreos/following{/other_user}","gists_url":"https://api.github.com/users/coreos/gists{/gist_id}","starred_url":"https://api.github.com/users/coreos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coreos/subscriptions","organizations_url":"https://api.github.com/users/coreos/orgs","repos_url":"https://api.github.com/users/coreos/repos","events_url":"https://api.github.com/users/coreos/events{/privacy}","received_events_url":"https://api.github.com/users/coreos/received_events","type":"Organization","site_admin":false},"repo":{"id":64974719,"name":"etcd-operator","full_name":"coreos/etcd-operator","owner":{"login":"coreos","id":3730757,"avatar_url":"https://avatars.githubusercontent.com/u/3730757?v=3","gravatar_id":"","url":"https://api.github.com/users/coreos","html_url":"https://github.com/coreos","followers_url":"https://api.github.com/users/coreos/followers","following_url":"https://api.github.com/users/coreos/following{/other_user}","gists_url":"https://api.github.com/users/coreos/gists{/gist_id}","starred_url":"https://api.github.com/users/coreos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coreos/subscriptions","organizations_url":"https://api.github.com/users/coreos/orgs","repos_url":"https://api.github.com/users/coreos/repos","events_url":"https://api.github.com/users/coreos/events{/privacy}","received_events_url":"https://api.github.com/users/coreos/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/coreos/etcd-operator","description":"etcd Operator creates/configures/manages etcd clusters atop Kubernetes","fork":false,"url":"https://api.github.com/repos/coreos/etcd-operator","forks_url":"https://api.github.com/repos/coreos/etcd-operator/forks","keys_url":"https://api.github.com/repos/coreos/etcd-operator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/coreos/etcd-operator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/coreos/etcd-operator/teams","hooks_url":"https://api.github.com/repos/coreos/etcd-operator/hooks","issue_events_url":"https://api.github.com/repos/coreos/etcd-operator/issues/events{/number}","events_url":"https://api.github.com/repos/coreos/etcd-operator/events","assignees_url":"https://api.github.com/repos/coreos/etcd-operator/assignees{/user}","branches_url":"https://api.github.com/repos/coreos/etcd-operator/branches{/branch}","tags_url":"https://api.github.com/repos/coreos/etcd-operator/tags","blobs_url":"https://api.github.com/repos/coreos/etcd-operator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/coreos/etcd-operator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/coreos/etcd-operator/git/refs{/sha}","trees_url":"https://api.github.com/repos/coreos/etcd-operator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/coreos/etcd-operator/statuses/{sha}","languages_url":"https://api.github.com/repos/coreos/etcd-operator/languages","stargazers_url":"https://api.github.com/repos/coreos/etcd-operator/stargazers","contributors_url":"https://api.github.com/repos/coreos/etcd-operator/contributors","subscribers_url":"https://api.github.com/repos/coreos/etcd-operator/subscribers","subscription_url":"https://api.github.com/repos/coreos/etcd-operator/subscription","commits_url":"https://api.github.com/repos/coreos/etcd-operator/commits{/sha}","git_commits_url":"https://api.github.com/repos/coreos/etcd-operator/git/commits{/sha}","comments_url":"https://api.github.com/repos/coreos/etcd-operator/comments{/number}","issue_comment_url":"https://api.github.com/repos/coreos/etcd-operator/issues/comments{/number}","contents_url":"https://api.github.com/repos/coreos/etcd-operator/contents/{+path}","compare_url":"https://api.github.com/repos/coreos/etcd-operator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/coreos/etcd-operator/merges","archive_url":"https://api.github.com/repos/coreos/etcd-operator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/coreos/etcd-operator/downloads","issues_url":"https://api.github.com/repos/coreos/etcd-operator/issues{/number}","pulls_url":"https://api.github.com/repos/coreos/etcd-operator/pulls{/number}","milestones_url":"https://api.github.com/repos/coreos/etcd-operator/milestones{/number}","notifications_url":"https://api.github.com/repos/coreos/etcd-operator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/coreos/etcd-operator/labels{/name}","releases_url":"https://api.github.com/repos/coreos/etcd-operator/releases{/id}","deployments_url":"https://api.github.com/repos/coreos/etcd-operator/deployments","created_at":"2016-08-04T23:54:58Z","updated_at":"2016-12-01T05:53:10Z","pushed_at":"2016-12-01T23:54:19Z","git_url":"git://github.com/coreos/etcd-operator.git","ssh_url":"git@github.com:coreos/etcd-operator.git","clone_url":"https://github.com/coreos/etcd-operator.git","svn_url":"https://github.com/coreos/etcd-operator","homepage":"https://coreos.com/blog/introducing-the-etcd-operator.html","size":595,"stargazers_count":125,"watchers_count":125,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":11,"mirror_url":null,"open_issues_count":20,"forks":11,"open_issues":20,"watchers":125,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/coreos/etcd-operator/pulls/418"},"html":{"href":"https://github.com/coreos/etcd-operator/pull/418"},"issue":{"href":"https://api.github.com/repos/coreos/etcd-operator/issues/418"},"comments":{"href":"https://api.github.com/repos/coreos/etcd-operator/issues/418/comments"},"review_comments":{"href":"https://api.github.com/repos/coreos/etcd-operator/pulls/418/comments"},"review_comment":{"href":"https://api.github.com/repos/coreos/etcd-operator/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/coreos/etcd-operator/pulls/418/commits"},"statuses":{"href":"https://api.github.com/repos/coreos/etcd-operator/statuses/7f6cebcbb488fede218efc598fe48ef38ff060dd"}}}}
{"actor":{"display_login":"hongchaodeng"}}