changed the way oc-catalog API is constructed
This commit is contained in:
parent
2fd85737d1
commit
852755ab42
@ -2,6 +2,7 @@ package controllers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
OCCatalog_cli "oc-search/api-client/oc-catalog"
|
OCCatalog_cli "oc-search/api-client/oc-catalog"
|
||||||
|
"oc-search/models"
|
||||||
|
|
||||||
beego "github.com/beego/beego/v2/server/web"
|
beego "github.com/beego/beego/v2/server/web"
|
||||||
)
|
)
|
||||||
@ -13,9 +14,10 @@ type MainController struct {
|
|||||||
|
|
||||||
var OCCatalogAPI *OCCatalog_cli.APIClient
|
var OCCatalogAPI *OCCatalog_cli.APIClient
|
||||||
|
|
||||||
func init() {
|
func CreateOCCatalogAPI() {
|
||||||
|
config := models.GetConfig()
|
||||||
// auth := context.WithValue(context.Background(), OCCatalog_cli.ContextAPIKey, OCCatalog_cli.APIKey{Key: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdXRob3JpemVkIjp0cnVlLCJleHAiOjE2MTI1OTI3MDIsInVzZXJfaWQiOiJ4ZCJ9.kTLb1FtpdnaobUpe5u9Jw8S7Cc6gf7ExmU4U3XMcC2o"})
|
// auth := context.WithValue(context.Background(), OCCatalog_cli.ContextAPIKey, OCCatalog_cli.APIKey{Key: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdXRob3JpemVkIjp0cnVlLCJleHAiOjE2MTI1OTI3MDIsInVzZXJfaWQiOiJ4ZCJ9.kTLb1FtpdnaobUpe5u9Jw8S7Cc6gf7ExmU4U3XMcC2o"})
|
||||||
OCCatalogAPI = OCCatalog_cli.NewAPIClient(&OCCatalog_cli.Configuration{BasePath: "http://localhost:49618/v1",
|
OCCatalogAPI = OCCatalog_cli.NewAPIClient(&OCCatalog_cli.Configuration{BasePath: "http://"+config.OcCatalogUrl+"/v1",
|
||||||
DefaultHeader: map[string]string{
|
DefaultHeader: map[string]string{
|
||||||
"authorization": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdXRob3JpemVkIjp0cnVlLCJleHAiOjE2MTMwMDI0NjAsInVzZXJfaWQiOiJhc2QifQ.TXT18aeulnCrtedKKFVaD0BapOTdVAFcJJdVS7zk0I8",
|
"authorization": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdXRob3JpemVkIjp0cnVlLCJleHAiOjE2MTMwMDI0NjAsInVzZXJfaWQiOiJhc2QifQ.TXT18aeulnCrtedKKFVaD0BapOTdVAFcJJdVS7zk0I8",
|
||||||
},
|
},
|
||||||
|
@ -1 +1 @@
|
|||||||
{"/home/pierre/oc-search/controllers":1697618043343849928}
|
{"/home/pierre/open-cloud/oc-search/controllers":1698307784301209722}
|
23
main.go
23
main.go
@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"oc-search/controllers"
|
||||||
"oc-search/models"
|
"oc-search/models"
|
||||||
_ "oc-search/routers"
|
_ "oc-search/routers"
|
||||||
_ "oc-search/views"
|
_ "oc-search/views"
|
||||||
@ -14,6 +15,21 @@ const defaultConfigFile = "/etc/oc/search.json"
|
|||||||
const localConfigFile = "./search.json"
|
const localConfigFile = "./search.json"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
|
loadConfig()
|
||||||
|
controllers.CreateOCCatalogAPI()
|
||||||
|
|
||||||
|
beego.BConfig.WebConfig.Session.SessionOn = true
|
||||||
|
beego.SetStaticPath("/favicon.ico", "/static/favicon.ico")
|
||||||
|
beego.BConfig.WebConfig.DirectoryIndex = true
|
||||||
|
beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
|
||||||
|
|
||||||
|
beego.Run()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialising the config in the init so that the oc-catalog API receives it
|
||||||
|
|
||||||
|
func loadConfig(){
|
||||||
log := logs.NewLogger(10000)
|
log := logs.NewLogger(10000)
|
||||||
log.SetLogger("console")
|
log.SetLogger("console")
|
||||||
|
|
||||||
@ -42,10 +58,5 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
models.GetConfig().OcCatalogUrl = o.GetStringDefault("oc-catalog", "localhost:49618")
|
models.GetConfig().OcCatalogUrl = o.GetStringDefault("oc-catalog", "localhost:49618")
|
||||||
beego.BConfig.WebConfig.Session.SessionOn = true
|
logs.Info("Value for oc-catalog url : " + models.GetConfig().OcCatalogUrl)
|
||||||
beego.SetStaticPath("/favicon.ico", "/static/favicon.ico")
|
|
||||||
beego.BConfig.WebConfig.DirectoryIndex = true
|
|
||||||
beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
|
|
||||||
|
|
||||||
beego.Run()
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user