oclib latest major version
This commit is contained in:
parent
62c2d7bb23
commit
205b89de9e
@ -1,6 +1,8 @@
|
|||||||
package controllers
|
package controllers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
oclib "cloud.o-forge.io/core/oc-lib"
|
||||||
|
"cloud.o-forge.io/core/oc-lib/tools"
|
||||||
beego "github.com/beego/beego/v2/server/web"
|
beego "github.com/beego/beego/v2/server/web"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -17,3 +19,32 @@ func (c *VersionController) GetAll() {
|
|||||||
c.Data["json"] = map[string]string{"version": "1"}
|
c.Data["json"] = map[string]string{"version": "1"}
|
||||||
c.ServeJSON()
|
c.ServeJSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Title Status
|
||||||
|
// @Description get status
|
||||||
|
// @Success 200
|
||||||
|
// @router /status [get]
|
||||||
|
func (c *VersionController) Status() {
|
||||||
|
errStr := ""
|
||||||
|
api := tools.API{}
|
||||||
|
state, code, err := api.GetState()
|
||||||
|
|
||||||
|
if state == tools.ALIVE {
|
||||||
|
state, _, err = api.CheckRemoteAPIs([]string{
|
||||||
|
"http://" + oclib.LibDataEnum(oclib.WORKSPACE).String() + oclib.GetPath(oclib.LibDataEnum(oclib.WORKSPACE)),
|
||||||
|
"http://" + oclib.LibDataEnum(oclib.WORKFLOW).String() + oclib.GetPath(oclib.LibDataEnum(oclib.WORKFLOW)),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
errStr = err.Error()
|
||||||
|
}
|
||||||
|
c.Data["json"] = map[string]interface{}{
|
||||||
|
"data": map[string]interface{}{
|
||||||
|
"state": state.String(),
|
||||||
|
"code": state,
|
||||||
|
},
|
||||||
|
"error": errStr,
|
||||||
|
"code": code,
|
||||||
|
}
|
||||||
|
c.ServeJSON()
|
||||||
|
}
|
||||||
|
5
go.mod
5
go.mod
@ -11,7 +11,7 @@ require (
|
|||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20240813084212-4911e32ec215 // indirect
|
cloud.o-forge.io/core/oc-lib v0.0.0-20240821093044-f64563c9ff06 // indirect
|
||||||
filippo.io/edwards25519 v1.1.0 // indirect
|
filippo.io/edwards25519 v1.1.0 // indirect
|
||||||
github.com/beego/bee/v2 v2.1.0 // indirect
|
github.com/beego/bee/v2 v2.1.0 // indirect
|
||||||
github.com/beorn7/perks v1.0.1 // indirect
|
github.com/beorn7/perks v1.0.1 // indirect
|
||||||
@ -50,6 +50,9 @@ require (
|
|||||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||||
github.com/montanaflynn/stats v0.7.1 // indirect
|
github.com/montanaflynn/stats v0.7.1 // indirect
|
||||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||||
|
github.com/nats-io/nats.go v1.37.0 // indirect
|
||||||
|
github.com/nats-io/nkeys v0.4.7 // indirect
|
||||||
|
github.com/nats-io/nuid v1.0.1 // indirect
|
||||||
github.com/pelletier/go-toml v1.9.5 // indirect
|
github.com/pelletier/go-toml v1.9.5 // indirect
|
||||||
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
|
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
|
||||||
github.com/prometheus/client_golang v1.19.1 // indirect
|
github.com/prometheus/client_golang v1.19.1 // indirect
|
||||||
|
8
go.sum
8
go.sum
@ -114,6 +114,8 @@ cloud.o-forge.io/core/oc-lib v0.0.0-20240813082955-3962b7c7aa52 h1:za+jN2MkDfi/H
|
|||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20240813082955-3962b7c7aa52/go.mod h1:tFM1H8v+lpHt+dTZAhYmYXu3eF+wOEd+HtcOiUbCCvQ=
|
cloud.o-forge.io/core/oc-lib v0.0.0-20240813082955-3962b7c7aa52/go.mod h1:tFM1H8v+lpHt+dTZAhYmYXu3eF+wOEd+HtcOiUbCCvQ=
|
||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20240813084212-4911e32ec215 h1:Ra1RbFC41IFxJa38krCOHqWcTZvHj8W7FDPKcGnDIuw=
|
cloud.o-forge.io/core/oc-lib v0.0.0-20240813084212-4911e32ec215 h1:Ra1RbFC41IFxJa38krCOHqWcTZvHj8W7FDPKcGnDIuw=
|
||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20240813084212-4911e32ec215/go.mod h1:tFM1H8v+lpHt+dTZAhYmYXu3eF+wOEd+HtcOiUbCCvQ=
|
cloud.o-forge.io/core/oc-lib v0.0.0-20240813084212-4911e32ec215/go.mod h1:tFM1H8v+lpHt+dTZAhYmYXu3eF+wOEd+HtcOiUbCCvQ=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20240821093044-f64563c9ff06 h1:sYveE1C/0mpSr+ZmOYxuZ3fTWID7mr5hPiq0jQenv3Q=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20240821093044-f64563c9ff06/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
|
||||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||||
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
||||||
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
||||||
@ -374,6 +376,12 @@ github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt
|
|||||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
|
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
|
||||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
||||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||||
|
github.com/nats-io/nats.go v1.37.0 h1:07rauXbVnnJvv1gfIyghFEo6lUcYRY0WXc3x7x0vUxE=
|
||||||
|
github.com/nats-io/nats.go v1.37.0/go.mod h1:Ubdu4Nh9exXdSz0RVWRFBbRfrbSxOYd26oF0wkWclB8=
|
||||||
|
github.com/nats-io/nkeys v0.4.7 h1:RwNJbbIdYCoClSDNY7QVKZlyb/wfT6ugvFCiKy6vDvI=
|
||||||
|
github.com/nats-io/nkeys v0.4.7/go.mod h1:kqXRgRDPlGy7nGaEDMuYzmiJCIAAWDK0IMBtDmGD0nc=
|
||||||
|
github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw=
|
||||||
|
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
|
||||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||||
github.com/ogier/pflag v0.0.1/go.mod h1:zkFki7tvTa0tafRvTBIZTvzYyAu6kQhPZFnshFFPE+g=
|
github.com/ogier/pflag v0.0.1/go.mod h1:zkFki7tvTa0tafRvTBIZTvzYyAu6kQhPZFnshFFPE+g=
|
||||||
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
|
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
|
||||||
|
20
main.go
20
main.go
@ -1,43 +1,33 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
_ "oc-shared/routers"
|
_ "oc-shared/routers"
|
||||||
|
|
||||||
oclib "cloud.o-forge.io/core/oc-lib"
|
oclib "cloud.o-forge.io/core/oc-lib"
|
||||||
|
"cloud.o-forge.io/core/oc-lib/tools"
|
||||||
beego "github.com/beego/beego/v2/server/web"
|
beego "github.com/beego/beego/v2/server/web"
|
||||||
"github.com/goraz/onion"
|
"github.com/goraz/onion"
|
||||||
)
|
)
|
||||||
|
|
||||||
const defaultConfigFile = "/etc/oc/shared.json"
|
const defaultConfigFile = "/etc/oc/shared.json"
|
||||||
const localConfigFile = "./docker_shared.json"
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
configFile := ""
|
configFile := ""
|
||||||
var o *onion.Onion
|
var o *onion.Onion
|
||||||
l3 := onion.NewEnvLayerPrefix("_", "OCSHARED_")
|
l3 := onion.NewEnvLayerPrefix("_", "OCSHARED_")
|
||||||
l1, err := onion.NewFileLayer(localConfigFile, nil)
|
|
||||||
if err == nil {
|
|
||||||
configFile = localConfigFile
|
|
||||||
}
|
|
||||||
l2, err := onion.NewFileLayer(defaultConfigFile, nil)
|
l2, err := onion.NewFileLayer(defaultConfigFile, nil)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
configFile = defaultConfigFile
|
configFile = defaultConfigFile
|
||||||
}
|
}
|
||||||
if configFile == "" {
|
if configFile == "" || l2 == nil {
|
||||||
o = onion.New(l3)
|
o = onion.New(l3)
|
||||||
} else if l1 == nil && l2 == nil {
|
} else {
|
||||||
o = onion.New(l1, l2, l3)
|
|
||||||
} else if l1 == nil {
|
|
||||||
o = onion.New(l2, l3)
|
o = onion.New(l2, l3)
|
||||||
} else if l2 == nil {
|
|
||||||
o = onion.New(l1, l3)
|
|
||||||
}
|
}
|
||||||
fmt.Println("BSLDMqlkd", o.GetStringDefault("MONGO_URL", "mongodb://127.0.0.1:27017"),
|
tools.SetConfig(
|
||||||
o.GetStringDefault("MONGO_DATABASE", "DC_myDC"))
|
|
||||||
oclib.SetConfig(
|
|
||||||
o.GetStringDefault("MONGO_URL", "mongodb://127.0.0.1:27017"),
|
o.GetStringDefault("MONGO_URL", "mongodb://127.0.0.1:27017"),
|
||||||
o.GetStringDefault("MONGO_DATABASE", "DC_myDC"),
|
o.GetStringDefault("MONGO_DATABASE", "DC_myDC"),
|
||||||
|
"",
|
||||||
)
|
)
|
||||||
oclib.Init("oc-shared")
|
oclib.Init("oc-shared")
|
||||||
oclib.AddPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), o.GetStringDefault("SHARED_WORKSPACE_URL", ":8091"))
|
oclib.AddPath(oclib.LibDataEnum(oclib.SHARED_WORKSPACE), o.GetStringDefault("SHARED_WORKSPACE_URL", ":8091"))
|
||||||
|
@ -124,4 +124,13 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
|
beego.GlobalControllerRouter["oc-shared/controllers:VersionController"] = append(beego.GlobalControllerRouter["oc-shared/controllers:VersionController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "Status",
|
||||||
|
Router: `/status`,
|
||||||
|
AllowHTTPMethods: []string{"get"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,20 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/version/status": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"version"
|
||||||
|
],
|
||||||
|
"description": "get status\n\u003cbr\u003e",
|
||||||
|
"operationId": "VersionController.Status",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/workspace/": {
|
"/workspace/": {
|
||||||
"get": {
|
"get": {
|
||||||
"tags": [
|
"tags": [
|
||||||
|
@ -23,6 +23,17 @@ paths:
|
|||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: ""
|
description: ""
|
||||||
|
/version/status:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- version
|
||||||
|
description: |-
|
||||||
|
get status
|
||||||
|
<br>
|
||||||
|
operationId: VersionController.Status
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: ""
|
||||||
/workspace/:
|
/workspace/:
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
|
Loading…
Reference in New Issue
Block a user