{"action":"created","comment":{"url":"https://api.github.com/repos/GovTechSG/terraform-modules/pulls/comments/192021325","pull_request_review_id":124709553,"id":192021325,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5MjAyMTMyNQ==","diff_hunk":"@@ -202,13 +204,97 @@ EOF\n   chown \"${user}:${user}\" \"${config_dir}/acl.hcl\"\n }\n \n+function generate_docker_config {\n+  local readonly consul_prefix=\"${1}\"\n+  local readonly config_dir=\"${2}\"\n+  local readonly user=\"${3}\"\n+  local readonly consul_template_config=\"${4}\"\n+  local readonly docker_auth_path=\"${5}\"\n+\n+    local docker_config=$(cat <<EOF\n+client {\n+  options {\n+    \"docker.auth.config\" = \"${docker_auth_path}\"\n+  }\n+}\n+EOF\n+)\n+\n+  log_info \"Writing Docker configuration to ${config_dir}/docker.hcl\"\n+  echo \"${docker_config}\" > \"${config_dir}/docker.hcl\"\n+  chown \"${user}:${user}\" \"${config_dir}/docker.hcl\"\n+\n+  local vault_path\n+  vault_path=$(consul_kv \"${consul_prefix}docker-auth/path\")\n+\n+  local docker_template=$(cat <<EOF\n+template {\n+  destination = \"${docker_auth_path}\"\n+  create_dest_dirs = true\n+\n+  # consul-template does not deal with ownership properly\n+  # See https://github.com/hashicorp/consul-template/issues/1061\n+  command = \"bash -c 'chown ${user}:${user} ${docker_auth_path}'\"\n+\n+  perms = 0600\n+  error_on_missing_key = true\n+\n+  # The goal is to produce something like\n+  # {\n+  #     \"auths\": {\n+  #         \"registry.a.b\": {\n+  #           \"auth\": \"aaaaa=\"\n+  #         },\n+  #         \"foo.bar.xyz\": {\n+  #           \"auth\": \"bbbb=\"\n+  #         }\n+  #     }\n+  # }\n+  #\n+  # But two things make it difficult:\n+  # 1. JSON doesn't do dangling commas\n+  # 2. Go Template has really basic logic handling\n+  #\n+  # Thus this template is more complicated than needed.\n+  contents = <<EOH\n+{{- define \"keys\" -}}\n+  {{- with secret \"${vault_path}\" }}\n+      {{- range \\$key, \\$value := .Data -}}\n+        {{ \\$key }}{{ \" \" }}","path":"modules/core/packer/roles/nomad/files/configure.sh","position":69,"original_position":69,"commit_id":"5775ec00544300ebc572f918377ac09d7f60f15c","original_commit_id":"5775ec00544300ebc572f918377ac09d7f60f15c","user":{"login":"lawliet89","id":983101,"node_id":"MDQ6VXNlcjk4MzEwMQ==","avatar_url":"https://avatars2.githubusercontent.com/u/983101?v=4","gravatar_id":"","url":"https://api.github.com/users/lawliet89","html_url":"https://github.com/lawliet89","followers_url":"https://api.github.com/users/lawliet89/followers","following_url":"https://api.github.com/users/lawliet89/following{/other_user}","gists_url":"https://api.github.com/users/lawliet89/gists{/gist_id}","starred_url":"https://api.github.com/users/lawliet89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lawliet89/subscriptions","organizations_url":"https://api.github.com/users/lawliet89/orgs","repos_url":"https://api.github.com/users/lawliet89/repos","events_url":"https://api.github.com/users/lawliet89/events{/privacy}","received_events_url":"https://api.github.com/users/lawliet89/received_events","type":"User","site_admin":false},"body":"There is a join. But I can't get a list of map keys only. LOL","created_at":"2018-05-31T08:18:34Z","updated_at":"2018-05-31T08:18:35Z","html_url":"https://github.com/GovTechSG/terraform-modules/pull/66#discussion_r192021325","pull_request_url":"https://api.github.com/repos/GovTechSG/terraform-modules/pulls/66","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/GovTechSG/terraform-modules/pulls/comments/192021325"},"html":{"href":"https://github.com/GovTechSG/terraform-modules/pull/66#discussion_r192021325"},"pull_request":{"href":"https://api.github.com/repos/GovTechSG/terraform-modules/pulls/66"}},"in_reply_to_id":191962737},"pull_request":{"url":"https://api.github.com/repos/GovTechSG/terraform-modules/pulls/66","id":191415182,"node_id":"MDExOlB1bGxSZXF1ZXN0MTkxNDE1MTgy","html_url":"https://github.com/GovTechSG/terraform-modules/pull/66","diff_url":"https://github.com/GovTechSG/terraform-modules/pull/66.diff","patch_url":"https://github.com/GovTechSG/terraform-modules/pull/66.patch","issue_url":"https://api.github.com/repos/GovTechSG/terraform-modules/issues/66","number":66,"state":"open","locked":false,"title":"Integration to retrieve private Docker auth from Vault","user":{"login":"lawliet89","id":983101,"node_id":"MDQ6VXNlcjk4MzEwMQ==","avatar_url":"https://avatars2.githubusercontent.com/u/983101?v=4","gravatar_id":"","url":"https://api.github.com/users/lawliet89","html_url":"https://github.com/lawliet89","followers_url":"https://api.github.com/users/lawliet89/followers","following_url":"https://api.github.com/users/lawliet89/following{/other_user}","gists_url":"https://api.github.com/users/lawliet89/gists{/gist_id}","starred_url":"https://api.github.com/users/lawliet89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lawliet89/subscriptions","organizations_url":"https://api.github.com/users/lawliet89/orgs","repos_url":"https://api.github.com/users/lawliet89/repos","events_url":"https://api.github.com/users/lawliet89/events{/privacy}","received_events_url":"https://api.github.com/users/lawliet89/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-05-30T11:06:56Z","updated_at":"2018-05-31T08:18:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7b526f04b68779a9326674439c588bda8e3f2d9f","assignee":null,"assignees":[],"requested_reviewers":[{"login":"chrissng","id":1767795,"node_id":"MDQ6VXNlcjE3Njc3OTU=","avatar_url":"https://avatars3.githubusercontent.com/u/1767795?v=4","gravatar_id":"","url":"https://api.github.com/users/chrissng","html_url":"https://github.com/chrissng","followers_url":"https://api.github.com/users/chrissng/followers","following_url":"https://api.github.com/users/chrissng/following{/other_user}","gists_url":"https://api.github.com/users/chrissng/gists{/gist_id}","starred_url":"https://api.github.com/users/chrissng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrissng/subscriptions","organizations_url":"https://api.github.com/users/chrissng/orgs","repos_url":"https://api.github.com/users/chrissng/repos","events_url":"https://api.github.com/users/chrissng/events{/privacy}","received_events_url":"https://api.github.com/users/chrissng/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/GovTechSG/terraform-modules/pulls/66/commits","review_comments_url":"https://api.github.com/repos/GovTechSG/terraform-modules/pulls/66/comments","review_comment_url":"https://api.github.com/repos/GovTechSG/terraform-modules/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GovTechSG/terraform-modules/issues/66/comments","statuses_url":"https://api.github.com/repos/GovTechSG/terraform-modules/statuses/5775ec00544300ebc572f918377ac09d7f60f15c","head":{"label":"GovTechSG:docker-auth","ref":"docker-auth","sha":"5775ec00544300ebc572f918377ac09d7f60f15c","user":{"login":"GovTechSG","id":12439141,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEyNDM5MTQx","avatar_url":"https://avatars0.githubusercontent.com/u/12439141?v=4","gravatar_id":"","url":"https://api.github.com/users/GovTechSG","html_url":"https://github.com/GovTechSG","followers_url":"https://api.github.com/users/GovTechSG/followers","following_url":"https://api.github.com/users/GovTechSG/following{/other_user}","gists_url":"https://api.github.com/users/GovTechSG/gists{/gist_id}","starred_url":"https://api.github.com/users/GovTechSG/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GovTechSG/subscriptions","organizations_url":"https://api.github.com/users/GovTechSG/orgs","repos_url":"https://api.github.com/users/GovTechSG/repos","events_url":"https://api.github.com/users/GovTechSG/events{/privacy}","received_events_url":"https://api.github.com/users/GovTechSG/received_events","type":"Organization","site_admin":false},"repo":{"id":122424272,"node_id":"MDEwOlJlcG9zaXRvcnkxMjI0MjQyNzI=","name":"terraform-modules","full_name":"GovTechSG/terraform-modules","owner":{"login":"GovTechSG","id":12439141,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEyNDM5MTQx","avatar_url":"https://avatars0.githubusercontent.com/u/12439141?v=4","gravatar_id":"","url":"https://api.github.com/users/GovTechSG","html_url":"https://github.com/GovTechSG","followers_url":"https://api.github.com/users/GovTechSG/followers","following_url":"https://api.github.com/users/GovTechSG/following{/other_user}","gists_url":"https://api.github.com/users/GovTechSG/gists{/gist_id}","starred_url":"https://api.github.com/users/GovTechSG/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GovTechSG/subscriptions","organizations_url":"https://api.github.com/users/GovTechSG/orgs","repos_url":"https://api.github.com/users/GovTechSG/repos","events_url":"https://api.github.com/users/GovTechSG/events{/privacy}","received_events_url":"https://api.github.com/users/GovTechSG/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GovTechSG/terraform-modules","description":"Reusable Terraform modules","fork":false,"url":"https://api.github.com/repos/GovTechSG/terraform-modules","forks_url":"https://api.github.com/repos/GovTechSG/terraform-modules/forks","keys_url":"https://api.github.com/repos/GovTechSG/terraform-modules/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GovTechSG/terraform-modules/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GovTechSG/terraform-modules/teams","hooks_url":"https://api.github.com/repos/GovTechSG/terraform-modules/hooks","issue_events_url":"https://api.github.com/repos/GovTechSG/terraform-modules/issues/events{/number}","events_url":"https://api.github.com/repos/GovTechSG/terraform-modules/events","assignees_url":"https://api.github.com/repos/GovTechSG/terraform-modules/assignees{/user}","branches_url":"https://api.github.com/repos/GovTechSG/terraform-modules/branches{/branch}","tags_url":"https://api.github.com/repos/GovTechSG/terraform-modules/tags","blobs_url":"https://api.github.com/repos/GovTechSG/terraform-modules/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GovTechSG/terraform-modules/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GovTechSG/terraform-modules/git/refs{/sha}","trees_url":"https://api.github.com/repos/GovTechSG/terraform-modules/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GovTechSG/terraform-modules/statuses/{sha}","languages_url":"https://api.github.com/repos/GovTechSG/terraform-modules/languages","stargazers_url":"https://api.github.com/repos/GovTechSG/terraform-modules/stargazers","contributors_url":"https://api.github.com/repos/GovTechSG/terraform-modules/contributors","subscribers_url":"https://api.github.com/repos/GovTechSG/terraform-modules/subscribers","subscription_url":"https://api.github.com/repos/GovTechSG/terraform-modules/subscription","commits_url":"https://api.github.com/repos/GovTechSG/terraform-modules/commits{/sha}","git_commits_url":"https://api.github.com/repos/GovTechSG/terraform-modules/git/commits{/sha}","comments_url":"https://api.github.com/repos/GovTechSG/terraform-modules/comments{/number}","issue_comment_url":"https://api.github.com/repos/GovTechSG/terraform-modules/issues/comments{/number}","contents_url":"https://api.github.com/repos/GovTechSG/terraform-modules/contents/{+path}","compare_url":"https://api.github.com/repos/GovTechSG/terraform-modules/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GovTechSG/terraform-modules/merges","archive_url":"https://api.github.com/repos/GovTechSG/terraform-modules/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GovTechSG/terraform-modules/downloads","issues_url":"https://api.github.com/repos/GovTechSG/terraform-modules/issues{/number}","pulls_url":"https://api.github.com/repos/GovTechSG/terraform-modules/pulls{/number}","milestones_url":"https://api.github.com/repos/GovTechSG/terraform-modules/milestones{/number}","notifications_url":"https://api.github.com/repos/GovTechSG/terraform-modules/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GovTechSG/terraform-modules/labels{/name}","releases_url":"https://api.github.com/repos/GovTechSG/terraform-modules/releases{/id}","deployments_url":"https://api.github.com/repos/GovTechSG/terraform-modules/deployments","created_at":"2018-02-22T03:08:06Z","updated_at":"2018-05-30T02:04:01Z","pushed_at":"2018-05-30T11:29:26Z","git_url":"git://github.com/GovTechSG/terraform-modules.git","ssh_url":"git@github.com:GovTechSG/terraform-modules.git","clone_url":"https://github.com/GovTechSG/terraform-modules.git","svn_url":"https://github.com/GovTechSG/terraform-modules","homepage":null,"size":184,"stargazers_count":2,"watchers_count":2,"language":"HCL","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":14,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":14,"watchers":2,"default_branch":"master"}},"base":{"label":"GovTechSG:master","ref":"master","sha":"c6216c2524a638d6cdfa6332e7a3338be06fe830","user":{"login":"GovTechSG","id":12439141,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEyNDM5MTQx","avatar_url":"https://avatars0.githubusercontent.com/u/12439141?v=4","gravatar_id":"","url":"https://api.github.com/users/GovTechSG","html_url":"https://github.com/GovTechSG","followers_url":"https://api.github.com/users/GovTechSG/followers","following_url":"https://api.github.com/users/GovTechSG/following{/other_user}","gists_url":"https://api.github.com/users/GovTechSG/gists{/gist_id}","starred_url":"https://api.github.com/users/GovTechSG/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GovTechSG/subscriptions","organizations_url":"https://api.github.com/users/GovTechSG/orgs","repos_url":"https://api.github.com/users/GovTechSG/repos","events_url":"https://api.github.com/users/GovTechSG/events{/privacy}","received_events_url":"https://api.github.com/users/GovTechSG/received_events","type":"Organization","site_admin":false},"repo":{"id":122424272,"node_id":"MDEwOlJlcG9zaXRvcnkxMjI0MjQyNzI=","name":"terraform-modules","full_name":"GovTechSG/terraform-modules","owner":{"login":"GovTechSG","id":12439141,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEyNDM5MTQx","avatar_url":"https://avatars0.githubusercontent.com/u/12439141?v=4","gravatar_id":"","url":"https://api.github.com/users/GovTechSG","html_url":"https://github.com/GovTechSG","followers_url":"https://api.github.com/users/GovTechSG/followers","following_url":"https://api.github.com/users/GovTechSG/following{/other_user}","gists_url":"https://api.github.com/users/GovTechSG/gists{/gist_id}","starred_url":"https://api.github.com/users/GovTechSG/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GovTechSG/subscriptions","organizations_url":"https://api.github.com/users/GovTechSG/orgs","repos_url":"https://api.github.com/users/GovTechSG/repos","events_url":"https://api.github.com/users/GovTechSG/events{/privacy}","received_events_url":"https://api.github.com/users/GovTechSG/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GovTechSG/terraform-modules","description":"Reusable Terraform modules","fork":false,"url":"https://api.github.com/repos/GovTechSG/terraform-modules","forks_url":"https://api.github.com/repos/GovTechSG/terraform-modules/forks","keys_url":"https://api.github.com/repos/GovTechSG/terraform-modules/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GovTechSG/terraform-modules/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GovTechSG/terraform-modules/teams","hooks_url":"https://api.github.com/repos/GovTechSG/terraform-modules/hooks","issue_events_url":"https://api.github.com/repos/GovTechSG/terraform-modules/issues/events{/number}","events_url":"https://api.github.com/repos/GovTechSG/terraform-modules/events","assignees_url":"https://api.github.com/repos/GovTechSG/terraform-modules/assignees{/user}","branches_url":"https://api.github.com/repos/GovTechSG/terraform-modules/branches{/branch}","tags_url":"https://api.github.com/repos/GovTechSG/terraform-modules/tags","blobs_url":"https://api.github.com/repos/GovTechSG/terraform-modules/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GovTechSG/terraform-modules/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GovTechSG/terraform-modules/git/refs{/sha}","trees_url":"https://api.github.com/repos/GovTechSG/terraform-modules/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GovTechSG/terraform-modules/statuses/{sha}","languages_url":"https://api.github.com/repos/GovTechSG/terraform-modules/languages","stargazers_url":"https://api.github.com/repos/GovTechSG/terraform-modules/stargazers","contributors_url":"https://api.github.com/repos/GovTechSG/terraform-modules/contributors","subscribers_url":"https://api.github.com/repos/GovTechSG/terraform-modules/subscribers","subscription_url":"https://api.github.com/repos/GovTechSG/terraform-modules/subscription","commits_url":"https://api.github.com/repos/GovTechSG/terraform-modules/commits{/sha}","git_commits_url":"https://api.github.com/repos/GovTechSG/terraform-modules/git/commits{/sha}","comments_url":"https://api.github.com/repos/GovTechSG/terraform-modules/comments{/number}","issue_comment_url":"https://api.github.com/repos/GovTechSG/terraform-modules/issues/comments{/number}","contents_url":"https://api.github.com/repos/GovTechSG/terraform-modules/contents/{+path}","compare_url":"https://api.github.com/repos/GovTechSG/terraform-modules/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GovTechSG/terraform-modules/merges","archive_url":"https://api.github.com/repos/GovTechSG/terraform-modules/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GovTechSG/terraform-modules/downloads","issues_url":"https://api.github.com/repos/GovTechSG/terraform-modules/issues{/number}","pulls_url":"https://api.github.com/repos/GovTechSG/terraform-modules/pulls{/number}","milestones_url":"https://api.github.com/repos/GovTechSG/terraform-modules/milestones{/number}","notifications_url":"https://api.github.com/repos/GovTechSG/terraform-modules/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GovTechSG/terraform-modules/labels{/name}","releases_url":"https://api.github.com/repos/GovTechSG/terraform-modules/releases{/id}","deployments_url":"https://api.github.com/repos/GovTechSG/terraform-modules/deployments","created_at":"2018-02-22T03:08:06Z","updated_at":"2018-05-30T02:04:01Z","pushed_at":"2018-05-30T11:29:26Z","git_url":"git://github.com/GovTechSG/terraform-modules.git","ssh_url":"git@github.com:GovTechSG/terraform-modules.git","clone_url":"https://github.com/GovTechSG/terraform-modules.git","svn_url":"https://github.com/GovTechSG/terraform-modules","homepage":null,"size":184,"stargazers_count":2,"watchers_count":2,"language":"HCL","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":14,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":14,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GovTechSG/terraform-modules/pulls/66"},"html":{"href":"https://github.com/GovTechSG/terraform-modules/pull/66"},"issue":{"href":"https://api.github.com/repos/GovTechSG/terraform-modules/issues/66"},"comments":{"href":"https://api.github.com/repos/GovTechSG/terraform-modules/issues/66/comments"},"review_comments":{"href":"https://api.github.com/repos/GovTechSG/terraform-modules/pulls/66/comments"},"review_comment":{"href":"https://api.github.com/repos/GovTechSG/terraform-modules/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GovTechSG/terraform-modules/pulls/66/commits"},"statuses":{"href":"https://api.github.com/repos/GovTechSG/terraform-modules/statuses/5775ec00544300ebc572f918377ac09d7f60f15c"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"lawliet89"}}