Not reaching catalog
This commit is contained in:
parent
2fd85737d1
commit
5004dc9b06
@ -32,7 +32,7 @@ COPY scripts scripts
|
||||
|
||||
# Configuration file : aims at making your variables suit your environment (local, docker, prod, etc)
|
||||
|
||||
COPY local_search.json /etc/oc/search.json
|
||||
COPY docker_search.json /etc/oc/search.json
|
||||
|
||||
# FROM golang
|
||||
|
||||
|
17
conf/conf.go
Normal file
17
conf/conf.go
Normal file
@ -0,0 +1,17 @@
|
||||
package conf
|
||||
|
||||
import "sync"
|
||||
|
||||
type Config struct {
|
||||
OcCatalogUrl string
|
||||
}
|
||||
|
||||
var instance *Config
|
||||
var once sync.Once
|
||||
|
||||
func GetConfig() *Config {
|
||||
once.Do(func() {
|
||||
instance = &Config{}
|
||||
})
|
||||
return instance
|
||||
}
|
@ -3,6 +3,7 @@ package controllers
|
||||
import (
|
||||
OCCatalog_cli "oc-search/api-client/oc-catalog"
|
||||
|
||||
"github.com/beego/beego/logs"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
@ -14,8 +15,14 @@ type MainController struct {
|
||||
var OCCatalogAPI *OCCatalog_cli.APIClient
|
||||
|
||||
func init() {
|
||||
|
||||
// OcCatalogURL := conf.GetConfig().OcCatalogUrl
|
||||
// if OcCatalogURL == "" {
|
||||
// panic("OcCatalogUrl is blank")
|
||||
// }
|
||||
|
||||
// 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://"+ "oc-catalog:8080" +"/v1",
|
||||
DefaultHeader: map[string]string{
|
||||
"authorization": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdXRob3JpemVkIjp0cnVlLCJleHAiOjE2MTMwMDI0NjAsInVzZXJfaWQiOiJhc2QifQ.TXT18aeulnCrtedKKFVaD0BapOTdVAFcJJdVS7zk0I8",
|
||||
},
|
||||
@ -25,6 +32,9 @@ func init() {
|
||||
|
||||
// Get provides the main page
|
||||
func (c *MainController) Get() {
|
||||
|
||||
logs.Debug("received : %v",c.Ctx.Input.RequestBody)
|
||||
|
||||
c.Data["Website"] = "beego.me"
|
||||
c.Data["Email"] = "astaxie@gmail.com"
|
||||
c.TplName = "index.tpl"
|
||||
|
@ -35,6 +35,10 @@ func loadSingleFile(filename string) []models.Resource {
|
||||
|
||||
// Get implements simple search
|
||||
func (c *SearchController) Get() {
|
||||
|
||||
logs.Debug("received : %v",c.Ctx.Input.RequestBody)
|
||||
|
||||
|
||||
query := c.GetString("q")
|
||||
|
||||
var resources OCCatalog_cli.ModelsSearchResult
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/beego/beego/logs"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
"github.com/sbabiv/xml2map"
|
||||
)
|
||||
@ -19,6 +20,8 @@ type WorkflowController struct {
|
||||
// Get i
|
||||
func (c *WorkflowController) Get() {
|
||||
|
||||
logs.Debug("received : %v",c.Ctx.Input.RequestBody)
|
||||
|
||||
c.Data["Website"] = "beego.me"
|
||||
c.Data["Email"] = "astaxie@gmail.com"
|
||||
c.TplName = "workflow.tpl"
|
||||
|
@ -2,7 +2,7 @@ version: '3.4'
|
||||
|
||||
services:
|
||||
oc-search:
|
||||
build: .
|
||||
image: oc-search:debugging
|
||||
container_name: oc-search
|
||||
ports:
|
||||
- 8080:8080
|
||||
|
3
docker_search.json
Normal file
3
docker_search.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"oc-catalog" : "catalog:49618"
|
||||
}
|
3
local_search.json
Normal file
3
local_search.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"oc-catalog" : "localhost:49618"
|
||||
}
|
10
main.go
10
main.go
@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"oc-search/models"
|
||||
conf "oc-search/conf"
|
||||
_ "oc-search/routers"
|
||||
_ "oc-search/views"
|
||||
|
||||
@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
const defaultConfigFile = "/etc/oc/search.json"
|
||||
const localConfigFile = "./search.json"
|
||||
const localConfigFile = "./local_search.json"
|
||||
|
||||
func main() {
|
||||
log := logs.NewLogger(10000)
|
||||
@ -19,7 +19,7 @@ func main() {
|
||||
|
||||
configFile := ""
|
||||
var o *onion.Onion
|
||||
l3 := onion.NewEnvLayerPrefix("_", "OCDISCOVERY_")
|
||||
l3 := onion.NewEnvLayerPrefix("_", "OCSEARCH_")
|
||||
l2, err := onion.NewFileLayer(defaultConfigFile, nil)
|
||||
if err == nil {
|
||||
logs.Info("Config file found : " + defaultConfigFile)
|
||||
@ -41,11 +41,13 @@ func main() {
|
||||
o = onion.New(l1, l3)
|
||||
}
|
||||
|
||||
models.GetConfig().OcCatalogUrl = o.GetStringDefault("oc-catalog", "localhost:49618")
|
||||
conf.GetConfig().OcCatalogUrl = o.GetStringDefault("oc-catalog", "localhost:49618")
|
||||
beego.BConfig.WebConfig.Session.SessionOn = true
|
||||
beego.SetStaticPath("/favicon.ico", "/static/favicon.ico")
|
||||
beego.BConfig.WebConfig.DirectoryIndex = true
|
||||
beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
|
||||
|
||||
logs.Info("Will contact oc-catalog at : %v", conf.GetConfig().OcCatalogUrl)
|
||||
|
||||
beego.Run()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user