From 586a88c710f74fd755618e13474a18ea7539fa2b Mon Sep 17 00:00:00 2001 From: Anton Tolchanov Date: Tue, 24 Jan 2023 12:14:01 +0000 Subject: [PATCH] hostinfo: add an environment type for Replit Signed-off-by: Anton Tolchanov --- hostinfo/hostinfo.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hostinfo/hostinfo.go b/hostinfo/hostinfo.go index 5ce9142ed..d86fbf97b 100644 --- a/hostinfo/hostinfo.go +++ b/hostinfo/hostinfo.go @@ -139,6 +139,7 @@ func packageTypeCached() string { FlyDotIo = EnvType("fly") Kubernetes = EnvType("k8s") DockerDesktop = EnvType("dde") + Replit = EnvType("repl") ) var envType atomic.Value // of EnvType @@ -226,6 +227,9 @@ func getEnvType() EnvType { if inDockerDesktop() { return DockerDesktop } + if inReplit() { + return Replit + } return "" } @@ -313,6 +317,14 @@ func inFlyDotIo() bool { return false } +func inReplit() bool { + // https://docs.replit.com/programming-ide/getting-repl-metadata + if os.Getenv("REPL_OWNER") != "" && os.Getenv("REPL_SLUG") != "" { + return true + } + return false +} + func inKubernetes() bool { if os.Getenv("KUBERNETES_SERVICE_HOST") != "" && os.Getenv("KUBERNETES_SERVICE_PORT") != "" { return true