initial commit
This commit is contained in:
35
services/discovery.go
Normal file
35
services/discovery.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
SelfAPI "cloud.o-forge.io/core/oc-catalog/selfapi"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
var DC_NAME string
|
||||
|
||||
func GetSelfAPI(host string) *SelfAPI.APIClient {
|
||||
return SelfAPI.NewAPIClient(&SelfAPI.Configuration{BasePath: "http://" + host + "/v1"})
|
||||
}
|
||||
|
||||
func Discoveryinit() {
|
||||
|
||||
dcNameOS := os.Getenv("DOCKER_DCNAME")
|
||||
if len(dcNameOS) != 0 {
|
||||
DC_NAME = dcNameOS
|
||||
return
|
||||
}
|
||||
|
||||
//FIXME: Beego doesn't retrieve the dcname
|
||||
beegoDC, err := beego.AppConfig.String("DCNAME")
|
||||
if err == nil && len(beegoDC) != 0 {
|
||||
DC_NAME = beegoDC
|
||||
return
|
||||
}
|
||||
|
||||
DC_NAME = "DC_DEFAULT"
|
||||
logs.Warning("Default DC name is used")
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user