{"action":"created","comment":{"url":"https://api.github.com/repos/Originate/exosphere/pulls/comments/130149761","pull_request_review_id":52998708,"id":130149761,"diff_hunk":"@@ -0,0 +1,165 @@\n+package awsHelper\n+\n+import (\n+\t\"bytes\"\n+\t\"errors\"\n+\t\"fmt\"\n+\t\"io\"\n+\t\"strings\"\n+\n+\t\"github.com/aws/aws-sdk-go/aws\"\n+\t\"github.com/aws/aws-sdk-go/aws/awserr\"\n+\t\"github.com/aws/aws-sdk-go/service/s3\"\n+)\n+\n+const secretsFile string = \"secrets.tfvars\"\n+\n+// CreateSecretsStore creates an S3 bucket  and file object used for secrets management\n+func CreateSecretsStore(secretsBucket, region string) error {\n+\ts3client := createS3client(region)\n+\n+\thasBucket, err := hasBucket(s3client, secretsBucket)\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\n+\t// create bucket if it doesn't exist\n+\tif !hasBucket {\n+\t\t_, err = s3client.CreateBucket(&s3.CreateBucketInput{Bucket: &secretsBucket})\n+\t\tif err != nil {\n+\t\t\treturn err\n+\t\t}\n+\t}\n+\n+\t// create secrets file if it doesn't exist\n+\t_, err = s3client.GetObject(&s3.GetObjectInput{\n+\t\tBucket: aws.String(secretsBucket),\n+\t\tKey:    aws.String(secretsFile),\n+\t})\n+\n+\tif err != nil {\n+\t\tif awsErr, ok := err.(awserr.Error); ok {\n+\t\t\tswitch awsErr.Code() {\n+\t\t\tcase s3.ErrCodeNoSuchKey:\n+\t\t\t\treturn putSecretsFile(map[string]string{}, secretsBucket, region)\n+\t\t\tdefault:\n+\t\t\t\treturn awsErr\n+\t\t\t}\n+\t\t} else {\n+\t\t\treturn err\n+\t\t}\n+\t}\n+\n+\treturn err\n+}\n+\n+// ReadSecrets reads secret key value pair from remote store\n+func ReadSecrets(secretsBucket, region string) (string, error) {\n+\ts3client := createS3client(region)\n+\terr := verifyBucket(s3client, secretsBucket)\n+\tif err != nil {\n+\t\treturn \"\", err\n+\t}\n+\n+\tresults, err := s3client.GetObject(&s3.GetObjectInput{\n+\t\tBucket: aws.String(secretsBucket),\n+\t\tKey:    aws.String(secretsFile),\n+\t})\n+\tif err != nil {\n+\t\treturn \"\", err\n+\t}\n+\n+\tdefer results.Body.Close()","path":"exo-go/src/aws_helpers/secrets_helpers.go","position":72,"original_position":72,"commit_id":"6ea4da8bc21b1a82df3ff901d2b1b5a8d2b37827","original_commit_id":"176d8e56113421bb4654dbff1002ada934dc1b05","user":{"login":"charlierudolph","id":1676758,"avatar_url":"https://avatars2.githubusercontent.com/u/1676758?v=4","gravatar_id":"","url":"https://api.github.com/users/charlierudolph","html_url":"https://github.com/charlierudolph","followers_url":"https://api.github.com/users/charlierudolph/followers","following_url":"https://api.github.com/users/charlierudolph/following{/other_user}","gists_url":"https://api.github.com/users/charlierudolph/gists{/gist_id}","starred_url":"https://api.github.com/users/charlierudolph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/charlierudolph/subscriptions","organizations_url":"https://api.github.com/users/charlierudolph/orgs","repos_url":"https://api.github.com/users/charlierudolph/repos","events_url":"https://api.github.com/users/charlierudolph/events{/privacy}","received_events_url":"https://api.github.com/users/charlierudolph/received_events","type":"User","site_admin":false},"body":"I don't like ignoring any errors. Can we run this at the end of the function instead of deferring it?","created_at":"2017-07-28T18:01:40Z","updated_at":"2017-07-28T18:01:40Z","html_url":"https://github.com/Originate/exosphere/pull/378#discussion_r130149761","pull_request_url":"https://api.github.com/repos/Originate/exosphere/pulls/378","_links":{"self":{"href":"https://api.github.com/repos/Originate/exosphere/pulls/comments/130149761"},"html":{"href":"https://github.com/Originate/exosphere/pull/378#discussion_r130149761"},"pull_request":{"href":"https://api.github.com/repos/Originate/exosphere/pulls/378"}}},"pull_request":{"url":"https://api.github.com/repos/Originate/exosphere/pulls/378","id":133015275,"html_url":"https://github.com/Originate/exosphere/pull/378","diff_url":"https://github.com/Originate/exosphere/pull/378.diff","patch_url":"https://github.com/Originate/exosphere/pull/378.patch","issue_url":"https://api.github.com/repos/Originate/exosphere/issues/378","number":378,"state":"open","locked":false,"title":"exo-deploy: first half of secrets management","user":{"login":"hugobho","id":7258240,"avatar_url":"https://avatars0.githubusercontent.com/u/7258240?v=4","gravatar_id":"","url":"https://api.github.com/users/hugobho","html_url":"https://github.com/hugobho","followers_url":"https://api.github.com/users/hugobho/followers","following_url":"https://api.github.com/users/hugobho/following{/other_user}","gists_url":"https://api.github.com/users/hugobho/gists{/gist_id}","starred_url":"https://api.github.com/users/hugobho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hugobho/subscriptions","organizations_url":"https://api.github.com/users/hugobho/orgs","repos_url":"https://api.github.com/users/hugobho/repos","events_url":"https://api.github.com/users/hugobho/events{/privacy}","received_events_url":"https://api.github.com/users/hugobho/received_events","type":"User","site_admin":false},"body":"C & R of CRUD. Will upload vendor files shortly (updating to Sierra)","created_at":"2017-07-28T17:24:24Z","updated_at":"2017-07-28T18:01:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"562fc18a21f7b752e52ce14d7938ccdb2ea5d964","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/Originate/exosphere/pulls/378/commits","review_comments_url":"https://api.github.com/repos/Originate/exosphere/pulls/378/comments","review_comment_url":"https://api.github.com/repos/Originate/exosphere/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Originate/exosphere/issues/378/comments","statuses_url":"https://api.github.com/repos/Originate/exosphere/statuses/6ea4da8bc21b1a82df3ff901d2b1b5a8d2b37827","head":{"label":"Originate:hh-exo-deploy4","ref":"hh-exo-deploy4","sha":"6ea4da8bc21b1a82df3ff901d2b1b5a8d2b37827","user":{"login":"Originate","id":1627168,"avatar_url":"https://avatars3.githubusercontent.com/u/1627168?v=4","gravatar_id":"","url":"https://api.github.com/users/Originate","html_url":"https://github.com/Originate","followers_url":"https://api.github.com/users/Originate/followers","following_url":"https://api.github.com/users/Originate/following{/other_user}","gists_url":"https://api.github.com/users/Originate/gists{/gist_id}","starred_url":"https://api.github.com/users/Originate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Originate/subscriptions","organizations_url":"https://api.github.com/users/Originate/orgs","repos_url":"https://api.github.com/users/Originate/repos","events_url":"https://api.github.com/users/Originate/events{/privacy}","received_events_url":"https://api.github.com/users/Originate/received_events","type":"Organization","site_admin":false},"repo":{"id":75137299,"name":"exosphere","full_name":"Originate/exosphere","owner":{"login":"Originate","id":1627168,"avatar_url":"https://avatars3.githubusercontent.com/u/1627168?v=4","gravatar_id":"","url":"https://api.github.com/users/Originate","html_url":"https://github.com/Originate","followers_url":"https://api.github.com/users/Originate/followers","following_url":"https://api.github.com/users/Originate/following{/other_user}","gists_url":"https://api.github.com/users/Originate/gists{/gist_id}","starred_url":"https://api.github.com/users/Originate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Originate/subscriptions","organizations_url":"https://api.github.com/users/Originate/orgs","repos_url":"https://api.github.com/users/Originate/repos","events_url":"https://api.github.com/users/Originate/events{/privacy}","received_events_url":"https://api.github.com/users/Originate/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Originate/exosphere","description":"A modern cloud-based micro-service framework","fork":false,"url":"https://api.github.com/repos/Originate/exosphere","forks_url":"https://api.github.com/repos/Originate/exosphere/forks","keys_url":"https://api.github.com/repos/Originate/exosphere/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Originate/exosphere/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Originate/exosphere/teams","hooks_url":"https://api.github.com/repos/Originate/exosphere/hooks","issue_events_url":"https://api.github.com/repos/Originate/exosphere/issues/events{/number}","events_url":"https://api.github.com/repos/Originate/exosphere/events","assignees_url":"https://api.github.com/repos/Originate/exosphere/assignees{/user}","branches_url":"https://api.github.com/repos/Originate/exosphere/branches{/branch}","tags_url":"https://api.github.com/repos/Originate/exosphere/tags","blobs_url":"https://api.github.com/repos/Originate/exosphere/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Originate/exosphere/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Originate/exosphere/git/refs{/sha}","trees_url":"https://api.github.com/repos/Originate/exosphere/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Originate/exosphere/statuses/{sha}","languages_url":"https://api.github.com/repos/Originate/exosphere/languages","stargazers_url":"https://api.github.com/repos/Originate/exosphere/stargazers","contributors_url":"https://api.github.com/repos/Originate/exosphere/contributors","subscribers_url":"https://api.github.com/repos/Originate/exosphere/subscribers","subscription_url":"https://api.github.com/repos/Originate/exosphere/subscription","commits_url":"https://api.github.com/repos/Originate/exosphere/commits{/sha}","git_commits_url":"https://api.github.com/repos/Originate/exosphere/git/commits{/sha}","comments_url":"https://api.github.com/repos/Originate/exosphere/comments{/number}","issue_comment_url":"https://api.github.com/repos/Originate/exosphere/issues/comments{/number}","contents_url":"https://api.github.com/repos/Originate/exosphere/contents/{+path}","compare_url":"https://api.github.com/repos/Originate/exosphere/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Originate/exosphere/merges","archive_url":"https://api.github.com/repos/Originate/exosphere/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Originate/exosphere/downloads","issues_url":"https://api.github.com/repos/Originate/exosphere/issues{/number}","pulls_url":"https://api.github.com/repos/Originate/exosphere/pulls{/number}","milestones_url":"https://api.github.com/repos/Originate/exosphere/milestones{/number}","notifications_url":"https://api.github.com/repos/Originate/exosphere/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Originate/exosphere/labels{/name}","releases_url":"https://api.github.com/repos/Originate/exosphere/releases{/id}","deployments_url":"https://api.github.com/repos/Originate/exosphere/deployments","created_at":"2016-11-30T01:09:58Z","updated_at":"2017-07-20T19:23:47Z","pushed_at":"2017-07-28T18:00:52Z","git_url":"git://github.com/Originate/exosphere.git","ssh_url":"git@github.com:Originate/exosphere.git","clone_url":"https://github.com/Originate/exosphere.git","svn_url":"https://github.com/Originate/exosphere","homepage":null,"size":26381,"stargazers_count":5,"watchers_count":5,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":30,"forks":3,"open_issues":30,"watchers":5,"default_branch":"master"}},"base":{"label":"Originate:hh-exo-deploy3","ref":"hh-exo-deploy3","sha":"2fe4424ca64d68b6428718c090489be87f292571","user":{"login":"Originate","id":1627168,"avatar_url":"https://avatars3.githubusercontent.com/u/1627168?v=4","gravatar_id":"","url":"https://api.github.com/users/Originate","html_url":"https://github.com/Originate","followers_url":"https://api.github.com/users/Originate/followers","following_url":"https://api.github.com/users/Originate/following{/other_user}","gists_url":"https://api.github.com/users/Originate/gists{/gist_id}","starred_url":"https://api.github.com/users/Originate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Originate/subscriptions","organizations_url":"https://api.github.com/users/Originate/orgs","repos_url":"https://api.github.com/users/Originate/repos","events_url":"https://api.github.com/users/Originate/events{/privacy}","received_events_url":"https://api.github.com/users/Originate/received_events","type":"Organization","site_admin":false},"repo":{"id":75137299,"name":"exosphere","full_name":"Originate/exosphere","owner":{"login":"Originate","id":1627168,"avatar_url":"https://avatars3.githubusercontent.com/u/1627168?v=4","gravatar_id":"","url":"https://api.github.com/users/Originate","html_url":"https://github.com/Originate","followers_url":"https://api.github.com/users/Originate/followers","following_url":"https://api.github.com/users/Originate/following{/other_user}","gists_url":"https://api.github.com/users/Originate/gists{/gist_id}","starred_url":"https://api.github.com/users/Originate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Originate/subscriptions","organizations_url":"https://api.github.com/users/Originate/orgs","repos_url":"https://api.github.com/users/Originate/repos","events_url":"https://api.github.com/users/Originate/events{/privacy}","received_events_url":"https://api.github.com/users/Originate/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Originate/exosphere","description":"A modern cloud-based micro-service framework","fork":false,"url":"https://api.github.com/repos/Originate/exosphere","forks_url":"https://api.github.com/repos/Originate/exosphere/forks","keys_url":"https://api.github.com/repos/Originate/exosphere/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Originate/exosphere/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Originate/exosphere/teams","hooks_url":"https://api.github.com/repos/Originate/exosphere/hooks","issue_events_url":"https://api.github.com/repos/Originate/exosphere/issues/events{/number}","events_url":"https://api.github.com/repos/Originate/exosphere/events","assignees_url":"https://api.github.com/repos/Originate/exosphere/assignees{/user}","branches_url":"https://api.github.com/repos/Originate/exosphere/branches{/branch}","tags_url":"https://api.github.com/repos/Originate/exosphere/tags","blobs_url":"https://api.github.com/repos/Originate/exosphere/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Originate/exosphere/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Originate/exosphere/git/refs{/sha}","trees_url":"https://api.github.com/repos/Originate/exosphere/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Originate/exosphere/statuses/{sha}","languages_url":"https://api.github.com/repos/Originate/exosphere/languages","stargazers_url":"https://api.github.com/repos/Originate/exosphere/stargazers","contributors_url":"https://api.github.com/repos/Originate/exosphere/contributors","subscribers_url":"https://api.github.com/repos/Originate/exosphere/subscribers","subscription_url":"https://api.github.com/repos/Originate/exosphere/subscription","commits_url":"https://api.github.com/repos/Originate/exosphere/commits{/sha}","git_commits_url":"https://api.github.com/repos/Originate/exosphere/git/commits{/sha}","comments_url":"https://api.github.com/repos/Originate/exosphere/comments{/number}","issue_comment_url":"https://api.github.com/repos/Originate/exosphere/issues/comments{/number}","contents_url":"https://api.github.com/repos/Originate/exosphere/contents/{+path}","compare_url":"https://api.github.com/repos/Originate/exosphere/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Originate/exosphere/merges","archive_url":"https://api.github.com/repos/Originate/exosphere/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Originate/exosphere/downloads","issues_url":"https://api.github.com/repos/Originate/exosphere/issues{/number}","pulls_url":"https://api.github.com/repos/Originate/exosphere/pulls{/number}","milestones_url":"https://api.github.com/repos/Originate/exosphere/milestones{/number}","notifications_url":"https://api.github.com/repos/Originate/exosphere/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Originate/exosphere/labels{/name}","releases_url":"https://api.github.com/repos/Originate/exosphere/releases{/id}","deployments_url":"https://api.github.com/repos/Originate/exosphere/deployments","created_at":"2016-11-30T01:09:58Z","updated_at":"2017-07-20T19:23:47Z","pushed_at":"2017-07-28T18:00:52Z","git_url":"git://github.com/Originate/exosphere.git","ssh_url":"git@github.com:Originate/exosphere.git","clone_url":"https://github.com/Originate/exosphere.git","svn_url":"https://github.com/Originate/exosphere","homepage":null,"size":26381,"stargazers_count":5,"watchers_count":5,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":30,"forks":3,"open_issues":30,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Originate/exosphere/pulls/378"},"html":{"href":"https://github.com/Originate/exosphere/pull/378"},"issue":{"href":"https://api.github.com/repos/Originate/exosphere/issues/378"},"comments":{"href":"https://api.github.com/repos/Originate/exosphere/issues/378/comments"},"review_comments":{"href":"https://api.github.com/repos/Originate/exosphere/pulls/378/comments"},"review_comment":{"href":"https://api.github.com/repos/Originate/exosphere/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Originate/exosphere/pulls/378/commits"},"statuses":{"href":"https://api.github.com/repos/Originate/exosphere/statuses/6ea4da8bc21b1a82df3ff901d2b1b5a8d2b37827"}}}}
{"actor":{"display_login":"charlierudolph"}}