Swagger returning only 404s

This commit is contained in:
pb 2024-02-15 10:52:29 +01:00
parent c8508a4976
commit f77d2bc8cf
9 changed files with 32 additions and 27 deletions

View File

@ -9,9 +9,15 @@ RUN go get github.com/beego/bee/v2 && go install github.com/beego/bee/v2@master
# Generating the swagger # Generating the swagger
RUN timeout 20 bee run -gendoc=true -downdoc=true -runmode=dev || : RUN timeout 20 bee run -gendoc=true -downdoc=true -runmode=dev || :
RUN ls swagger/
RUN sed -i 's/http:\/\/127.0.0.1:8080\/swagger\/swagger.json/swagger.json/g' swagger/index.html RUN sed -i 's/http:\/\/127.0.0.1:8080\/swagger\/swagger.json/swagger.json/g' swagger/index.html
RUN sed -i 's/https:\/\/petstore.swagger.io\/v2\/swagger.json/swagger.json/g' swagger/index.html RUN sed -i 's/https:\/\/petstore.swagger.io\/v2\/swagger.json/swagger.json/g' swagger/index.html
RUN echo '------------------------------------------------------------'
RUN cat 'swagger/index.html'
RUN echo '------------------------------------------------------------'
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" . RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" .
FROM scratch FROM scratch

View File

@ -2,7 +2,7 @@ version: '3.4'
services: services:
oc-catalog: oc-catalog:
image: oc-catalog:latest image: oc-catalog:debugging
restart: always restart: always
environment: environment:
- DOCKER_DCNAME=DC_myDC - DOCKER_DCNAME=DC_myDC

View File

@ -21,6 +21,9 @@ services:
- catalog - catalog
ports: ports:
- 8081:8081 - 8081:8081
environment:
- ME_CONFIG_BASICAUTH_USERNAME=test
- ME_CONFIG_BASICAUTH_PASSWORD=test
volumes: volumes:
oc-catalog-data: oc-catalog-data:

5
docker_catalog.json Normal file
View File

@ -0,0 +1,5 @@
{
"MongoURL" : "mongodb://mongo:27017/",
"DCNAME" : "DC_myDC",
"DBPOINT" : "demo_06042021"
}

5
local_catalog.json Normal file
View File

@ -0,0 +1,5 @@
{
"MongoURL" : "mongodb://127.0.0.1:27017/",
"DCNAME" : "DC_myDC",
"DBPOINT" : "demo_06042021"
}

View File

@ -75,6 +75,6 @@ func loadConfig(){
conf.GetConfig().MongoURL = o.GetStringDefault("MongoURL", "mongodb://127.0.0.1:27017") conf.GetConfig().MongoURL = o.GetStringDefault("MongoURL", "mongodb://127.0.0.1:27017")
conf.GetConfig().DCNAME = o.GetStringDefault("DCNAME", "DC_myDC") conf.GetConfig().DCNAME = o.GetStringDefault("DCNAME", "DC_myDC")
conf.GetConfig().DBPOINT = o.GetStringDefault("DBPOINT", "demdemo_06042021o") conf.GetConfig().DBPOINT = o.GetStringDefault("DBPOINT", "demo_06042021")
} }

View File

@ -79,14 +79,13 @@ func Init() {
), ),
) )
beego.AddNamespace(ns) beego.AddNamespace(ns)
beego.Get("/", func(ctx *context.Context) { beego.Get("/", func(ctx *context.Context) {
ctx.Output.Body([]byte(services.DC_NAME)) ctx.Output.Body([]byte(services.DC_NAME))
}) })
// Force regenerate swagger before consuming the data // Force regenerate swagger before consuming the data
// bee.GenerateDocs(".") // bee.GenerateDocs(".")
// Open our jsonFile // Open our jsonFile

View File

@ -2,43 +2,29 @@ package services
import ( import (
"cloud.o-forge.io/core/oc-catalog/conf" "cloud.o-forge.io/core/oc-catalog/conf"
"github.com/beego/beego/v2/core/logs"
) )
func Init() { func Init() {
// Discoveryinit() //First init DC name // Discoveryinit() //First init DC name
config := conf.GetConfig() // var DBpoint string
// var err error
var DBpoint string DCName := conf.GetConfig().DCNAME
var DC_NAME string DBPoint := conf.GetConfig().DBPOINT
var err error
DC_NAME = config.DCNAME
if len(DC_NAME) == 0 {
logs.Critical("DC_NAME URI error: %v", err)
panic(err)
}
DBpoint = config.DBPOINT
if len(DBpoint) == 0 {
logs.Critical("DBPOINT URI error: %v", err)
panic(err)
}
// DBpoint = os.Getenv("DOCKER_DBPOINT")
// if len(DBpoint) == 0 { // if len(DBpoint) == 0 {
// DBpoint, err = beego.AppConfig.String("DBPOINT") // DBpoint, err = beego.AppConfig.String("DBPOINT")
// if err != nil { // if err != nil {
// logs.Critical("DBPOINT URI error: %v", err) // logs.Critical("DBPOINT URI error: %v", err)
// panic(err) // panic(err)
// } // }
// } // }
logs.Debug("connecting to datacenter db : " + DC_NAME + "-" + DBpoint) // Mongoinit(DC_NAME + "-" + DBpoint)
Mongoinit(DC_NAME + "-" + DBpoint) Mongoinit(DCName + "-" + DBPoint )
// Mongoinit("beego-demo")
} }

View File

@ -98,6 +98,7 @@ func Mongoinit(DBname string) {
panic(err) panic(err)
} }
logs.Info("Connecting mongo client to db %v", DBname)
mngoDB = mngoClient.Database(DBname) mngoDB = mngoClient.Database(DBname)
MngoCollData = mngoDB.Collection(MngoNamesCollection.DATA) MngoCollData = mngoDB.Collection(MngoNamesCollection.DATA)