aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/core/init/Platform.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/scala/xyz/driver/core/init/Platform.scala')
-rw-r--r--src/main/scala/xyz/driver/core/init/Platform.scala31
1 files changed, 0 insertions, 31 deletions
diff --git a/src/main/scala/xyz/driver/core/init/Platform.scala b/src/main/scala/xyz/driver/core/init/Platform.scala
deleted file mode 100644
index 2daa2c8..0000000
--- a/src/main/scala/xyz/driver/core/init/Platform.scala
+++ /dev/null
@@ -1,31 +0,0 @@
-package xyz.driver.core
-package init
-
-import java.nio.file.{Files, Path, Paths}
-
-import com.google.auth.oauth2.ServiceAccountCredentials
-
-sealed trait Platform
-object Platform {
- case class GoogleCloud(keyfile: Path, namespace: String) extends Platform {
- def credentials: ServiceAccountCredentials = ServiceAccountCredentials.fromStream(
- Files.newInputStream(keyfile)
- )
- def project: String = credentials.getProjectId
- }
- // case object AliCloud extends Platform
- case object Dev extends Platform
-
- lazy val fromEnv: Platform = {
- def isGoogle = sys.env.get("GOOGLE_APPLICATION_CREDENTIALS").map { value =>
- val keyfile = Paths.get(value)
- require(Files.isReadable(keyfile), s"Google credentials file $value is not readable.")
- val namespace = sys.env.getOrElse("SERVICE_NAMESPACE", sys.error("Namespace not set"))
- GoogleCloud(keyfile, namespace)
- }
- isGoogle.getOrElse(Dev)
- }
-
- def current: Platform = fromEnv
-
-}