2023-07-15 23:00:48 +01:00
|
|
|
package helpers
|
2023-07-15 22:32:46 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Version Constants
|
|
|
|
const versionNum string = "2023.7.1"
|
|
|
|
const versionSuffix string = "beta"
|
2023-07-15 23:00:48 +01:00
|
|
|
const Version string = versionNum + "-" + versionSuffix
|
2023-07-15 22:32:46 +01:00
|
|
|
|
|
|
|
// Environment Variables
|
|
|
|
var runtime string = getRuntime()
|
2023-07-17 12:48:36 +01:00
|
|
|
var DbUri string = getDbUri()
|
2023-07-15 23:06:32 +01:00
|
|
|
var NrUser string = "nil"
|
|
|
|
var NrPass string = ""
|
2023-07-15 22:32:46 +01:00
|
|
|
|
|
|
|
|
|
|
|
// Functions
|
|
|
|
func getRuntime() string {
|
|
|
|
var runtimeEnv string = os.Getenv("runtime")
|
|
|
|
if runtimeEnv == "" {
|
|
|
|
runtimeEnv = "unknown"
|
|
|
|
}
|
|
|
|
Out(fmt.Sprintf("Runtime mode: %s", runtimeEnv), 1)
|
|
|
|
return runtimeEnv
|
|
|
|
}
|
|
|
|
|
|
|
|
func getDbUri() string {
|
|
|
|
var dbHost string = os.Getenv("OWL_DB_HOST")
|
|
|
|
if dbHost == "" {
|
|
|
|
dbHost = "localhost"
|
|
|
|
}
|
|
|
|
var dbPort string = os.Getenv("OWL_DB_PORT")
|
|
|
|
if dbPort == "" {
|
|
|
|
dbPort = "27017"
|
|
|
|
}
|
|
|
|
var dbUser string = os.Getenv("OWL_DB_USER")
|
|
|
|
if dbUser == "" {
|
|
|
|
dbUser = "owl"
|
|
|
|
}
|
|
|
|
var dbPass string = os.Getenv("OWL_DB_PASS")
|
|
|
|
if dbPass == "" {
|
|
|
|
dbPass = "twittwoo"
|
|
|
|
}
|
|
|
|
var uri = "mongodb://" + dbUser + ":" + dbPass + "@" + dbHost + ":" + dbPort
|
|
|
|
return uri;
|
|
|
|
}
|