{"action":"created","comment":{"url":"https://api.github.com/repos/mapbox/ecs-conex/pulls/comments/121435138","pull_request_review_id":43466345,"id":121435138,"diff_hunk":"@@ -30,8 +30,8 @@ function create_repo() {\n \n function set_policy() {\n   local region=$1\n-  RepositoryPermissionPolicy=$(printenv | grep RepositoryPermissionPolicy | sed 's/.*=//')\n-  if [ -n \"$RepositoryPermissionPolicy\" ]\n+  RepositoryPermissionPolicy=$(printenv RepositoryPermissionPolicy)","path":"utils.sh","position":null,"original_position":6,"commit_id":"39856462fe39f2f3f77e2320e5560bcfd51d52ea","original_commit_id":"17028a997d1abcc7ada2a9515db27f3a9cc8004b","user":{"login":"drboyer","id":4665492,"avatar_url":"https://avatars0.githubusercontent.com/u/4665492?v=3","gravatar_id":"","url":"https://api.github.com/users/drboyer","html_url":"https://github.com/drboyer","followers_url":"https://api.github.com/users/drboyer/followers","following_url":"https://api.github.com/users/drboyer/following{/other_user}","gists_url":"https://api.github.com/users/drboyer/gists{/gist_id}","starred_url":"https://api.github.com/users/drboyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drboyer/subscriptions","organizations_url":"https://api.github.com/users/drboyer/orgs","repos_url":"https://api.github.com/users/drboyer/repos","events_url":"https://api.github.com/users/drboyer/events{/privacy}","received_events_url":"https://api.github.com/users/drboyer/received_events","type":"User","site_admin":false},"body":"> If RepositoryPermissionPolicy is set in the env, then why would set -u be a problem?\r\n\r\nHad to chew on this for probably longer than I should've, as it seemed like a totally valid point. And it was. Issue was actually with my test script where I was **[unsetting](https://github.com/mapbox/ecs-conex/pull/100/commits/39856462fe39f2f3f77e2320e5560bcfd51d52ea)** this variable to test the \"no-policy\" case. When I switched to testing a realistic no-policy case (`RepositoryPermissionPolicy=\"\"`), just having the `-n` test worked fine!\r\n\r\nSorry it took so long to get to this. 🙃 ","created_at":"2017-06-12T15:06:23Z","updated_at":"2017-06-12T15:06:24Z","html_url":"https://github.com/mapbox/ecs-conex/pull/100#discussion_r121435138","pull_request_url":"https://api.github.com/repos/mapbox/ecs-conex/pulls/100","_links":{"self":{"href":"https://api.github.com/repos/mapbox/ecs-conex/pulls/comments/121435138"},"html":{"href":"https://github.com/mapbox/ecs-conex/pull/100#discussion_r121435138"},"pull_request":{"href":"https://api.github.com/repos/mapbox/ecs-conex/pulls/100"}}},"pull_request":{"url":"https://api.github.com/repos/mapbox/ecs-conex/pulls/100","id":124505794,"html_url":"https://github.com/mapbox/ecs-conex/pull/100","diff_url":"https://github.com/mapbox/ecs-conex/pull/100.diff","patch_url":"https://github.com/mapbox/ecs-conex/pull/100.patch","issue_url":"https://api.github.com/repos/mapbox/ecs-conex/issues/100","number":100,"state":"open","locked":false,"title":"Add ability to set a repository permission policy","user":{"login":"drboyer","id":4665492,"avatar_url":"https://avatars0.githubusercontent.com/u/4665492?v=3","gravatar_id":"","url":"https://api.github.com/users/drboyer","html_url":"https://github.com/drboyer","followers_url":"https://api.github.com/users/drboyer/followers","following_url":"https://api.github.com/users/drboyer/following{/other_user}","gists_url":"https://api.github.com/users/drboyer/gists{/gist_id}","starred_url":"https://api.github.com/users/drboyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drboyer/subscriptions","organizations_url":"https://api.github.com/users/drboyer/orgs","repos_url":"https://api.github.com/users/drboyer/repos","events_url":"https://api.github.com/users/drboyer/events{/privacy}","received_events_url":"https://api.github.com/users/drboyer/received_events","type":"User","site_admin":false},"body":"This change enables ecs-conex to set a Permissions Policy on _all_ repositories watched by this instance of conex. ECR Permissions policies enable you to share an ECR repository in one account with another AWS account. \r\n\r\n*[➡️ Documentation on ECR Repository Policies](http://docs.aws.amazon.com/AmazonECR/latest/userguide/RepositoryPolicies.html)*\r\n\r\n**How this feature was implemented**\r\nI've implemented this feature where including an IAM policy document as the `RepositoryPermissionPolicy` stack parameter will set it as an environment variable on the watchbot worker. When a worker is processing a job, after ensuring the ECR repo exists in a given region, the policy for the repository will be set as well (this is an idempotent operation if the policy does not change).\r\n\r\n**Testing**\r\nI added what I think are appropriate unit tests to the `test/utils.test.sh` file. I also tested creating an ECR repository using this stack both when the `RepositoryPermissionPolicy` parameter was blank and when it was set to a valid policy to share with another account. In both cases, the expected result happened (the repository was published on ECR, in the former case with no permissions set, in the latter with the specified policy set).","created_at":"2017-06-07T20:02:56Z","updated_at":"2017-06-12T15:06:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9fcf50ad1c46b470ffce103215e538faf9a9e296","assignee":null,"assignees":[],"requested_reviewers":[{"login":"emilymdubois","id":6913048,"avatar_url":"https://avatars2.githubusercontent.com/u/6913048?v=3","gravatar_id":"","url":"https://api.github.com/users/emilymdubois","html_url":"https://github.com/emilymdubois","followers_url":"https://api.github.com/users/emilymdubois/followers","following_url":"https://api.github.com/users/emilymdubois/following{/other_user}","gists_url":"https://api.github.com/users/emilymdubois/gists{/gist_id}","starred_url":"https://api.github.com/users/emilymdubois/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emilymdubois/subscriptions","organizations_url":"https://api.github.com/users/emilymdubois/orgs","repos_url":"https://api.github.com/users/emilymdubois/repos","events_url":"https://api.github.com/users/emilymdubois/events{/privacy}","received_events_url":"https://api.github.com/users/emilymdubois/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/mapbox/ecs-conex/pulls/100/commits","review_comments_url":"https://api.github.com/repos/mapbox/ecs-conex/pulls/100/comments","review_comment_url":"https://api.github.com/repos/mapbox/ecs-conex/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mapbox/ecs-conex/issues/100/comments","statuses_url":"https://api.github.com/repos/mapbox/ecs-conex/statuses/39856462fe39f2f3f77e2320e5560bcfd51d52ea","head":{"label":"mapbox:set-repo-policy","ref":"set-repo-policy","sha":"39856462fe39f2f3f77e2320e5560bcfd51d52ea","user":{"login":"mapbox","id":600935,"avatar_url":"https://avatars2.githubusercontent.com/u/600935?v=3","gravatar_id":"","url":"https://api.github.com/users/mapbox","html_url":"https://github.com/mapbox","followers_url":"https://api.github.com/users/mapbox/followers","following_url":"https://api.github.com/users/mapbox/following{/other_user}","gists_url":"https://api.github.com/users/mapbox/gists{/gist_id}","starred_url":"https://api.github.com/users/mapbox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mapbox/subscriptions","organizations_url":"https://api.github.com/users/mapbox/orgs","repos_url":"https://api.github.com/users/mapbox/repos","events_url":"https://api.github.com/users/mapbox/events{/privacy}","received_events_url":"https://api.github.com/users/mapbox/received_events","type":"Organization","site_admin":false},"repo":{"id":58424071,"name":"ecs-conex","full_name":"mapbox/ecs-conex","owner":{"login":"mapbox","id":600935,"avatar_url":"https://avatars2.githubusercontent.com/u/600935?v=3","gravatar_id":"","url":"https://api.github.com/users/mapbox","html_url":"https://github.com/mapbox","followers_url":"https://api.github.com/users/mapbox/followers","following_url":"https://api.github.com/users/mapbox/following{/other_user}","gists_url":"https://api.github.com/users/mapbox/gists{/gist_id}","starred_url":"https://api.github.com/users/mapbox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mapbox/subscriptions","organizations_url":"https://api.github.com/users/mapbox/orgs","repos_url":"https://api.github.com/users/mapbox/repos","events_url":"https://api.github.com/users/mapbox/events{/privacy}","received_events_url":"https://api.github.com/users/mapbox/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mapbox/ecs-conex","description":"ECS Container Express","fork":false,"url":"https://api.github.com/repos/mapbox/ecs-conex","forks_url":"https://api.github.com/repos/mapbox/ecs-conex/forks","keys_url":"https://api.github.com/repos/mapbox/ecs-conex/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mapbox/ecs-conex/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mapbox/ecs-conex/teams","hooks_url":"https://api.github.com/repos/mapbox/ecs-conex/hooks","issue_events_url":"https://api.github.com/repos/mapbox/ecs-conex/issues/events{/number}","events_url":"https://api.github.com/repos/mapbox/ecs-conex/events","assignees_url":"https://api.github.com/repos/mapbox/ecs-conex/assignees{/user}","branches_url":"https://api.github.com/repos/mapbox/ecs-conex/branches{/branch}","tags_url":"https://api.github.com/repos/mapbox/ecs-conex/tags","blobs_url":"https://api.github.com/repos/mapbox/ecs-conex/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mapbox/ecs-conex/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mapbox/ecs-conex/git/refs{/sha}","trees_url":"https://api.github.com/repos/mapbox/ecs-conex/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mapbox/ecs-conex/statuses/{sha}","languages_url":"https://api.github.com/repos/mapbox/ecs-conex/languages","stargazers_url":"https://api.github.com/repos/mapbox/ecs-conex/stargazers","contributors_url":"https://api.github.com/repos/mapbox/ecs-conex/contributors","subscribers_url":"https://api.github.com/repos/mapbox/ecs-conex/subscribers","subscription_url":"https://api.github.com/repos/mapbox/ecs-conex/subscription","commits_url":"https://api.github.com/repos/mapbox/ecs-conex/commits{/sha}","git_commits_url":"https://api.github.com/repos/mapbox/ecs-conex/git/commits{/sha}","comments_url":"https://api.github.com/repos/mapbox/ecs-conex/comments{/number}","issue_comment_url":"https://api.github.com/repos/mapbox/ecs-conex/issues/comments{/number}","contents_url":"https://api.github.com/repos/mapbox/ecs-conex/contents/{+path}","compare_url":"https://api.github.com/repos/mapbox/ecs-conex/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mapbox/ecs-conex/merges","archive_url":"https://api.github.com/repos/mapbox/ecs-conex/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mapbox/ecs-conex/downloads","issues_url":"https://api.github.com/repos/mapbox/ecs-conex/issues{/number}","pulls_url":"https://api.github.com/repos/mapbox/ecs-conex/pulls{/number}","milestones_url":"https://api.github.com/repos/mapbox/ecs-conex/milestones{/number}","notifications_url":"https://api.github.com/repos/mapbox/ecs-conex/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mapbox/ecs-conex/labels{/name}","releases_url":"https://api.github.com/repos/mapbox/ecs-conex/releases{/id}","deployments_url":"https://api.github.com/repos/mapbox/ecs-conex/deployments","created_at":"2016-05-10T02:39:11Z","updated_at":"2017-05-12T10:26:15Z","pushed_at":"2017-06-12T14:59:04Z","git_url":"git://github.com/mapbox/ecs-conex.git","ssh_url":"git@github.com:mapbox/ecs-conex.git","clone_url":"https://github.com/mapbox/ecs-conex.git","svn_url":"https://github.com/mapbox/ecs-conex","homepage":null,"size":156,"stargazers_count":21,"watchers_count":21,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":22,"forks":2,"open_issues":22,"watchers":21,"default_branch":"master"}},"base":{"label":"mapbox:master","ref":"master","sha":"b240e7d199e0829996c779a697b6db113e5984a2","user":{"login":"mapbox","id":600935,"avatar_url":"https://avatars2.githubusercontent.com/u/600935?v=3","gravatar_id":"","url":"https://api.github.com/users/mapbox","html_url":"https://github.com/mapbox","followers_url":"https://api.github.com/users/mapbox/followers","following_url":"https://api.github.com/users/mapbox/following{/other_user}","gists_url":"https://api.github.com/users/mapbox/gists{/gist_id}","starred_url":"https://api.github.com/users/mapbox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mapbox/subscriptions","organizations_url":"https://api.github.com/users/mapbox/orgs","repos_url":"https://api.github.com/users/mapbox/repos","events_url":"https://api.github.com/users/mapbox/events{/privacy}","received_events_url":"https://api.github.com/users/mapbox/received_events","type":"Organization","site_admin":false},"repo":{"id":58424071,"name":"ecs-conex","full_name":"mapbox/ecs-conex","owner":{"login":"mapbox","id":600935,"avatar_url":"https://avatars2.githubusercontent.com/u/600935?v=3","gravatar_id":"","url":"https://api.github.com/users/mapbox","html_url":"https://github.com/mapbox","followers_url":"https://api.github.com/users/mapbox/followers","following_url":"https://api.github.com/users/mapbox/following{/other_user}","gists_url":"https://api.github.com/users/mapbox/gists{/gist_id}","starred_url":"https://api.github.com/users/mapbox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mapbox/subscriptions","organizations_url":"https://api.github.com/users/mapbox/orgs","repos_url":"https://api.github.com/users/mapbox/repos","events_url":"https://api.github.com/users/mapbox/events{/privacy}","received_events_url":"https://api.github.com/users/mapbox/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mapbox/ecs-conex","description":"ECS Container Express","fork":false,"url":"https://api.github.com/repos/mapbox/ecs-conex","forks_url":"https://api.github.com/repos/mapbox/ecs-conex/forks","keys_url":"https://api.github.com/repos/mapbox/ecs-conex/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mapbox/ecs-conex/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mapbox/ecs-conex/teams","hooks_url":"https://api.github.com/repos/mapbox/ecs-conex/hooks","issue_events_url":"https://api.github.com/repos/mapbox/ecs-conex/issues/events{/number}","events_url":"https://api.github.com/repos/mapbox/ecs-conex/events","assignees_url":"https://api.github.com/repos/mapbox/ecs-conex/assignees{/user}","branches_url":"https://api.github.com/repos/mapbox/ecs-conex/branches{/branch}","tags_url":"https://api.github.com/repos/mapbox/ecs-conex/tags","blobs_url":"https://api.github.com/repos/mapbox/ecs-conex/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mapbox/ecs-conex/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mapbox/ecs-conex/git/refs{/sha}","trees_url":"https://api.github.com/repos/mapbox/ecs-conex/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mapbox/ecs-conex/statuses/{sha}","languages_url":"https://api.github.com/repos/mapbox/ecs-conex/languages","stargazers_url":"https://api.github.com/repos/mapbox/ecs-conex/stargazers","contributors_url":"https://api.github.com/repos/mapbox/ecs-conex/contributors","subscribers_url":"https://api.github.com/repos/mapbox/ecs-conex/subscribers","subscription_url":"https://api.github.com/repos/mapbox/ecs-conex/subscription","commits_url":"https://api.github.com/repos/mapbox/ecs-conex/commits{/sha}","git_commits_url":"https://api.github.com/repos/mapbox/ecs-conex/git/commits{/sha}","comments_url":"https://api.github.com/repos/mapbox/ecs-conex/comments{/number}","issue_comment_url":"https://api.github.com/repos/mapbox/ecs-conex/issues/comments{/number}","contents_url":"https://api.github.com/repos/mapbox/ecs-conex/contents/{+path}","compare_url":"https://api.github.com/repos/mapbox/ecs-conex/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mapbox/ecs-conex/merges","archive_url":"https://api.github.com/repos/mapbox/ecs-conex/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mapbox/ecs-conex/downloads","issues_url":"https://api.github.com/repos/mapbox/ecs-conex/issues{/number}","pulls_url":"https://api.github.com/repos/mapbox/ecs-conex/pulls{/number}","milestones_url":"https://api.github.com/repos/mapbox/ecs-conex/milestones{/number}","notifications_url":"https://api.github.com/repos/mapbox/ecs-conex/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mapbox/ecs-conex/labels{/name}","releases_url":"https://api.github.com/repos/mapbox/ecs-conex/releases{/id}","deployments_url":"https://api.github.com/repos/mapbox/ecs-conex/deployments","created_at":"2016-05-10T02:39:11Z","updated_at":"2017-05-12T10:26:15Z","pushed_at":"2017-06-12T14:59:04Z","git_url":"git://github.com/mapbox/ecs-conex.git","ssh_url":"git@github.com:mapbox/ecs-conex.git","clone_url":"https://github.com/mapbox/ecs-conex.git","svn_url":"https://github.com/mapbox/ecs-conex","homepage":null,"size":156,"stargazers_count":21,"watchers_count":21,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":22,"forks":2,"open_issues":22,"watchers":21,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mapbox/ecs-conex/pulls/100"},"html":{"href":"https://github.com/mapbox/ecs-conex/pull/100"},"issue":{"href":"https://api.github.com/repos/mapbox/ecs-conex/issues/100"},"comments":{"href":"https://api.github.com/repos/mapbox/ecs-conex/issues/100/comments"},"review_comments":{"href":"https://api.github.com/repos/mapbox/ecs-conex/pulls/100/comments"},"review_comment":{"href":"https://api.github.com/repos/mapbox/ecs-conex/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mapbox/ecs-conex/pulls/100/commits"},"statuses":{"href":"https://api.github.com/repos/mapbox/ecs-conex/statuses/39856462fe39f2f3f77e2320e5560bcfd51d52ea"}}}}
{"actor":{"display_login":"drboyer"}}