{"action":"created","comment":{"url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/pulls/comments/241571376","pull_request_review_id":184881513,"id":241571376,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0MTU3MTM3Ng==","diff_hunk":"@@ -260,6 +264,29 @@ def _write_htpasswd(path, user, password):\n     return True\n \n \n+def _write_tls_blobs_to_files():\n+    '''Write the user defined TLS blobs to files.\n+\n+    :parm charm_config: Object\n+    :return: None\n+    '''\n+    charm_config = hookenv.config()\n+\n+    blobs = [\n+        ('tls-cert-blob', 'tls-cert-path'),\n+        ('tls-ca-blob', 'tls-ca-path'),\n+        ('tls-key-blob', 'tls-key-path')\n+    ]\n+\n+    for blob, path in blobs:\n+        content = charm_config.get(blob)\n+        if content:\n+            if not os.path.isdir(os.path.basename(path)):\n+                os.makedirs(os.path.basename(path))","path":"lib/charms/layer/docker_registry.py","position":33,"original_position":33,"commit_id":"cd1b64cfa3a61c55ed0004842084b9619aeffb03","original_commit_id":"cd1b64cfa3a61c55ed0004842084b9619aeffb03","user":{"login":"johnsca","id":406082,"node_id":"MDQ6VXNlcjQwNjA4Mg==","avatar_url":"https://avatars3.githubusercontent.com/u/406082?v=4","gravatar_id":"","url":"https://api.github.com/users/johnsca","html_url":"https://github.com/johnsca","followers_url":"https://api.github.com/users/johnsca/followers","following_url":"https://api.github.com/users/johnsca/following{/other_user}","gists_url":"https://api.github.com/users/johnsca/gists{/gist_id}","starred_url":"https://api.github.com/users/johnsca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnsca/subscriptions","organizations_url":"https://api.github.com/users/johnsca/orgs","repos_url":"https://api.github.com/users/johnsca/repos","events_url":"https://api.github.com/users/johnsca/events{/privacy}","received_events_url":"https://api.github.com/users/johnsca/received_events","type":"User","site_admin":false},"body":"My suggestion is this:\r\n\r\n```python\r\ndef _write_tls_blobs_to_files():\r\n    '''Write the user defined TLS blobs to files.\r\n    :parm charm_config: Object\r\n    :return: None\r\n    '''\r\n    charm_config = hookenv.config()\r\n\r\n    blobs = [\r\n        ('tls-cert-blob', 'tls-cert-path'),\r\n        ('tls-ca-blob', 'tls-ca-path'),\r\n        ('tls-key-blob', 'tls-key-path')\r\n    ]\r\n\r\n    for blob, path in blobs:\r\n        content = charm_config.get(blob)\r\n        path = Path(charm_config[path])\r\n        if content:\r\n            path.parent.mkdir(parents=True, exist_ok=True)\r\n            path.write_bytes(base64.b64decode(content))\r\n```","created_at":"2018-12-13T21:41:20Z","updated_at":"2018-12-13T21:41:20Z","html_url":"https://github.com/CanonicalLtd/docker-registry-charm/pull/20#discussion_r241571376","pull_request_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/pulls/20","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/pulls/comments/241571376"},"html":{"href":"https://github.com/CanonicalLtd/docker-registry-charm/pull/20#discussion_r241571376"},"pull_request":{"href":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/pulls/20"}},"in_reply_to_id":241571072},"pull_request":{"url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/pulls/20","id":238536386,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM4NTM2Mzg2","html_url":"https://github.com/CanonicalLtd/docker-registry-charm/pull/20","diff_url":"https://github.com/CanonicalLtd/docker-registry-charm/pull/20.diff","patch_url":"https://github.com/CanonicalLtd/docker-registry-charm/pull/20.patch","issue_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/issues/20","number":20,"state":"open","locked":false,"title":"Ability to add blobs for TLS","user":{"login":"joedborg","id":1426404,"node_id":"MDQ6VXNlcjE0MjY0MDQ=","avatar_url":"https://avatars3.githubusercontent.com/u/1426404?v=4","gravatar_id":"","url":"https://api.github.com/users/joedborg","html_url":"https://github.com/joedborg","followers_url":"https://api.github.com/users/joedborg/followers","following_url":"https://api.github.com/users/joedborg/following{/other_user}","gists_url":"https://api.github.com/users/joedborg/gists{/gist_id}","starred_url":"https://api.github.com/users/joedborg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joedborg/subscriptions","organizations_url":"https://api.github.com/users/joedborg/orgs","repos_url":"https://api.github.com/users/joedborg/repos","events_url":"https://api.github.com/users/joedborg/events{/privacy}","received_events_url":"https://api.github.com/users/joedborg/received_events","type":"User","site_admin":false},"body":"https://bugs.launchpad.net/layer-docker-registry/+bug/1788891","created_at":"2018-12-13T21:22:19Z","updated_at":"2018-12-13T21:41:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"07ef1c1f3fc83d7d73e5a729e076e868ecf13509","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/pulls/20/commits","review_comments_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/pulls/20/comments","review_comment_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/issues/20/comments","statuses_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/statuses/cd1b64cfa3a61c55ed0004842084b9619aeffb03","head":{"label":"joedborg:blob-tls","ref":"blob-tls","sha":"cd1b64cfa3a61c55ed0004842084b9619aeffb03","user":{"login":"joedborg","id":1426404,"node_id":"MDQ6VXNlcjE0MjY0MDQ=","avatar_url":"https://avatars3.githubusercontent.com/u/1426404?v=4","gravatar_id":"","url":"https://api.github.com/users/joedborg","html_url":"https://github.com/joedborg","followers_url":"https://api.github.com/users/joedborg/followers","following_url":"https://api.github.com/users/joedborg/following{/other_user}","gists_url":"https://api.github.com/users/joedborg/gists{/gist_id}","starred_url":"https://api.github.com/users/joedborg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joedborg/subscriptions","organizations_url":"https://api.github.com/users/joedborg/orgs","repos_url":"https://api.github.com/users/joedborg/repos","events_url":"https://api.github.com/users/joedborg/events{/privacy}","received_events_url":"https://api.github.com/users/joedborg/received_events","type":"User","site_admin":false},"repo":{"id":161696126,"node_id":"MDEwOlJlcG9zaXRvcnkxNjE2OTYxMjY=","name":"docker-registry-charm","full_name":"joedborg/docker-registry-charm","private":false,"owner":{"login":"joedborg","id":1426404,"node_id":"MDQ6VXNlcjE0MjY0MDQ=","avatar_url":"https://avatars3.githubusercontent.com/u/1426404?v=4","gravatar_id":"","url":"https://api.github.com/users/joedborg","html_url":"https://github.com/joedborg","followers_url":"https://api.github.com/users/joedborg/followers","following_url":"https://api.github.com/users/joedborg/following{/other_user}","gists_url":"https://api.github.com/users/joedborg/gists{/gist_id}","starred_url":"https://api.github.com/users/joedborg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joedborg/subscriptions","organizations_url":"https://api.github.com/users/joedborg/orgs","repos_url":"https://api.github.com/users/joedborg/repos","events_url":"https://api.github.com/users/joedborg/events{/privacy}","received_events_url":"https://api.github.com/users/joedborg/received_events","type":"User","site_admin":false},"html_url":"https://github.com/joedborg/docker-registry-charm","description":"PLEASE FILE ISSUES ON LAUNCHPAD","fork":true,"url":"https://api.github.com/repos/joedborg/docker-registry-charm","forks_url":"https://api.github.com/repos/joedborg/docker-registry-charm/forks","keys_url":"https://api.github.com/repos/joedborg/docker-registry-charm/keys{/key_id}","collaborators_url":"https://api.github.com/repos/joedborg/docker-registry-charm/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/joedborg/docker-registry-charm/teams","hooks_url":"https://api.github.com/repos/joedborg/docker-registry-charm/hooks","issue_events_url":"https://api.github.com/repos/joedborg/docker-registry-charm/issues/events{/number}","events_url":"https://api.github.com/repos/joedborg/docker-registry-charm/events","assignees_url":"https://api.github.com/repos/joedborg/docker-registry-charm/assignees{/user}","branches_url":"https://api.github.com/repos/joedborg/docker-registry-charm/branches{/branch}","tags_url":"https://api.github.com/repos/joedborg/docker-registry-charm/tags","blobs_url":"https://api.github.com/repos/joedborg/docker-registry-charm/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/joedborg/docker-registry-charm/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/joedborg/docker-registry-charm/git/refs{/sha}","trees_url":"https://api.github.com/repos/joedborg/docker-registry-charm/git/trees{/sha}","statuses_url":"https://api.github.com/repos/joedborg/docker-registry-charm/statuses/{sha}","languages_url":"https://api.github.com/repos/joedborg/docker-registry-charm/languages","stargazers_url":"https://api.github.com/repos/joedborg/docker-registry-charm/stargazers","contributors_url":"https://api.github.com/repos/joedborg/docker-registry-charm/contributors","subscribers_url":"https://api.github.com/repos/joedborg/docker-registry-charm/subscribers","subscription_url":"https://api.github.com/repos/joedborg/docker-registry-charm/subscription","commits_url":"https://api.github.com/repos/joedborg/docker-registry-charm/commits{/sha}","git_commits_url":"https://api.github.com/repos/joedborg/docker-registry-charm/git/commits{/sha}","comments_url":"https://api.github.com/repos/joedborg/docker-registry-charm/comments{/number}","issue_comment_url":"https://api.github.com/repos/joedborg/docker-registry-charm/issues/comments{/number}","contents_url":"https://api.github.com/repos/joedborg/docker-registry-charm/contents/{+path}","compare_url":"https://api.github.com/repos/joedborg/docker-registry-charm/compare/{base}...{head}","merges_url":"https://api.github.com/repos/joedborg/docker-registry-charm/merges","archive_url":"https://api.github.com/repos/joedborg/docker-registry-charm/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/joedborg/docker-registry-charm/downloads","issues_url":"https://api.github.com/repos/joedborg/docker-registry-charm/issues{/number}","pulls_url":"https://api.github.com/repos/joedborg/docker-registry-charm/pulls{/number}","milestones_url":"https://api.github.com/repos/joedborg/docker-registry-charm/milestones{/number}","notifications_url":"https://api.github.com/repos/joedborg/docker-registry-charm/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/joedborg/docker-registry-charm/labels{/name}","releases_url":"https://api.github.com/repos/joedborg/docker-registry-charm/releases{/id}","deployments_url":"https://api.github.com/repos/joedborg/docker-registry-charm/deployments","created_at":"2018-12-13T21:20:26Z","updated_at":"2018-12-13T21:20:28Z","pushed_at":"2018-12-13T21:28:46Z","git_url":"git://github.com/joedborg/docker-registry-charm.git","ssh_url":"git@github.com:joedborg/docker-registry-charm.git","clone_url":"https://github.com/joedborg/docker-registry-charm.git","svn_url":"https://github.com/joedborg/docker-registry-charm","homepage":"https://launchpad.net/layer-docker-registry","size":85,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"CanonicalLtd:master","ref":"master","sha":"2d600f154fb39772befc9d9c10c583d2bf7546f8","user":{"login":"CanonicalLtd","id":7490288,"node_id":"MDEyOk9yZ2FuaXphdGlvbjc0OTAyODg=","avatar_url":"https://avatars0.githubusercontent.com/u/7490288?v=4","gravatar_id":"","url":"https://api.github.com/users/CanonicalLtd","html_url":"https://github.com/CanonicalLtd","followers_url":"https://api.github.com/users/CanonicalLtd/followers","following_url":"https://api.github.com/users/CanonicalLtd/following{/other_user}","gists_url":"https://api.github.com/users/CanonicalLtd/gists{/gist_id}","starred_url":"https://api.github.com/users/CanonicalLtd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CanonicalLtd/subscriptions","organizations_url":"https://api.github.com/users/CanonicalLtd/orgs","repos_url":"https://api.github.com/users/CanonicalLtd/repos","events_url":"https://api.github.com/users/CanonicalLtd/events{/privacy}","received_events_url":"https://api.github.com/users/CanonicalLtd/received_events","type":"Organization","site_admin":false},"repo":{"id":137222837,"node_id":"MDEwOlJlcG9zaXRvcnkxMzcyMjI4Mzc=","name":"docker-registry-charm","full_name":"CanonicalLtd/docker-registry-charm","private":false,"owner":{"login":"CanonicalLtd","id":7490288,"node_id":"MDEyOk9yZ2FuaXphdGlvbjc0OTAyODg=","avatar_url":"https://avatars0.githubusercontent.com/u/7490288?v=4","gravatar_id":"","url":"https://api.github.com/users/CanonicalLtd","html_url":"https://github.com/CanonicalLtd","followers_url":"https://api.github.com/users/CanonicalLtd/followers","following_url":"https://api.github.com/users/CanonicalLtd/following{/other_user}","gists_url":"https://api.github.com/users/CanonicalLtd/gists{/gist_id}","starred_url":"https://api.github.com/users/CanonicalLtd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CanonicalLtd/subscriptions","organizations_url":"https://api.github.com/users/CanonicalLtd/orgs","repos_url":"https://api.github.com/users/CanonicalLtd/repos","events_url":"https://api.github.com/users/CanonicalLtd/events{/privacy}","received_events_url":"https://api.github.com/users/CanonicalLtd/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/CanonicalLtd/docker-registry-charm","description":"PLEASE FILE ISSUES ON LAUNCHPAD","fork":false,"url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm","forks_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/forks","keys_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/teams","hooks_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/hooks","issue_events_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/issues/events{/number}","events_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/events","assignees_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/assignees{/user}","branches_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/branches{/branch}","tags_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/tags","blobs_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/git/refs{/sha}","trees_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/statuses/{sha}","languages_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/languages","stargazers_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/stargazers","contributors_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/contributors","subscribers_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/subscribers","subscription_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/subscription","commits_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/commits{/sha}","git_commits_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/git/commits{/sha}","comments_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/comments{/number}","issue_comment_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/issues/comments{/number}","contents_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/contents/{+path}","compare_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/merges","archive_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/downloads","issues_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/issues{/number}","pulls_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/pulls{/number}","milestones_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/milestones{/number}","notifications_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/labels{/name}","releases_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/releases{/id}","deployments_url":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/deployments","created_at":"2018-06-13T13:55:28Z","updated_at":"2018-11-30T17:59:12Z","pushed_at":"2018-12-13T21:28:47Z","git_url":"git://github.com/CanonicalLtd/docker-registry-charm.git","ssh_url":"git@github.com:CanonicalLtd/docker-registry-charm.git","clone_url":"https://github.com/CanonicalLtd/docker-registry-charm.git","svn_url":"https://github.com/CanonicalLtd/docker-registry-charm","homepage":"https://launchpad.net/layer-docker-registry","size":85,"stargazers_count":3,"watchers_count":3,"language":"Python","has_issues":false,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":2,"open_issues":1,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/pulls/20"},"html":{"href":"https://github.com/CanonicalLtd/docker-registry-charm/pull/20"},"issue":{"href":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/issues/20"},"comments":{"href":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/issues/20/comments"},"review_comments":{"href":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/pulls/20/comments"},"review_comment":{"href":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/pulls/20/commits"},"statuses":{"href":"https://api.github.com/repos/CanonicalLtd/docker-registry-charm/statuses/cd1b64cfa3a61c55ed0004842084b9619aeffb03"}},"author_association":"NONE"}}
{"actor":{"display_login":"johnsca"}}