Skip to content

Commit

Permalink
Added debug message (apache#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gschiavon authored and pianista215 committed Jan 9, 2018
1 parent ad671c5 commit 117177f
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions core/src/main/scala/org/apache/spark/security/ConfigSecurity.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,32 @@
*/
package org.apache.spark.security


import scala.util.{Failure, Success, Try}


import org.apache.spark.internal.Logging

object ConfigSecurity extends Logging {

lazy val vaultToken: Option[String] =

if (sys.env.get("VAULT_TOKEN").isDefined) {
logDebug("Obtaining vault token using VAULT_TOKEN")
logInfo("Obtaining vault token using VAULT_TOKEN")
sys.env.get("VAULT_TOKEN")
} else if (sys.env.get("VAULT_TEMP_TOKEN").isDefined) {
logDebug("Obtaining vault token using VAULT_TEMP_TOKEN")
logInfo("Obtaining vault token using VAULT_TEMP_TOKEN")
scala.util.Try {
VaultHelper.getRealToken(sys.env.get("VAULT_TEMP_TOKEN"))
}.toOption
} match {
case Success(token) => Option(token)
case Failure(e) =>
logWarning("An error ocurred while trying to obtain" +
" Application Token from a temporal token", e)
None
}
} else if (sys.env.get("VAULT_ROLE_ID").isDefined && sys.env.get("VAULT_SECRET_ID").isDefined) {
logDebug("Obtaining vault token using ROLE_ID and SECRET_ID")
logInfo("Obtaining vault token using ROLE_ID and SECRET_ID")
Option(VaultHelper.getTokenFromAppRole(
sys.env("VAULT_ROLE_ID"),
sys.env("VAULT_SECRET_ID")))
Expand Down

0 comments on commit 117177f

Please sign in to comment.