configuration done in conf/conf.go init()

This commit is contained in:
pb
2024-02-16 10:23:22 +01:00
parent 6b67dfe729
commit 886023b2b9
3 changed files with 48 additions and 27 deletions

View File

@@ -2,6 +2,7 @@ package controllers
import (
OCCatalog_cli "oc-search/api-client/oc-catalog"
conf "oc-search/conf"
"github.com/beego/beego/logs"
beego "github.com/beego/beego/v2/server/web"
@@ -14,6 +15,11 @@ type MainController struct {
var OCCatalogAPI *OCCatalog_cli.APIClient
// This method should not be called init() because it will
// lead to the parameter BasePath to not be able to
// retrieve its value from a config file, that will
// be read after the init has happened (at import of the package)
func init() {
// OcCatalogURL := conf.GetConfig().OcCatalogUrl
@@ -22,7 +28,7 @@ func init() {
// }
// auth := context.WithValue(context.Background(), OCCatalog_cli.ContextAPIKey, OCCatalog_cli.APIKey{Key: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdXRob3JpemVkIjp0cnVlLCJleHAiOjE2MTI1OTI3MDIsInVzZXJfaWQiOiJ4ZCJ9.kTLb1FtpdnaobUpe5u9Jw8S7Cc6gf7ExmU4U3XMcC2o"})
OCCatalogAPI = OCCatalog_cli.NewAPIClient(&OCCatalog_cli.Configuration{BasePath: "http://"+ "oc-catalog:8080" +"/v1",
OCCatalogAPI = OCCatalog_cli.NewAPIClient(&OCCatalog_cli.Configuration{BasePath: "http://"+ conf.GetConfig().OcCatalogUrl +"/v1",
DefaultHeader: map[string]string{
"authorization": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdXRob3JpemVkIjp0cnVlLCJleHAiOjE2MTMwMDI0NjAsInVzZXJfaWQiOiJhc2QifQ.TXT18aeulnCrtedKKFVaD0BapOTdVAFcJJdVS7zk0I8",
},