{"action":"created","comment":{"url":"https://api.github.com/repos/allenai/sbt-plugins/pulls/comments/53097548","id":53097548,"diff_hunk":"@@ -420,51 +449,95 @@ object DeployPlugin extends AutoPlugin {\n     overrides.withFallback(rcConfig.withFallback(targetConfig)).resolve\n   }\n \n-  /** Translates the given deploy Config object into a flat Map[String, String]\n-    * containing all the relevant deployment keys.\n-    *\n-    * Exits the program if any of the keys required for deployment are missing.\n-    *\n-    * @param targetName the name of the target to print on error\n-    * @param targetConfig the config to parse\n+  /** Check that all environment variables required for deployment are set,\n+    * and exit the program if any are missing.\n     */\n-  def validateAsMap(targetName: String, targetConfig: Config): Map[String, String] = {\n-    // Validate that the target has all the required environment variables.\n+  def validateEnv(): Unit = {\n     val requiredEnv = Seq(\"AWS_PEM_FILE\")\n-    for (variable <- requiredEnv) {\n-      val value = sys.env.get(variable).getOrElse {\n-        throw new IllegalArgumentException(s\"Environment variable ${variable} undefined.\")\n-      }\n+    requiredEnv foreach { variable =>\n+      val value = sys.env.getOrElse(variable, {\n+        throw new IllegalArgumentException(s\"Environment variable '$variable' undefined.\")\n+      })\n \n-      require(!value.isEmpty, \"Environment variable ${value} is empty.\")\n+      require(!value.isEmpty, s\"Environment variable '$variable' is empty.\")\n     }\n+  }\n+\n+  /** Container for config needed to deploy a project to a host.\n+    * @param host The fully-qualified name of the host the project should be deployed to\n+    * @param directory The directory on the host in which the project's code should be placed\n+    * @param sshUser The username to use when accessing the host\n+    * @param startupScript The path, relative to the deploy directory, to the script that should\n+    *                      be used to restart the project after deploying the new code\n+    * @param startupArgs Optional arguments to pass to the startup script\n+    */\n+  case class HostConfig(\n+    host: String,\n+    directory: String,\n+    sshUser: String,\n+    startupScript: String,\n+    startupArgs: Option[Seq[String]]\n+  )\n+\n+  /** Wrapper for many [[org.allenai.plugins.DeployPlugin.HostConfig]] objects, along with any data\n+    * that should be shared between them, when deploying a project.\n+    * @param hostConfigs configuration objects specifying how the project should be deployed to\n+    *                    many hosts\n+    * @param projectVersion the version of the project being deployed\n+    */\n+  case class DeployConfig(hostConfigs: Seq[HostConfig], projectVersion: Option[String])\n+\n+  /** Transform the given [[com.typesafe.config.Config]] object into a corresponding\n+    * [[org.allenai.plugins.DeployPlugin.DeployConfig]] object.\n+    * @param targetName the name of the target to print on error\n+    * @param targetConfig env-level deployment config to convert\n+    */\n+  def parseConfig(targetName: String, targetConfig: Config): DeployConfig = {\n \n-    // Validate that the target has all the required keys.\n-    val requiredKeys = Seq(\"deploy.host\", \"deploy.directory\",\n-      \"deploy.startup_script\", \"deploy.user.ssh_username\")\n-    val requiredKeyPairs: Seq[(String, String)] = for {\n-      key <- requiredKeys\n-    } yield key -> {\n-      try {\n-        targetConfig.getString(key)\n+    DeployConfig(\n+      hostConfigs = Seq(parseHostConfig(targetConfig.getConfig(\"deploy\"))),\n+      projectVersion = Try(targetConfig.getString(\"project.version\")).toOption","path":"src/main/scala/org/allenai/plugins/DeployPlugin.scala","position":283,"original_position":283,"commit_id":"e0d0a04256b2640bee79d6f9177a7965b70dac5a","original_commit_id":"e0d0a04256b2640bee79d6f9177a7965b70dac5a","user":{"login":"danxmoran","id":2755881,"avatar_url":"https://avatars.githubusercontent.com/u/2755881?v=3","gravatar_id":"","url":"https://api.github.com/users/danxmoran","html_url":"https://github.com/danxmoran","followers_url":"https://api.github.com/users/danxmoran/followers","following_url":"https://api.github.com/users/danxmoran/following{/other_user}","gists_url":"https://api.github.com/users/danxmoran/gists{/gist_id}","starred_url":"https://api.github.com/users/danxmoran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danxmoran/subscriptions","organizations_url":"https://api.github.com/users/danxmoran/orgs","repos_url":"https://api.github.com/users/danxmoran/repos","events_url":"https://api.github.com/users/danxmoran/events{/privacy}","received_events_url":"https://api.github.com/users/danxmoran/received_events","type":"User","site_admin":false},"body":"That said, I probably want to modify this to be more granular and let any `ConfigException.WrongType` errors bubble through","created_at":"2016-02-16T23:25:10Z","updated_at":"2016-02-16T23:25:10Z","html_url":"https://github.com/allenai/sbt-plugins/pull/209#discussion_r53097548","pull_request_url":"https://api.github.com/repos/allenai/sbt-plugins/pulls/209","_links":{"self":{"href":"https://api.github.com/repos/allenai/sbt-plugins/pulls/comments/53097548"},"html":{"href":"https://github.com/allenai/sbt-plugins/pull/209#discussion_r53097548"},"pull_request":{"href":"https://api.github.com/repos/allenai/sbt-plugins/pulls/209"}}},"pull_request":{"url":"https://api.github.com/repos/allenai/sbt-plugins/pulls/209","id":59556337,"html_url":"https://github.com/allenai/sbt-plugins/pull/209","diff_url":"https://github.com/allenai/sbt-plugins/pull/209.diff","patch_url":"https://github.com/allenai/sbt-plugins/pull/209.patch","issue_url":"https://api.github.com/repos/allenai/sbt-plugins/issues/209","number":209,"state":"open","locked":false,"title":"Pass optional args to restart script on deploy, refactor in prep for deploying to many hosts.","user":{"login":"danxmoran","id":2755881,"avatar_url":"https://avatars.githubusercontent.com/u/2755881?v=3","gravatar_id":"","url":"https://api.github.com/users/danxmoran","html_url":"https://github.com/danxmoran","followers_url":"https://api.github.com/users/danxmoran/followers","following_url":"https://api.github.com/users/danxmoran/following{/other_user}","gists_url":"https://api.github.com/users/danxmoran/gists{/gist_id}","starred_url":"https://api.github.com/users/danxmoran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danxmoran/subscriptions","organizations_url":"https://api.github.com/users/danxmoran/orgs","repos_url":"https://api.github.com/users/danxmoran/repos","events_url":"https://api.github.com/users/danxmoran/events{/privacy}","received_events_url":"https://api.github.com/users/danxmoran/received_events","type":"User","site_admin":false},"body":"A few things here:\r\n\r\n- Separate validation of environment variables from validation of configuration\r\n- Create dedicated `case class` wrappers for deploy config\r\n- Lay the groundwork for deploying to multiple hosts in parallel\r\n- Add support for a new config key, `deploy.startup_args`.  If this config entry is set to an array of strings, the contents will be passed as arguments to the call to `deploy.startup_script`, making use of #208 \r\n- Resolve a bunch of IntelliJ style warnings","created_at":"2016-02-16T21:22:59Z","updated_at":"2016-02-16T23:25:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"86e2f13f96560bef18c412649beca96bfbd0a5d2","assignee":{"login":"jkinkead","id":1548392,"avatar_url":"https://avatars.githubusercontent.com/u/1548392?v=3","gravatar_id":"","url":"https://api.github.com/users/jkinkead","html_url":"https://github.com/jkinkead","followers_url":"https://api.github.com/users/jkinkead/followers","following_url":"https://api.github.com/users/jkinkead/following{/other_user}","gists_url":"https://api.github.com/users/jkinkead/gists{/gist_id}","starred_url":"https://api.github.com/users/jkinkead/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkinkead/subscriptions","organizations_url":"https://api.github.com/users/jkinkead/orgs","repos_url":"https://api.github.com/users/jkinkead/repos","events_url":"https://api.github.com/users/jkinkead/events{/privacy}","received_events_url":"https://api.github.com/users/jkinkead/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/allenai/sbt-plugins/pulls/209/commits","review_comments_url":"https://api.github.com/repos/allenai/sbt-plugins/pulls/209/comments","review_comment_url":"https://api.github.com/repos/allenai/sbt-plugins/pulls/comments{/number}","comments_url":"https://api.github.com/repos/allenai/sbt-plugins/issues/209/comments","statuses_url":"https://api.github.com/repos/allenai/sbt-plugins/statuses/e0d0a04256b2640bee79d6f9177a7965b70dac5a","head":{"label":"danxmoran:startup-args","ref":"startup-args","sha":"e0d0a04256b2640bee79d6f9177a7965b70dac5a","user":{"login":"danxmoran","id":2755881,"avatar_url":"https://avatars.githubusercontent.com/u/2755881?v=3","gravatar_id":"","url":"https://api.github.com/users/danxmoran","html_url":"https://github.com/danxmoran","followers_url":"https://api.github.com/users/danxmoran/followers","following_url":"https://api.github.com/users/danxmoran/following{/other_user}","gists_url":"https://api.github.com/users/danxmoran/gists{/gist_id}","starred_url":"https://api.github.com/users/danxmoran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danxmoran/subscriptions","organizations_url":"https://api.github.com/users/danxmoran/orgs","repos_url":"https://api.github.com/users/danxmoran/repos","events_url":"https://api.github.com/users/danxmoran/events{/privacy}","received_events_url":"https://api.github.com/users/danxmoran/received_events","type":"User","site_admin":false},"repo":{"id":50371193,"name":"sbt-plugins","full_name":"danxmoran/sbt-plugins","owner":{"login":"danxmoran","id":2755881,"avatar_url":"https://avatars.githubusercontent.com/u/2755881?v=3","gravatar_id":"","url":"https://api.github.com/users/danxmoran","html_url":"https://github.com/danxmoran","followers_url":"https://api.github.com/users/danxmoran/followers","following_url":"https://api.github.com/users/danxmoran/following{/other_user}","gists_url":"https://api.github.com/users/danxmoran/gists{/gist_id}","starred_url":"https://api.github.com/users/danxmoran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danxmoran/subscriptions","organizations_url":"https://api.github.com/users/danxmoran/orgs","repos_url":"https://api.github.com/users/danxmoran/repos","events_url":"https://api.github.com/users/danxmoran/events{/privacy}","received_events_url":"https://api.github.com/users/danxmoran/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/danxmoran/sbt-plugins","description":"SBT Plugins for AI2 projects","fork":true,"url":"https://api.github.com/repos/danxmoran/sbt-plugins","forks_url":"https://api.github.com/repos/danxmoran/sbt-plugins/forks","keys_url":"https://api.github.com/repos/danxmoran/sbt-plugins/keys{/key_id}","collaborators_url":"https://api.github.com/repos/danxmoran/sbt-plugins/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/danxmoran/sbt-plugins/teams","hooks_url":"https://api.github.com/repos/danxmoran/sbt-plugins/hooks","issue_events_url":"https://api.github.com/repos/danxmoran/sbt-plugins/issues/events{/number}","events_url":"https://api.github.com/repos/danxmoran/sbt-plugins/events","assignees_url":"https://api.github.com/repos/danxmoran/sbt-plugins/assignees{/user}","branches_url":"https://api.github.com/repos/danxmoran/sbt-plugins/branches{/branch}","tags_url":"https://api.github.com/repos/danxmoran/sbt-plugins/tags","blobs_url":"https://api.github.com/repos/danxmoran/sbt-plugins/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/danxmoran/sbt-plugins/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/danxmoran/sbt-plugins/git/refs{/sha}","trees_url":"https://api.github.com/repos/danxmoran/sbt-plugins/git/trees{/sha}","statuses_url":"https://api.github.com/repos/danxmoran/sbt-plugins/statuses/{sha}","languages_url":"https://api.github.com/repos/danxmoran/sbt-plugins/languages","stargazers_url":"https://api.github.com/repos/danxmoran/sbt-plugins/stargazers","contributors_url":"https://api.github.com/repos/danxmoran/sbt-plugins/contributors","subscribers_url":"https://api.github.com/repos/danxmoran/sbt-plugins/subscribers","subscription_url":"https://api.github.com/repos/danxmoran/sbt-plugins/subscription","commits_url":"https://api.github.com/repos/danxmoran/sbt-plugins/commits{/sha}","git_commits_url":"https://api.github.com/repos/danxmoran/sbt-plugins/git/commits{/sha}","comments_url":"https://api.github.com/repos/danxmoran/sbt-plugins/comments{/number}","issue_comment_url":"https://api.github.com/repos/danxmoran/sbt-plugins/issues/comments{/number}","contents_url":"https://api.github.com/repos/danxmoran/sbt-plugins/contents/{+path}","compare_url":"https://api.github.com/repos/danxmoran/sbt-plugins/compare/{base}...{head}","merges_url":"https://api.github.com/repos/danxmoran/sbt-plugins/merges","archive_url":"https://api.github.com/repos/danxmoran/sbt-plugins/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/danxmoran/sbt-plugins/downloads","issues_url":"https://api.github.com/repos/danxmoran/sbt-plugins/issues{/number}","pulls_url":"https://api.github.com/repos/danxmoran/sbt-plugins/pulls{/number}","milestones_url":"https://api.github.com/repos/danxmoran/sbt-plugins/milestones{/number}","notifications_url":"https://api.github.com/repos/danxmoran/sbt-plugins/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/danxmoran/sbt-plugins/labels{/name}","releases_url":"https://api.github.com/repos/danxmoran/sbt-plugins/releases{/id}","deployments_url":"https://api.github.com/repos/danxmoran/sbt-plugins/deployments","created_at":"2016-01-25T18:23:50Z","updated_at":"2016-01-25T18:23:51Z","pushed_at":"2016-02-16T21:11:29Z","git_url":"git://github.com/danxmoran/sbt-plugins.git","ssh_url":"git@github.com:danxmoran/sbt-plugins.git","clone_url":"https://github.com/danxmoran/sbt-plugins.git","svn_url":"https://github.com/danxmoran/sbt-plugins","homepage":"","size":8533,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"allenai:master","ref":"master","sha":"0b542906023c00528baca79920a439a86fbc35fd","user":{"login":"allenai","id":5667695,"avatar_url":"https://avatars.githubusercontent.com/u/5667695?v=3","gravatar_id":"","url":"https://api.github.com/users/allenai","html_url":"https://github.com/allenai","followers_url":"https://api.github.com/users/allenai/followers","following_url":"https://api.github.com/users/allenai/following{/other_user}","gists_url":"https://api.github.com/users/allenai/gists{/gist_id}","starred_url":"https://api.github.com/users/allenai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/allenai/subscriptions","organizations_url":"https://api.github.com/users/allenai/orgs","repos_url":"https://api.github.com/users/allenai/repos","events_url":"https://api.github.com/users/allenai/events{/privacy}","received_events_url":"https://api.github.com/users/allenai/received_events","type":"Organization","site_admin":false},"repo":{"id":15742018,"name":"sbt-plugins","full_name":"allenai/sbt-plugins","owner":{"login":"allenai","id":5667695,"avatar_url":"https://avatars.githubusercontent.com/u/5667695?v=3","gravatar_id":"","url":"https://api.github.com/users/allenai","html_url":"https://github.com/allenai","followers_url":"https://api.github.com/users/allenai/followers","following_url":"https://api.github.com/users/allenai/following{/other_user}","gists_url":"https://api.github.com/users/allenai/gists{/gist_id}","starred_url":"https://api.github.com/users/allenai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/allenai/subscriptions","organizations_url":"https://api.github.com/users/allenai/orgs","repos_url":"https://api.github.com/users/allenai/repos","events_url":"https://api.github.com/users/allenai/events{/privacy}","received_events_url":"https://api.github.com/users/allenai/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/allenai/sbt-plugins","description":"SBT Plugins for AI2 projects","fork":false,"url":"https://api.github.com/repos/allenai/sbt-plugins","forks_url":"https://api.github.com/repos/allenai/sbt-plugins/forks","keys_url":"https://api.github.com/repos/allenai/sbt-plugins/keys{/key_id}","collaborators_url":"https://api.github.com/repos/allenai/sbt-plugins/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/allenai/sbt-plugins/teams","hooks_url":"https://api.github.com/repos/allenai/sbt-plugins/hooks","issue_events_url":"https://api.github.com/repos/allenai/sbt-plugins/issues/events{/number}","events_url":"https://api.github.com/repos/allenai/sbt-plugins/events","assignees_url":"https://api.github.com/repos/allenai/sbt-plugins/assignees{/user}","branches_url":"https://api.github.com/repos/allenai/sbt-plugins/branches{/branch}","tags_url":"https://api.github.com/repos/allenai/sbt-plugins/tags","blobs_url":"https://api.github.com/repos/allenai/sbt-plugins/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/allenai/sbt-plugins/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/allenai/sbt-plugins/git/refs{/sha}","trees_url":"https://api.github.com/repos/allenai/sbt-plugins/git/trees{/sha}","statuses_url":"https://api.github.com/repos/allenai/sbt-plugins/statuses/{sha}","languages_url":"https://api.github.com/repos/allenai/sbt-plugins/languages","stargazers_url":"https://api.github.com/repos/allenai/sbt-plugins/stargazers","contributors_url":"https://api.github.com/repos/allenai/sbt-plugins/contributors","subscribers_url":"https://api.github.com/repos/allenai/sbt-plugins/subscribers","subscription_url":"https://api.github.com/repos/allenai/sbt-plugins/subscription","commits_url":"https://api.github.com/repos/allenai/sbt-plugins/commits{/sha}","git_commits_url":"https://api.github.com/repos/allenai/sbt-plugins/git/commits{/sha}","comments_url":"https://api.github.com/repos/allenai/sbt-plugins/comments{/number}","issue_comment_url":"https://api.github.com/repos/allenai/sbt-plugins/issues/comments{/number}","contents_url":"https://api.github.com/repos/allenai/sbt-plugins/contents/{+path}","compare_url":"https://api.github.com/repos/allenai/sbt-plugins/compare/{base}...{head}","merges_url":"https://api.github.com/repos/allenai/sbt-plugins/merges","archive_url":"https://api.github.com/repos/allenai/sbt-plugins/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/allenai/sbt-plugins/downloads","issues_url":"https://api.github.com/repos/allenai/sbt-plugins/issues{/number}","pulls_url":"https://api.github.com/repos/allenai/sbt-plugins/pulls{/number}","milestones_url":"https://api.github.com/repos/allenai/sbt-plugins/milestones{/number}","notifications_url":"https://api.github.com/repos/allenai/sbt-plugins/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/allenai/sbt-plugins/labels{/name}","releases_url":"https://api.github.com/repos/allenai/sbt-plugins/releases{/id}","deployments_url":"https://api.github.com/repos/allenai/sbt-plugins/deployments","created_at":"2014-01-08T17:07:07Z","updated_at":"2016-01-20T21:26:50Z","pushed_at":"2016-02-16T21:22:59Z","git_url":"git://github.com/allenai/sbt-plugins.git","ssh_url":"git@github.com:allenai/sbt-plugins.git","clone_url":"https://github.com/allenai/sbt-plugins.git","svn_url":"https://github.com/allenai/sbt-plugins","homepage":"","size":8539,"stargazers_count":13,"watchers_count":13,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":13,"mirror_url":null,"open_issues_count":17,"forks":13,"open_issues":17,"watchers":13,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/allenai/sbt-plugins/pulls/209"},"html":{"href":"https://github.com/allenai/sbt-plugins/pull/209"},"issue":{"href":"https://api.github.com/repos/allenai/sbt-plugins/issues/209"},"comments":{"href":"https://api.github.com/repos/allenai/sbt-plugins/issues/209/comments"},"review_comments":{"href":"https://api.github.com/repos/allenai/sbt-plugins/pulls/209/comments"},"review_comment":{"href":"https://api.github.com/repos/allenai/sbt-plugins/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/allenai/sbt-plugins/pulls/209/commits"},"statuses":{"href":"https://api.github.com/repos/allenai/sbt-plugins/statuses/e0d0a04256b2640bee79d6f9177a7965b70dac5a"}}}}