k8s integration
This commit is contained in:
16
main.go
16
main.go
@@ -6,18 +6,18 @@ import (
|
||||
|
||||
oclib "cloud.o-forge.io/core/oc-lib"
|
||||
"cloud.o-forge.io/core/oc-lib/logs"
|
||||
"cloud.o-forge.io/core/oc-lib/tools"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
"github.com/beego/beego/v2/server/web/filter/cors"
|
||||
)
|
||||
|
||||
const appname = "oc-discovery"
|
||||
|
||||
func main() {
|
||||
// Init the oc-lib
|
||||
oclib.Init(appname, "", "")
|
||||
oclib.Init(appname)
|
||||
// get the right config file
|
||||
|
||||
o := tools.GetConfLoader()
|
||||
o := oclib.GetConfLoader()
|
||||
|
||||
models.GetConfig().Port = o.GetIntDefault("port", 8080)
|
||||
models.GetConfig().LokiUrl = o.GetStringDefault("lokiurl", "")
|
||||
@@ -31,7 +31,7 @@ func main() {
|
||||
|
||||
// set oc-lib logger
|
||||
if models.GetConfig().LokiUrl != "" {
|
||||
logs.CreateLogger(appname, models.GetConfig().LokiUrl)
|
||||
logs.CreateLogger(appname)
|
||||
}
|
||||
|
||||
// Normal beego init
|
||||
@@ -39,6 +39,12 @@ func main() {
|
||||
beego.BConfig.Listen.HTTPPort = o.GetIntDefault("port", 8080)
|
||||
beego.BConfig.WebConfig.DirectoryIndex = true
|
||||
beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
|
||||
|
||||
beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
|
||||
AllowAllOrigins: true,
|
||||
AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
|
||||
AllowHeaders: []string{"Origin", "Authorization", "Content-Type"},
|
||||
ExposeHeaders: []string{"Content-Length", "Content-Type"},
|
||||
AllowCredentials: true,
|
||||
}))
|
||||
beego.Run()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user