33 lines
706 B
Go
33 lines
706 B
Go
|
package env
|
||
|
|
||
|
import (
|
||
|
"os"
|
||
|
"strings"
|
||
|
|
||
|
"git.apinb.com/bsm-sdk/engine/types"
|
||
|
"git.apinb.com/bsm-sdk/engine/utils"
|
||
|
)
|
||
|
|
||
|
var MeshEnv *types.MeshEnv = nil
|
||
|
|
||
|
// get system env.
|
||
|
func NewEnv() *types.MeshEnv {
|
||
|
if MeshEnv == nil {
|
||
|
MeshEnv = &types.MeshEnv{
|
||
|
Workspace: GetEnvDefault("BlocksMesh_Workspace", "bsm"),
|
||
|
Prefix: GetEnvDefault("BlocksMesh_Prefix", utils.GetCurrentPath()),
|
||
|
JwtSecretKey: GetEnvDefault("BlocksMesh_JwtSecretKey", "Cblocksmesh2022C"),
|
||
|
RuntimeMode: strings.ToLower(GetEnvDefault("BlocksMesh_RuntimeMode", "dev")),
|
||
|
}
|
||
|
}
|
||
|
return MeshEnv
|
||
|
}
|
||
|
|
||
|
func GetEnvDefault(key string, def string) string {
|
||
|
value := os.Getenv(key)
|
||
|
if value == "" {
|
||
|
return def
|
||
|
}
|
||
|
return value
|
||
|
}
|