{"action":"created","comment":{"url":"https://api.github.com/repos/avast/marathon-vault-plugin/pulls/comments/136165155","pull_request_review_id":59666247,"id":136165155,"diff_hunk":"@@ -12,47 +12,39 @@ import play.api.libs.json.{JsObject, _}\n \n import scala.util.{Failure, Success, Try}\n \n-case class Configuration(address: String, token: String)\n+case class Configuration(address: String, token: String, pathProvider: PathProvider)\n+case class PathProvider(name: String, pathPrefix: Option[String])\n \n class VaultPlugin extends RunSpecTaskProcessor with PluginConfiguration {\n \n   private val logger = LoggerFactory.getLogger(classOf[VaultPlugin])\n   logger.info(\"Vault plugin instantiated\")\n \n   private var vault: Vault = _\n+  private var pathProvider: VaultPathProvider = _\n \n   override def initialize(marathonInfo: Map[String, Any], configurationJson: JsObject): Unit = {\n-    val conf = configurationJson.as[Configuration](Json.reads[Configuration])\n+    implicit val pathProviderFormat = Json.format[PathProvider]\n+    val conf = configurationJson.as[Configuration](Json.format[Configuration])\n     assert(conf != null, \"VaultPlugin not initialized with configuration info.\")\n     assert(conf.address != null, \"Vault address not specified.\")\n     assert(conf.token != null, \"Vault token not specified.\")\n     vault = new Vault(new VaultConfig().address(conf.address).token(conf.token).build())\n+    pathProvider = conf.pathProvider.name.toLowerCase match {\n+      case \"absolutepathprovider\" => new AbsolutePathProvider()\n+      case \"relativepathprovider\" => new RelativePathProvider(conf.pathProvider.pathPrefix.getOrElse(\"\"))\n+      case p => throw new RuntimeException(s\"Unknown Vault path provider '$p'\")\n+    }\n     logger.info(s\"VaultPlugin initialized with $conf\")\n   }\n \n-  /*\n-    {\n-      \"env\": {\n-        \"abc\": \"def\",\n-        \"DB_PASSWORD\": {\n-          \"secret\": \"db_pwd\"\n-        }\n-      },\n-      \"secrets\": {\n-        \"db_pwd\": {\n-          \"source\": \"/path/to/vault/secret@password\"\n-        }\n-      }\n-    }\n-  */\n-\n   def taskInfo(appSpec: ApplicationSpec, builder: TaskInfo.Builder): Unit = {\n     val envBuilder = builder.getCommand.getEnvironment.toBuilder\n     appSpec.env.foreach {\n       case (name, v: EnvVarSecretRef) =>\n         appSpec.secrets.get(v.secret) match {\n           case Some(secret) =>\n-            getSecretValueFromVault(secret) match {\n+            getSecretValueFromVault(secret, pathProvider.getPath(appSpec, builder)) match {","path":"src/main/scala/com/avast/marathon/plugin/vault/VaultPlugin.scala","position":55,"original_position":55,"commit_id":"19670ef2d9f7b0f3525c18473dd8feed433d9313","original_commit_id":"71752fd00f6bcb9a07597c9543a2e50f972ca3e6","user":{"login":"augi","id":273052,"avatar_url":"https://avatars3.githubusercontent.com/u/273052?v=4","gravatar_id":"","url":"https://api.github.com/users/augi","html_url":"https://github.com/augi","followers_url":"https://api.github.com/users/augi/followers","following_url":"https://api.github.com/users/augi/following{/other_user}","gists_url":"https://api.github.com/users/augi/gists{/gist_id}","starred_url":"https://api.github.com/users/augi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/augi/subscriptions","organizations_url":"https://api.github.com/users/augi/orgs","repos_url":"https://api.github.com/users/augi/repos","events_url":"https://api.github.com/users/augi/events{/privacy}","received_events_url":"https://api.github.com/users/augi/received_events","type":"User","site_admin":false},"body":"Ok. The `getSecretValueFromVault` method is instance method so you can access the `pathProvider` there directly. So I would prefer to remove the second parameter of `getSecretValueFromVault` method, and call `pathProvider.getFullPath` from it.","created_at":"2017-08-30T19:21:26Z","updated_at":"2017-08-30T19:26:43Z","html_url":"https://github.com/avast/marathon-vault-plugin/pull/1#discussion_r136165155","pull_request_url":"https://api.github.com/repos/avast/marathon-vault-plugin/pulls/1","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/avast/marathon-vault-plugin/pulls/comments/136165155"},"html":{"href":"https://github.com/avast/marathon-vault-plugin/pull/1#discussion_r136165155"},"pull_request":{"href":"https://api.github.com/repos/avast/marathon-vault-plugin/pulls/1"}},"in_reply_to_id":136157944},"pull_request":{"url":"https://api.github.com/repos/avast/marathon-vault-plugin/pulls/1","id":138487007,"html_url":"https://github.com/avast/marathon-vault-plugin/pull/1","diff_url":"https://github.com/avast/marathon-vault-plugin/pull/1.diff","patch_url":"https://github.com/avast/marathon-vault-plugin/pull/1.patch","issue_url":"https://api.github.com/repos/avast/marathon-vault-plugin/issues/1","number":1,"state":"open","locked":false,"title":"Path providers","user":{"login":"rpliva","id":11376905,"avatar_url":"https://avatars1.githubusercontent.com/u/11376905?v=4","gravatar_id":"","url":"https://api.github.com/users/rpliva","html_url":"https://github.com/rpliva","followers_url":"https://api.github.com/users/rpliva/followers","following_url":"https://api.github.com/users/rpliva/following{/other_user}","gists_url":"https://api.github.com/users/rpliva/gists{/gist_id}","starred_url":"https://api.github.com/users/rpliva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rpliva/subscriptions","organizations_url":"https://api.github.com/users/rpliva/orgs","repos_url":"https://api.github.com/users/rpliva/repos","events_url":"https://api.github.com/users/rpliva/events{/privacy}","received_events_url":"https://api.github.com/users/rpliva/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-08-30T17:41:38Z","updated_at":"2017-08-30T19:26:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"667c23163d2ed86fbfd120668bdaa5db12218d77","assignee":null,"assignees":[],"requested_reviewers":[{"login":"petr-k","id":376925,"avatar_url":"https://avatars2.githubusercontent.com/u/376925?v=4","gravatar_id":"","url":"https://api.github.com/users/petr-k","html_url":"https://github.com/petr-k","followers_url":"https://api.github.com/users/petr-k/followers","following_url":"https://api.github.com/users/petr-k/following{/other_user}","gists_url":"https://api.github.com/users/petr-k/gists{/gist_id}","starred_url":"https://api.github.com/users/petr-k/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/petr-k/subscriptions","organizations_url":"https://api.github.com/users/petr-k/orgs","repos_url":"https://api.github.com/users/petr-k/repos","events_url":"https://api.github.com/users/petr-k/events{/privacy}","received_events_url":"https://api.github.com/users/petr-k/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/avast/marathon-vault-plugin/pulls/1/commits","review_comments_url":"https://api.github.com/repos/avast/marathon-vault-plugin/pulls/1/comments","review_comment_url":"https://api.github.com/repos/avast/marathon-vault-plugin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/avast/marathon-vault-plugin/issues/1/comments","statuses_url":"https://api.github.com/repos/avast/marathon-vault-plugin/statuses/19670ef2d9f7b0f3525c18473dd8feed433d9313","head":{"label":"avast:PathProviders","ref":"PathProviders","sha":"19670ef2d9f7b0f3525c18473dd8feed433d9313","user":{"login":"avast","id":3996079,"avatar_url":"https://avatars1.githubusercontent.com/u/3996079?v=4","gravatar_id":"","url":"https://api.github.com/users/avast","html_url":"https://github.com/avast","followers_url":"https://api.github.com/users/avast/followers","following_url":"https://api.github.com/users/avast/following{/other_user}","gists_url":"https://api.github.com/users/avast/gists{/gist_id}","starred_url":"https://api.github.com/users/avast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avast/subscriptions","organizations_url":"https://api.github.com/users/avast/orgs","repos_url":"https://api.github.com/users/avast/repos","events_url":"https://api.github.com/users/avast/events{/privacy}","received_events_url":"https://api.github.com/users/avast/received_events","type":"Organization","site_admin":false},"repo":{"id":75668638,"name":"marathon-vault-plugin","full_name":"avast/marathon-vault-plugin","owner":{"login":"avast","id":3996079,"avatar_url":"https://avatars1.githubusercontent.com/u/3996079?v=4","gravatar_id":"","url":"https://api.github.com/users/avast","html_url":"https://github.com/avast","followers_url":"https://api.github.com/users/avast/followers","following_url":"https://api.github.com/users/avast/following{/other_user}","gists_url":"https://api.github.com/users/avast/gists{/gist_id}","starred_url":"https://api.github.com/users/avast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avast/subscriptions","organizations_url":"https://api.github.com/users/avast/orgs","repos_url":"https://api.github.com/users/avast/repos","events_url":"https://api.github.com/users/avast/events{/privacy}","received_events_url":"https://api.github.com/users/avast/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/avast/marathon-vault-plugin","description":"Marathon plugin which injects Vault secrets via environment variables","fork":false,"url":"https://api.github.com/repos/avast/marathon-vault-plugin","forks_url":"https://api.github.com/repos/avast/marathon-vault-plugin/forks","keys_url":"https://api.github.com/repos/avast/marathon-vault-plugin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/avast/marathon-vault-plugin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/avast/marathon-vault-plugin/teams","hooks_url":"https://api.github.com/repos/avast/marathon-vault-plugin/hooks","issue_events_url":"https://api.github.com/repos/avast/marathon-vault-plugin/issues/events{/number}","events_url":"https://api.github.com/repos/avast/marathon-vault-plugin/events","assignees_url":"https://api.github.com/repos/avast/marathon-vault-plugin/assignees{/user}","branches_url":"https://api.github.com/repos/avast/marathon-vault-plugin/branches{/branch}","tags_url":"https://api.github.com/repos/avast/marathon-vault-plugin/tags","blobs_url":"https://api.github.com/repos/avast/marathon-vault-plugin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/avast/marathon-vault-plugin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/avast/marathon-vault-plugin/git/refs{/sha}","trees_url":"https://api.github.com/repos/avast/marathon-vault-plugin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/avast/marathon-vault-plugin/statuses/{sha}","languages_url":"https://api.github.com/repos/avast/marathon-vault-plugin/languages","stargazers_url":"https://api.github.com/repos/avast/marathon-vault-plugin/stargazers","contributors_url":"https://api.github.com/repos/avast/marathon-vault-plugin/contributors","subscribers_url":"https://api.github.com/repos/avast/marathon-vault-plugin/subscribers","subscription_url":"https://api.github.com/repos/avast/marathon-vault-plugin/subscription","commits_url":"https://api.github.com/repos/avast/marathon-vault-plugin/commits{/sha}","git_commits_url":"https://api.github.com/repos/avast/marathon-vault-plugin/git/commits{/sha}","comments_url":"https://api.github.com/repos/avast/marathon-vault-plugin/comments{/number}","issue_comment_url":"https://api.github.com/repos/avast/marathon-vault-plugin/issues/comments{/number}","contents_url":"https://api.github.com/repos/avast/marathon-vault-plugin/contents/{+path}","compare_url":"https://api.github.com/repos/avast/marathon-vault-plugin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/avast/marathon-vault-plugin/merges","archive_url":"https://api.github.com/repos/avast/marathon-vault-plugin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/avast/marathon-vault-plugin/downloads","issues_url":"https://api.github.com/repos/avast/marathon-vault-plugin/issues{/number}","pulls_url":"https://api.github.com/repos/avast/marathon-vault-plugin/pulls{/number}","milestones_url":"https://api.github.com/repos/avast/marathon-vault-plugin/milestones{/number}","notifications_url":"https://api.github.com/repos/avast/marathon-vault-plugin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/avast/marathon-vault-plugin/labels{/name}","releases_url":"https://api.github.com/repos/avast/marathon-vault-plugin/releases{/id}","deployments_url":"https://api.github.com/repos/avast/marathon-vault-plugin/deployments","created_at":"2016-12-05T21:38:23Z","updated_at":"2017-08-30T09:50:20Z","pushed_at":"2017-08-30T19:16:14Z","git_url":"git://github.com/avast/marathon-vault-plugin.git","ssh_url":"git@github.com:avast/marathon-vault-plugin.git","clone_url":"https://github.com/avast/marathon-vault-plugin.git","svn_url":"https://github.com/avast/marathon-vault-plugin","homepage":"","size":110,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"avast:master","ref":"master","sha":"001b1540fc8fc2a76fcb759c1fa889b68dcf87c3","user":{"login":"avast","id":3996079,"avatar_url":"https://avatars1.githubusercontent.com/u/3996079?v=4","gravatar_id":"","url":"https://api.github.com/users/avast","html_url":"https://github.com/avast","followers_url":"https://api.github.com/users/avast/followers","following_url":"https://api.github.com/users/avast/following{/other_user}","gists_url":"https://api.github.com/users/avast/gists{/gist_id}","starred_url":"https://api.github.com/users/avast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avast/subscriptions","organizations_url":"https://api.github.com/users/avast/orgs","repos_url":"https://api.github.com/users/avast/repos","events_url":"https://api.github.com/users/avast/events{/privacy}","received_events_url":"https://api.github.com/users/avast/received_events","type":"Organization","site_admin":false},"repo":{"id":75668638,"name":"marathon-vault-plugin","full_name":"avast/marathon-vault-plugin","owner":{"login":"avast","id":3996079,"avatar_url":"https://avatars1.githubusercontent.com/u/3996079?v=4","gravatar_id":"","url":"https://api.github.com/users/avast","html_url":"https://github.com/avast","followers_url":"https://api.github.com/users/avast/followers","following_url":"https://api.github.com/users/avast/following{/other_user}","gists_url":"https://api.github.com/users/avast/gists{/gist_id}","starred_url":"https://api.github.com/users/avast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avast/subscriptions","organizations_url":"https://api.github.com/users/avast/orgs","repos_url":"https://api.github.com/users/avast/repos","events_url":"https://api.github.com/users/avast/events{/privacy}","received_events_url":"https://api.github.com/users/avast/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/avast/marathon-vault-plugin","description":"Marathon plugin which injects Vault secrets via environment variables","fork":false,"url":"https://api.github.com/repos/avast/marathon-vault-plugin","forks_url":"https://api.github.com/repos/avast/marathon-vault-plugin/forks","keys_url":"https://api.github.com/repos/avast/marathon-vault-plugin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/avast/marathon-vault-plugin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/avast/marathon-vault-plugin/teams","hooks_url":"https://api.github.com/repos/avast/marathon-vault-plugin/hooks","issue_events_url":"https://api.github.com/repos/avast/marathon-vault-plugin/issues/events{/number}","events_url":"https://api.github.com/repos/avast/marathon-vault-plugin/events","assignees_url":"https://api.github.com/repos/avast/marathon-vault-plugin/assignees{/user}","branches_url":"https://api.github.com/repos/avast/marathon-vault-plugin/branches{/branch}","tags_url":"https://api.github.com/repos/avast/marathon-vault-plugin/tags","blobs_url":"https://api.github.com/repos/avast/marathon-vault-plugin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/avast/marathon-vault-plugin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/avast/marathon-vault-plugin/git/refs{/sha}","trees_url":"https://api.github.com/repos/avast/marathon-vault-plugin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/avast/marathon-vault-plugin/statuses/{sha}","languages_url":"https://api.github.com/repos/avast/marathon-vault-plugin/languages","stargazers_url":"https://api.github.com/repos/avast/marathon-vault-plugin/stargazers","contributors_url":"https://api.github.com/repos/avast/marathon-vault-plugin/contributors","subscribers_url":"https://api.github.com/repos/avast/marathon-vault-plugin/subscribers","subscription_url":"https://api.github.com/repos/avast/marathon-vault-plugin/subscription","commits_url":"https://api.github.com/repos/avast/marathon-vault-plugin/commits{/sha}","git_commits_url":"https://api.github.com/repos/avast/marathon-vault-plugin/git/commits{/sha}","comments_url":"https://api.github.com/repos/avast/marathon-vault-plugin/comments{/number}","issue_comment_url":"https://api.github.com/repos/avast/marathon-vault-plugin/issues/comments{/number}","contents_url":"https://api.github.com/repos/avast/marathon-vault-plugin/contents/{+path}","compare_url":"https://api.github.com/repos/avast/marathon-vault-plugin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/avast/marathon-vault-plugin/merges","archive_url":"https://api.github.com/repos/avast/marathon-vault-plugin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/avast/marathon-vault-plugin/downloads","issues_url":"https://api.github.com/repos/avast/marathon-vault-plugin/issues{/number}","pulls_url":"https://api.github.com/repos/avast/marathon-vault-plugin/pulls{/number}","milestones_url":"https://api.github.com/repos/avast/marathon-vault-plugin/milestones{/number}","notifications_url":"https://api.github.com/repos/avast/marathon-vault-plugin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/avast/marathon-vault-plugin/labels{/name}","releases_url":"https://api.github.com/repos/avast/marathon-vault-plugin/releases{/id}","deployments_url":"https://api.github.com/repos/avast/marathon-vault-plugin/deployments","created_at":"2016-12-05T21:38:23Z","updated_at":"2017-08-30T09:50:20Z","pushed_at":"2017-08-30T19:16:14Z","git_url":"git://github.com/avast/marathon-vault-plugin.git","ssh_url":"git@github.com:avast/marathon-vault-plugin.git","clone_url":"https://github.com/avast/marathon-vault-plugin.git","svn_url":"https://github.com/avast/marathon-vault-plugin","homepage":"","size":110,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/avast/marathon-vault-plugin/pulls/1"},"html":{"href":"https://github.com/avast/marathon-vault-plugin/pull/1"},"issue":{"href":"https://api.github.com/repos/avast/marathon-vault-plugin/issues/1"},"comments":{"href":"https://api.github.com/repos/avast/marathon-vault-plugin/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/avast/marathon-vault-plugin/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/avast/marathon-vault-plugin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/avast/marathon-vault-plugin/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/avast/marathon-vault-plugin/statuses/19670ef2d9f7b0f3525c18473dd8feed433d9313"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"augi"}}