timetable-mgr/src/config.go

47 lines
966 B
Go
Raw Normal View History

2023-07-15 22:32:46 +01:00
package main
import (
"os"
"fmt"
)
// Version Constants
const versionNum string = "2023.7.1"
const versionSuffix string = "beta"
const versionStr string = versionNum + "-" + versionSuffix
// Environment Variables
var runtime string = getRuntime()
var dbUri string = getDbUri()
// 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;
}