{"action":"created","comment":{"url":"https://api.github.com/repos/brooklyncentral/clocker/pulls/comments/43905047","id":43905047,"diff_hunk":"@@ -0,0 +1,110 @@\n+package brooklyn.entity.container.docker.registry;\n+\n+\n+import static org.apache.brooklyn.util.ssh.BashCommands.chain;\n+\n+import java.net.URI;\n+import java.util.Arrays;\n+import java.util.List;\n+\n+import com.google.common.base.Functions;\n+import com.google.common.collect.ImmutableList;\n+import com.google.common.net.HostAndPort;\n+\n+import org.apache.brooklyn.core.entity.Attributes;\n+import org.apache.brooklyn.core.location.access.BrooklynAccessUtils;\n+import org.apache.brooklyn.entity.software.base.SoftwareProcess;\n+import org.apache.brooklyn.feed.http.HttpFeed;\n+import org.apache.brooklyn.feed.http.HttpPollConfig;\n+import org.apache.brooklyn.feed.http.HttpValueFunctions;\n+import org.apache.brooklyn.feed.http.JsonFunctions;\n+import org.apache.brooklyn.location.ssh.SshMachineLocation;\n+import org.apache.brooklyn.util.collections.MutableMap;\n+import org.apache.brooklyn.util.guava.Functionals;\n+import org.apache.brooklyn.util.os.Os;\n+import org.apache.brooklyn.util.ssh.BashCommands;\n+import org.apache.brooklyn.util.time.Duration;\n+\n+import brooklyn.entity.container.DockerAttributes;\n+import brooklyn.entity.container.docker.DockerHost;\n+import brooklyn.entity.container.docker.DockerInfrastructure;\n+import brooklyn.entity.container.docker.application.VanillaDockerApplicationImpl;\n+\n+public class DockerRegistryImpl extends VanillaDockerApplicationImpl implements DockerRegistry {\n+\n+    private volatile HttpFeed httpFeed;\n+    private final String CREATE_CERTS_SCRIPT_NAME = \"docker-registry-create-certs.sh\";\n+\n+    private String getSSHMachineInstallDir() {\n+        return config().get(DockerRegistry.DOCKER_HOST).sensors().get(SoftwareProcess.INSTALL_DIR);\n+    }\n+\n+    @Override\n+    public void connectSensors() {\n+        super.connectSensors();\n+        connectServiceUpIsRunning();\n+\n+        HostAndPort hostAndPort = BrooklynAccessUtils.getBrooklynAccessibleAddress(this, config().get(DockerRegistry.DOCKER_REGISTRY_PORT));\n+        sensors().set(Attributes.MAIN_URI, URI.create(\"https://\" + hostAndPort + \"/v2\"));\n+\n+\n+        httpFeed = HttpFeed.builder()\n+                .entity(this)\n+                .period(Duration.seconds(3))\n+                .baseUri(getAttribute(Attributes.MAIN_URI))\n+                .poll(new HttpPollConfig<Boolean>(Attributes.SERVICE_UP)\n+                        .onSuccess(Functions.constant(true))\n+                        .onFailureOrException(Functions.constant(false)))\n+                .poll(new HttpPollConfig<List<String>>(DOCKER_REGISTRY_CATALOG)\n+                        .suburl(\"/_catalog\")\n+                        .onSuccess(Functionals.chain(\n+                                HttpValueFunctions.jsonContents(),\n+                                JsonFunctions.walk(\"repositories\"),\n+                                JsonFunctions.forEach(JsonFunctions.cast(String.class))))\n+                        .onFailureOrException(Functions.constant(Arrays.asList(new String[0]))))","path":"docker/src/main/java/brooklyn/entity/container/docker/registry/DockerRegistryImpl.java","position":64,"original_position":64,"commit_id":"c619c12c37131835edbc4adfd7399a5186aae6b1","original_commit_id":"c619c12c37131835edbc4adfd7399a5186aae6b1","user":{"login":"grkvlt","id":214870,"avatar_url":"https://avatars.githubusercontent.com/u/214870?v=3","gravatar_id":"","url":"https://api.github.com/users/grkvlt","html_url":"https://github.com/grkvlt","followers_url":"https://api.github.com/users/grkvlt/followers","following_url":"https://api.github.com/users/grkvlt/following{/other_user}","gists_url":"https://api.github.com/users/grkvlt/gists{/gist_id}","starred_url":"https://api.github.com/users/grkvlt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grkvlt/subscriptions","organizations_url":"https://api.github.com/users/grkvlt/orgs","repos_url":"https://api.github.com/users/grkvlt/repos","events_url":"https://api.github.com/users/grkvlt/events{/privacy}","received_events_url":"https://api.github.com/users/grkvlt/received_events","type":"User","site_admin":false},"body":"Maybe `Lists.<String>newArrayList()` instead of creating the empty `String[0]` array?","created_at":"2015-11-04T16:44:56Z","updated_at":"2015-11-04T16:44:56Z","html_url":"https://github.com/brooklyncentral/clocker/pull/172#discussion_r43905047","pull_request_url":"https://api.github.com/repos/brooklyncentral/clocker/pulls/172","_links":{"self":{"href":"https://api.github.com/repos/brooklyncentral/clocker/pulls/comments/43905047"},"html":{"href":"https://github.com/brooklyncentral/clocker/pull/172#discussion_r43905047"},"pull_request":{"href":"https://api.github.com/repos/brooklyncentral/clocker/pulls/172"}}},"pull_request":{"url":"https://api.github.com/repos/brooklyncentral/clocker/pulls/172","id":47561348,"html_url":"https://github.com/brooklyncentral/clocker/pull/172","diff_url":"https://github.com/brooklyncentral/clocker/pull/172.diff","patch_url":"https://github.com/brooklyncentral/clocker/pull/172.patch","issue_url":"https://api.github.com/repos/brooklyncentral/clocker/issues/172","number":172,"state":"open","locked":false,"title":"WIP: Feature configurable regisrty","user":{"login":"Graeme-Miller","id":3742990,"avatar_url":"https://avatars.githubusercontent.com/u/3742990?v=3","gravatar_id":"","url":"https://api.github.com/users/Graeme-Miller","html_url":"https://github.com/Graeme-Miller","followers_url":"https://api.github.com/users/Graeme-Miller/followers","following_url":"https://api.github.com/users/Graeme-Miller/following{/other_user}","gists_url":"https://api.github.com/users/Graeme-Miller/gists{/gist_id}","starred_url":"https://api.github.com/users/Graeme-Miller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Graeme-Miller/subscriptions","organizations_url":"https://api.github.com/users/Graeme-Miller/orgs","repos_url":"https://api.github.com/users/Graeme-Miller/repos","events_url":"https://api.github.com/users/Graeme-Miller/events{/privacy}","received_events_url":"https://api.github.com/users/Graeme-Miller/received_events","type":"User","site_admin":false},"body":"Updated version of this [pull request](https://github.com/brooklyncentral/clocker/pull/168) with a slightly better branch name.","created_at":"2015-10-13T17:12:30Z","updated_at":"2015-11-04T16:44:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c8b08484bbe0a6aee984c70ac5761e500a126d64","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/brooklyncentral/clocker/pulls/172/commits","review_comments_url":"https://api.github.com/repos/brooklyncentral/clocker/pulls/172/comments","review_comment_url":"https://api.github.com/repos/brooklyncentral/clocker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/brooklyncentral/clocker/issues/172/comments","statuses_url":"https://api.github.com/repos/brooklyncentral/clocker/statuses/c619c12c37131835edbc4adfd7399a5186aae6b1","head":{"label":"Graeme-Miller:feature_configurable_repo","ref":"feature_configurable_repo","sha":"c619c12c37131835edbc4adfd7399a5186aae6b1","user":{"login":"Graeme-Miller","id":3742990,"avatar_url":"https://avatars.githubusercontent.com/u/3742990?v=3","gravatar_id":"","url":"https://api.github.com/users/Graeme-Miller","html_url":"https://github.com/Graeme-Miller","followers_url":"https://api.github.com/users/Graeme-Miller/followers","following_url":"https://api.github.com/users/Graeme-Miller/following{/other_user}","gists_url":"https://api.github.com/users/Graeme-Miller/gists{/gist_id}","starred_url":"https://api.github.com/users/Graeme-Miller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Graeme-Miller/subscriptions","organizations_url":"https://api.github.com/users/Graeme-Miller/orgs","repos_url":"https://api.github.com/users/Graeme-Miller/repos","events_url":"https://api.github.com/users/Graeme-Miller/events{/privacy}","received_events_url":"https://api.github.com/users/Graeme-Miller/received_events","type":"User","site_admin":false},"repo":{"id":42653882,"name":"clocker","full_name":"Graeme-Miller/clocker","owner":{"login":"Graeme-Miller","id":3742990,"avatar_url":"https://avatars.githubusercontent.com/u/3742990?v=3","gravatar_id":"","url":"https://api.github.com/users/Graeme-Miller","html_url":"https://github.com/Graeme-Miller","followers_url":"https://api.github.com/users/Graeme-Miller/followers","following_url":"https://api.github.com/users/Graeme-Miller/following{/other_user}","gists_url":"https://api.github.com/users/Graeme-Miller/gists{/gist_id}","starred_url":"https://api.github.com/users/Graeme-Miller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Graeme-Miller/subscriptions","organizations_url":"https://api.github.com/users/Graeme-Miller/orgs","repos_url":"https://api.github.com/users/Graeme-Miller/repos","events_url":"https://api.github.com/users/Graeme-Miller/events{/privacy}","received_events_url":"https://api.github.com/users/Graeme-Miller/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Graeme-Miller/clocker","description":"Brooklyn managed Docker containers","fork":true,"url":"https://api.github.com/repos/Graeme-Miller/clocker","forks_url":"https://api.github.com/repos/Graeme-Miller/clocker/forks","keys_url":"https://api.github.com/repos/Graeme-Miller/clocker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Graeme-Miller/clocker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Graeme-Miller/clocker/teams","hooks_url":"https://api.github.com/repos/Graeme-Miller/clocker/hooks","issue_events_url":"https://api.github.com/repos/Graeme-Miller/clocker/issues/events{/number}","events_url":"https://api.github.com/repos/Graeme-Miller/clocker/events","assignees_url":"https://api.github.com/repos/Graeme-Miller/clocker/assignees{/user}","branches_url":"https://api.github.com/repos/Graeme-Miller/clocker/branches{/branch}","tags_url":"https://api.github.com/repos/Graeme-Miller/clocker/tags","blobs_url":"https://api.github.com/repos/Graeme-Miller/clocker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Graeme-Miller/clocker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Graeme-Miller/clocker/git/refs{/sha}","trees_url":"https://api.github.com/repos/Graeme-Miller/clocker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Graeme-Miller/clocker/statuses/{sha}","languages_url":"https://api.github.com/repos/Graeme-Miller/clocker/languages","stargazers_url":"https://api.github.com/repos/Graeme-Miller/clocker/stargazers","contributors_url":"https://api.github.com/repos/Graeme-Miller/clocker/contributors","subscribers_url":"https://api.github.com/repos/Graeme-Miller/clocker/subscribers","subscription_url":"https://api.github.com/repos/Graeme-Miller/clocker/subscription","commits_url":"https://api.github.com/repos/Graeme-Miller/clocker/commits{/sha}","git_commits_url":"https://api.github.com/repos/Graeme-Miller/clocker/git/commits{/sha}","comments_url":"https://api.github.com/repos/Graeme-Miller/clocker/comments{/number}","issue_comment_url":"https://api.github.com/repos/Graeme-Miller/clocker/issues/comments{/number}","contents_url":"https://api.github.com/repos/Graeme-Miller/clocker/contents/{+path}","compare_url":"https://api.github.com/repos/Graeme-Miller/clocker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Graeme-Miller/clocker/merges","archive_url":"https://api.github.com/repos/Graeme-Miller/clocker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Graeme-Miller/clocker/downloads","issues_url":"https://api.github.com/repos/Graeme-Miller/clocker/issues{/number}","pulls_url":"https://api.github.com/repos/Graeme-Miller/clocker/pulls{/number}","milestones_url":"https://api.github.com/repos/Graeme-Miller/clocker/milestones{/number}","notifications_url":"https://api.github.com/repos/Graeme-Miller/clocker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Graeme-Miller/clocker/labels{/name}","releases_url":"https://api.github.com/repos/Graeme-Miller/clocker/releases{/id}","created_at":"2015-09-17T12:04:43Z","updated_at":"2015-09-17T12:04:44Z","pushed_at":"2015-10-29T16:55:04Z","git_url":"git://github.com/Graeme-Miller/clocker.git","ssh_url":"git@github.com:Graeme-Miller/clocker.git","clone_url":"https://github.com/Graeme-Miller/clocker.git","svn_url":"https://github.com/Graeme-Miller/clocker","homepage":null,"size":4288,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"brooklyncentral:master","ref":"master","sha":"5707675e1252d3f3c15c4b1cff9e25870c994973","user":{"login":"brooklyncentral","id":1587357,"avatar_url":"https://avatars.githubusercontent.com/u/1587357?v=3","gravatar_id":"","url":"https://api.github.com/users/brooklyncentral","html_url":"https://github.com/brooklyncentral","followers_url":"https://api.github.com/users/brooklyncentral/followers","following_url":"https://api.github.com/users/brooklyncentral/following{/other_user}","gists_url":"https://api.github.com/users/brooklyncentral/gists{/gist_id}","starred_url":"https://api.github.com/users/brooklyncentral/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brooklyncentral/subscriptions","organizations_url":"https://api.github.com/users/brooklyncentral/orgs","repos_url":"https://api.github.com/users/brooklyncentral/repos","events_url":"https://api.github.com/users/brooklyncentral/events{/privacy}","received_events_url":"https://api.github.com/users/brooklyncentral/received_events","type":"Organization","site_admin":false},"repo":{"id":17784299,"name":"clocker","full_name":"brooklyncentral/clocker","owner":{"login":"brooklyncentral","id":1587357,"avatar_url":"https://avatars.githubusercontent.com/u/1587357?v=3","gravatar_id":"","url":"https://api.github.com/users/brooklyncentral","html_url":"https://github.com/brooklyncentral","followers_url":"https://api.github.com/users/brooklyncentral/followers","following_url":"https://api.github.com/users/brooklyncentral/following{/other_user}","gists_url":"https://api.github.com/users/brooklyncentral/gists{/gist_id}","starred_url":"https://api.github.com/users/brooklyncentral/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brooklyncentral/subscriptions","organizations_url":"https://api.github.com/users/brooklyncentral/orgs","repos_url":"https://api.github.com/users/brooklyncentral/repos","events_url":"https://api.github.com/users/brooklyncentral/events{/privacy}","received_events_url":"https://api.github.com/users/brooklyncentral/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/brooklyncentral/clocker","description":"Brooklyn managed Docker containers","fork":false,"url":"https://api.github.com/repos/brooklyncentral/clocker","forks_url":"https://api.github.com/repos/brooklyncentral/clocker/forks","keys_url":"https://api.github.com/repos/brooklyncentral/clocker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/brooklyncentral/clocker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/brooklyncentral/clocker/teams","hooks_url":"https://api.github.com/repos/brooklyncentral/clocker/hooks","issue_events_url":"https://api.github.com/repos/brooklyncentral/clocker/issues/events{/number}","events_url":"https://api.github.com/repos/brooklyncentral/clocker/events","assignees_url":"https://api.github.com/repos/brooklyncentral/clocker/assignees{/user}","branches_url":"https://api.github.com/repos/brooklyncentral/clocker/branches{/branch}","tags_url":"https://api.github.com/repos/brooklyncentral/clocker/tags","blobs_url":"https://api.github.com/repos/brooklyncentral/clocker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/brooklyncentral/clocker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/brooklyncentral/clocker/git/refs{/sha}","trees_url":"https://api.github.com/repos/brooklyncentral/clocker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/brooklyncentral/clocker/statuses/{sha}","languages_url":"https://api.github.com/repos/brooklyncentral/clocker/languages","stargazers_url":"https://api.github.com/repos/brooklyncentral/clocker/stargazers","contributors_url":"https://api.github.com/repos/brooklyncentral/clocker/contributors","subscribers_url":"https://api.github.com/repos/brooklyncentral/clocker/subscribers","subscription_url":"https://api.github.com/repos/brooklyncentral/clocker/subscription","commits_url":"https://api.github.com/repos/brooklyncentral/clocker/commits{/sha}","git_commits_url":"https://api.github.com/repos/brooklyncentral/clocker/git/commits{/sha}","comments_url":"https://api.github.com/repos/brooklyncentral/clocker/comments{/number}","issue_comment_url":"https://api.github.com/repos/brooklyncentral/clocker/issues/comments{/number}","contents_url":"https://api.github.com/repos/brooklyncentral/clocker/contents/{+path}","compare_url":"https://api.github.com/repos/brooklyncentral/clocker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/brooklyncentral/clocker/merges","archive_url":"https://api.github.com/repos/brooklyncentral/clocker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/brooklyncentral/clocker/downloads","issues_url":"https://api.github.com/repos/brooklyncentral/clocker/issues{/number}","pulls_url":"https://api.github.com/repos/brooklyncentral/clocker/pulls{/number}","milestones_url":"https://api.github.com/repos/brooklyncentral/clocker/milestones{/number}","notifications_url":"https://api.github.com/repos/brooklyncentral/clocker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/brooklyncentral/clocker/labels{/name}","releases_url":"https://api.github.com/repos/brooklyncentral/clocker/releases{/id}","created_at":"2014-03-15T20:03:57Z","updated_at":"2015-10-31T07:57:32Z","pushed_at":"2015-11-04T16:02:16Z","git_url":"git://github.com/brooklyncentral/clocker.git","ssh_url":"git@github.com:brooklyncentral/clocker.git","clone_url":"https://github.com/brooklyncentral/clocker.git","svn_url":"https://github.com/brooklyncentral/clocker","homepage":null,"size":9713,"stargazers_count":359,"watchers_count":359,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":49,"mirror_url":null,"open_issues_count":38,"forks":49,"open_issues":38,"watchers":359,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/brooklyncentral/clocker/pulls/172"},"html":{"href":"https://github.com/brooklyncentral/clocker/pull/172"},"issue":{"href":"https://api.github.com/repos/brooklyncentral/clocker/issues/172"},"comments":{"href":"https://api.github.com/repos/brooklyncentral/clocker/issues/172/comments"},"review_comments":{"href":"https://api.github.com/repos/brooklyncentral/clocker/pulls/172/comments"},"review_comment":{"href":"https://api.github.com/repos/brooklyncentral/clocker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/brooklyncentral/clocker/pulls/172/commits"},"statuses":{"href":"https://api.github.com/repos/brooklyncentral/clocker/statuses/c619c12c37131835edbc4adfd7399a5186aae6b1"}}}}