{"action":"created","comment":{"url":"https://api.github.com/repos/dcos/cosmos/pulls/comments/211792500","pull_request_review_id":148282000,"id":211792500,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxMTc5MjUwMA==","diff_hunk":"@@ -10,60 +10,85 @@ import com.mesosphere.cosmos.render.PackageDefinitionRenderer\n import com.mesosphere.cosmos.repository.PackageCollection\n import com.mesosphere.cosmos.repository.rewriteUrlWithProxyInfo\n import com.mesosphere.cosmos.rpc\n+import com.mesosphere.cosmos.service.CustomPackageManagerRouter\n import com.mesosphere.universe\n import com.mesosphere.universe.bijection.UniverseConversions._\n import com.twitter.bijection.Conversion.asMethod\n import com.twitter.util.Future\n+import org.slf4j.Logger\n+\n \n private[cosmos] final class PackageInstallHandler(\n   packageCollection: PackageCollection,\n-  packageRunner: MarathonPackageRunner\n+  packageRunner: MarathonPackageRunner,\n+  customPackageManagerRouter: CustomPackageManagerRouter\n ) extends EndpointHandler[rpc.v1.model.InstallRequest, rpc.v2.model.InstallResponse] {\n-\n+  lazy val logger: Logger = org.slf4j.LoggerFactory.getLogger(getClass)\n   override def apply(\n     request: rpc.v1.model.InstallRequest\n   )(\n     implicit session: RequestSession\n   ): Future[rpc.v2.model.InstallResponse] = {\n-    packageCollection\n-      .getPackageByPackageVersion(\n-        request.packageName,\n-        request.packageVersion.as[Option[universe.v3.model.Version]]\n-      )\n-      .flatMap { case (pkg, sourceUri) =>\n-        PackageDefinitionRenderer.renderMarathonV2App(\n-          sourceUri,\n-          pkg,\n-          request.options,\n-          request.appId\n-        ) match {\n-          case Some(renderedMarathonJson) =>\n-            packageRunner.launch(renderedMarathonJson)\n-              .map { runnerResponse =>\n-                rpc.v2.model.InstallResponse(\n-                  packageName = pkg.name,\n-                  packageVersion = pkg.version,\n-                  appId = Some(runnerResponse.id),\n-                  postInstallNotes = pkg.postInstallNotes,\n-                  cli = pkg.rewrite(rewriteUrlWithProxyInfo(session.originInfo), identity).cli\n-                )\n-              }\n-              .handle {\n-                case CosmosException(ServiceAlreadyStarted(_), _, _) =>\n-                  throw PackageAlreadyInstalled().exception\n-              }\n-          case None =>\n-            Future {\n-              rpc.v2.model.InstallResponse(\n-                packageName = pkg.name,\n-                packageVersion = pkg.version,\n-                appId = None,\n-                postInstallNotes = pkg.postInstallNotes,\n-                cli = pkg.rewrite(rewriteUrlWithProxyInfo(session.originInfo), identity).cli\n-              )\n-            }\n+    customPackageManagerRouter.getCustomPackageManagerId(\n+      request.managerId,\n+      Option(request.packageName),\n+      request.packageVersion.as[Option[universe.v3.model.Version]],\n+      None\n+    ).flatMap {\n+      case managerId if !managerId.get.isEmpty => {","path":"cosmos-server/src/main/scala/com/mesosphere/cosmos/handler/PackageInstallHandler.scala","position":68,"original_position":68,"commit_id":"a936dd43bad6f5c2d54c6e45849057f56a9ee89f","original_commit_id":"a936dd43bad6f5c2d54c6e45849057f56a9ee89f","user":{"login":"takirala","id":2296947,"node_id":"MDQ6VXNlcjIyOTY5NDc=","avatar_url":"https://avatars2.githubusercontent.com/u/2296947?v=4","gravatar_id":"","url":"https://api.github.com/users/takirala","html_url":"https://github.com/takirala","followers_url":"https://api.github.com/users/takirala/followers","following_url":"https://api.github.com/users/takirala/following{/other_user}","gists_url":"https://api.github.com/users/takirala/gists{/gist_id}","starred_url":"https://api.github.com/users/takirala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/takirala/subscriptions","organizations_url":"https://api.github.com/users/takirala/orgs","repos_url":"https://api.github.com/users/takirala/repos","events_url":"https://api.github.com/users/takirala/events{/privacy}","received_events_url":"https://api.github.com/users/takirala/received_events","type":"User","site_admin":false},"body":"Instead, do:\r\n```\r\nmanagerId match {\r\n  case Some(_) if ... => ....\r\n  case Some(_) .. =>\r\n  case None =>\r\n```","created_at":"2018-08-21T23:40:15Z","updated_at":"2018-08-21T23:46:55Z","html_url":"https://github.com/dcos/cosmos/pull/739#discussion_r211792500","pull_request_url":"https://api.github.com/repos/dcos/cosmos/pulls/739","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/dcos/cosmos/pulls/comments/211792500"},"html":{"href":"https://github.com/dcos/cosmos/pull/739#discussion_r211792500"},"pull_request":{"href":"https://api.github.com/repos/dcos/cosmos/pulls/739"}}},"pull_request":{"url":"https://api.github.com/repos/dcos/cosmos/pulls/739","id":207470500,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA3NDcwNTAw","html_url":"https://github.com/dcos/cosmos/pull/739","diff_url":"https://github.com/dcos/cosmos/pull/739.diff","patch_url":"https://github.com/dcos/cosmos/pull/739.patch","issue_url":"https://api.github.com/repos/dcos/cosmos/issues/739","number":739,"state":"open","locked":false,"title":"[DCOS-39579] Forward requests to custom package managers when required","user":{"login":"kvish","id":3020510,"node_id":"MDQ6VXNlcjMwMjA1MTA=","avatar_url":"https://avatars2.githubusercontent.com/u/3020510?v=4","gravatar_id":"","url":"https://api.github.com/users/kvish","html_url":"https://github.com/kvish","followers_url":"https://api.github.com/users/kvish/followers","following_url":"https://api.github.com/users/kvish/following{/other_user}","gists_url":"https://api.github.com/users/kvish/gists{/gist_id}","starred_url":"https://api.github.com/users/kvish/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kvish/subscriptions","organizations_url":"https://api.github.com/users/kvish/orgs","repos_url":"https://api.github.com/users/kvish/repos","events_url":"https://api.github.com/users/kvish/events{/privacy}","received_events_url":"https://api.github.com/users/kvish/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-08-09T23:27:23Z","updated_at":"2018-08-21T23:46:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6b9b1465c7677c136118a6a9897ea178f1660e32","assignee":null,"assignees":[],"requested_reviewers":[{"login":"jeid64","id":1271427,"node_id":"MDQ6VXNlcjEyNzE0Mjc=","avatar_url":"https://avatars1.githubusercontent.com/u/1271427?v=4","gravatar_id":"","url":"https://api.github.com/users/jeid64","html_url":"https://github.com/jeid64","followers_url":"https://api.github.com/users/jeid64/followers","following_url":"https://api.github.com/users/jeid64/following{/other_user}","gists_url":"https://api.github.com/users/jeid64/gists{/gist_id}","starred_url":"https://api.github.com/users/jeid64/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeid64/subscriptions","organizations_url":"https://api.github.com/users/jeid64/orgs","repos_url":"https://api.github.com/users/jeid64/repos","events_url":"https://api.github.com/users/jeid64/events{/privacy}","received_events_url":"https://api.github.com/users/jeid64/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/dcos/cosmos/pulls/739/commits","review_comments_url":"https://api.github.com/repos/dcos/cosmos/pulls/739/comments","review_comment_url":"https://api.github.com/repos/dcos/cosmos/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dcos/cosmos/issues/739/comments","statuses_url":"https://api.github.com/repos/dcos/cosmos/statuses/a936dd43bad6f5c2d54c6e45849057f56a9ee89f","head":{"label":"dcos:kvish-custom-managers","ref":"kvish-custom-managers","sha":"a936dd43bad6f5c2d54c6e45849057f56a9ee89f","user":{"login":"dcos","id":17648048,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE3NjQ4MDQ4","avatar_url":"https://avatars1.githubusercontent.com/u/17648048?v=4","gravatar_id":"","url":"https://api.github.com/users/dcos","html_url":"https://github.com/dcos","followers_url":"https://api.github.com/users/dcos/followers","following_url":"https://api.github.com/users/dcos/following{/other_user}","gists_url":"https://api.github.com/users/dcos/gists{/gist_id}","starred_url":"https://api.github.com/users/dcos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcos/subscriptions","organizations_url":"https://api.github.com/users/dcos/orgs","repos_url":"https://api.github.com/users/dcos/repos","events_url":"https://api.github.com/users/dcos/events{/privacy}","received_events_url":"https://api.github.com/users/dcos/received_events","type":"Organization","site_admin":false},"repo":{"id":47585661,"node_id":"MDEwOlJlcG9zaXRvcnk0NzU4NTY2MQ==","name":"cosmos","full_name":"dcos/cosmos","owner":{"login":"dcos","id":17648048,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE3NjQ4MDQ4","avatar_url":"https://avatars1.githubusercontent.com/u/17648048?v=4","gravatar_id":"","url":"https://api.github.com/users/dcos","html_url":"https://github.com/dcos","followers_url":"https://api.github.com/users/dcos/followers","following_url":"https://api.github.com/users/dcos/following{/other_user}","gists_url":"https://api.github.com/users/dcos/gists{/gist_id}","starred_url":"https://api.github.com/users/dcos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcos/subscriptions","organizations_url":"https://api.github.com/users/dcos/orgs","repos_url":"https://api.github.com/users/dcos/repos","events_url":"https://api.github.com/users/dcos/events{/privacy}","received_events_url":"https://api.github.com/users/dcos/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dcos/cosmos","description":"Provides an API for the orderly, harmonious, and complete management of DC/OS service packages","fork":false,"url":"https://api.github.com/repos/dcos/cosmos","forks_url":"https://api.github.com/repos/dcos/cosmos/forks","keys_url":"https://api.github.com/repos/dcos/cosmos/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dcos/cosmos/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dcos/cosmos/teams","hooks_url":"https://api.github.com/repos/dcos/cosmos/hooks","issue_events_url":"https://api.github.com/repos/dcos/cosmos/issues/events{/number}","events_url":"https://api.github.com/repos/dcos/cosmos/events","assignees_url":"https://api.github.com/repos/dcos/cosmos/assignees{/user}","branches_url":"https://api.github.com/repos/dcos/cosmos/branches{/branch}","tags_url":"https://api.github.com/repos/dcos/cosmos/tags","blobs_url":"https://api.github.com/repos/dcos/cosmos/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dcos/cosmos/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dcos/cosmos/git/refs{/sha}","trees_url":"https://api.github.com/repos/dcos/cosmos/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dcos/cosmos/statuses/{sha}","languages_url":"https://api.github.com/repos/dcos/cosmos/languages","stargazers_url":"https://api.github.com/repos/dcos/cosmos/stargazers","contributors_url":"https://api.github.com/repos/dcos/cosmos/contributors","subscribers_url":"https://api.github.com/repos/dcos/cosmos/subscribers","subscription_url":"https://api.github.com/repos/dcos/cosmos/subscription","commits_url":"https://api.github.com/repos/dcos/cosmos/commits{/sha}","git_commits_url":"https://api.github.com/repos/dcos/cosmos/git/commits{/sha}","comments_url":"https://api.github.com/repos/dcos/cosmos/comments{/number}","issue_comment_url":"https://api.github.com/repos/dcos/cosmos/issues/comments{/number}","contents_url":"https://api.github.com/repos/dcos/cosmos/contents/{+path}","compare_url":"https://api.github.com/repos/dcos/cosmos/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dcos/cosmos/merges","archive_url":"https://api.github.com/repos/dcos/cosmos/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dcos/cosmos/downloads","issues_url":"https://api.github.com/repos/dcos/cosmos/issues{/number}","pulls_url":"https://api.github.com/repos/dcos/cosmos/pulls{/number}","milestones_url":"https://api.github.com/repos/dcos/cosmos/milestones{/number}","notifications_url":"https://api.github.com/repos/dcos/cosmos/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dcos/cosmos/labels{/name}","releases_url":"https://api.github.com/repos/dcos/cosmos/releases{/id}","deployments_url":"https://api.github.com/repos/dcos/cosmos/deployments","created_at":"2015-12-07T23:23:49Z","updated_at":"2018-08-15T18:05:25Z","pushed_at":"2018-08-21T22:15:45Z","git_url":"git://github.com/dcos/cosmos.git","ssh_url":"git@github.com:dcos/cosmos.git","clone_url":"https://github.com/dcos/cosmos.git","svn_url":"https://github.com/dcos/cosmos","homepage":"","size":2398,"stargazers_count":58,"watchers_count":58,"language":"Scala","has_issues":false,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":23,"mirror_url":null,"archived":false,"open_issues_count":3,"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":23,"open_issues":3,"watchers":58,"default_branch":"master"}},"base":{"label":"dcos:master","ref":"master","sha":"2b45980100866ac2e341374724ae8d1744c5b364","user":{"login":"dcos","id":17648048,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE3NjQ4MDQ4","avatar_url":"https://avatars1.githubusercontent.com/u/17648048?v=4","gravatar_id":"","url":"https://api.github.com/users/dcos","html_url":"https://github.com/dcos","followers_url":"https://api.github.com/users/dcos/followers","following_url":"https://api.github.com/users/dcos/following{/other_user}","gists_url":"https://api.github.com/users/dcos/gists{/gist_id}","starred_url":"https://api.github.com/users/dcos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcos/subscriptions","organizations_url":"https://api.github.com/users/dcos/orgs","repos_url":"https://api.github.com/users/dcos/repos","events_url":"https://api.github.com/users/dcos/events{/privacy}","received_events_url":"https://api.github.com/users/dcos/received_events","type":"Organization","site_admin":false},"repo":{"id":47585661,"node_id":"MDEwOlJlcG9zaXRvcnk0NzU4NTY2MQ==","name":"cosmos","full_name":"dcos/cosmos","owner":{"login":"dcos","id":17648048,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE3NjQ4MDQ4","avatar_url":"https://avatars1.githubusercontent.com/u/17648048?v=4","gravatar_id":"","url":"https://api.github.com/users/dcos","html_url":"https://github.com/dcos","followers_url":"https://api.github.com/users/dcos/followers","following_url":"https://api.github.com/users/dcos/following{/other_user}","gists_url":"https://api.github.com/users/dcos/gists{/gist_id}","starred_url":"https://api.github.com/users/dcos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcos/subscriptions","organizations_url":"https://api.github.com/users/dcos/orgs","repos_url":"https://api.github.com/users/dcos/repos","events_url":"https://api.github.com/users/dcos/events{/privacy}","received_events_url":"https://api.github.com/users/dcos/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dcos/cosmos","description":"Provides an API for the orderly, harmonious, and complete management of DC/OS service packages","fork":false,"url":"https://api.github.com/repos/dcos/cosmos","forks_url":"https://api.github.com/repos/dcos/cosmos/forks","keys_url":"https://api.github.com/repos/dcos/cosmos/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dcos/cosmos/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dcos/cosmos/teams","hooks_url":"https://api.github.com/repos/dcos/cosmos/hooks","issue_events_url":"https://api.github.com/repos/dcos/cosmos/issues/events{/number}","events_url":"https://api.github.com/repos/dcos/cosmos/events","assignees_url":"https://api.github.com/repos/dcos/cosmos/assignees{/user}","branches_url":"https://api.github.com/repos/dcos/cosmos/branches{/branch}","tags_url":"https://api.github.com/repos/dcos/cosmos/tags","blobs_url":"https://api.github.com/repos/dcos/cosmos/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dcos/cosmos/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dcos/cosmos/git/refs{/sha}","trees_url":"https://api.github.com/repos/dcos/cosmos/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dcos/cosmos/statuses/{sha}","languages_url":"https://api.github.com/repos/dcos/cosmos/languages","stargazers_url":"https://api.github.com/repos/dcos/cosmos/stargazers","contributors_url":"https://api.github.com/repos/dcos/cosmos/contributors","subscribers_url":"https://api.github.com/repos/dcos/cosmos/subscribers","subscription_url":"https://api.github.com/repos/dcos/cosmos/subscription","commits_url":"https://api.github.com/repos/dcos/cosmos/commits{/sha}","git_commits_url":"https://api.github.com/repos/dcos/cosmos/git/commits{/sha}","comments_url":"https://api.github.com/repos/dcos/cosmos/comments{/number}","issue_comment_url":"https://api.github.com/repos/dcos/cosmos/issues/comments{/number}","contents_url":"https://api.github.com/repos/dcos/cosmos/contents/{+path}","compare_url":"https://api.github.com/repos/dcos/cosmos/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dcos/cosmos/merges","archive_url":"https://api.github.com/repos/dcos/cosmos/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dcos/cosmos/downloads","issues_url":"https://api.github.com/repos/dcos/cosmos/issues{/number}","pulls_url":"https://api.github.com/repos/dcos/cosmos/pulls{/number}","milestones_url":"https://api.github.com/repos/dcos/cosmos/milestones{/number}","notifications_url":"https://api.github.com/repos/dcos/cosmos/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dcos/cosmos/labels{/name}","releases_url":"https://api.github.com/repos/dcos/cosmos/releases{/id}","deployments_url":"https://api.github.com/repos/dcos/cosmos/deployments","created_at":"2015-12-07T23:23:49Z","updated_at":"2018-08-15T18:05:25Z","pushed_at":"2018-08-21T22:15:45Z","git_url":"git://github.com/dcos/cosmos.git","ssh_url":"git@github.com:dcos/cosmos.git","clone_url":"https://github.com/dcos/cosmos.git","svn_url":"https://github.com/dcos/cosmos","homepage":"","size":2398,"stargazers_count":58,"watchers_count":58,"language":"Scala","has_issues":false,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":23,"mirror_url":null,"archived":false,"open_issues_count":3,"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":23,"open_issues":3,"watchers":58,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dcos/cosmos/pulls/739"},"html":{"href":"https://github.com/dcos/cosmos/pull/739"},"issue":{"href":"https://api.github.com/repos/dcos/cosmos/issues/739"},"comments":{"href":"https://api.github.com/repos/dcos/cosmos/issues/739/comments"},"review_comments":{"href":"https://api.github.com/repos/dcos/cosmos/pulls/739/comments"},"review_comment":{"href":"https://api.github.com/repos/dcos/cosmos/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dcos/cosmos/pulls/739/commits"},"statuses":{"href":"https://api.github.com/repos/dcos/cosmos/statuses/a936dd43bad6f5c2d54c6e45849057f56a9ee89f"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"takirala"}}