Skip to content

Commit

Permalink
make scala deploy config respect environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-goldstein committed Jul 31, 2023
1 parent 04a7fcb commit 604974e
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions hail/src/main/scala/is/hail/services/DeployConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,27 @@ object DeployConfig {
fromConfig(JsonMethods.parse(in))
}
} else
new DeployConfig(
"external",
"default",
"hail.is")
fromConfig("external", "default", "hail.is")
}

def fromConfig(config: JValue): DeployConfig = {
implicit val formats: Formats = DefaultFormats
new DeployConfig(
fromConfig(
(config \ "location").extract[String],
(config \ "default_namespace").extract[String],
(config \ "domain").extract[Option[String]].getOrElse("hail.is"))
}

def fromConfig(location: String, defaultNamespace: String, domain: String): DeployConfig = {
new DeployConfig(
sys.env.getOrElse(toEnvVarName("location"), location),
sys.env.getOrElse(toEnvVarName("default_namespace"), location),
sys.env.getOrElse(toEnvVarName("domain"), location))
}

private[this] def toEnvVarName(s: String): String = {
"HAIL_" + s.toUpperCase
}
}

class DeployConfig(
Expand Down

0 comments on commit 604974e

Please sign in to comment.