Oclib latest major version
This commit is contained in:
parent
6c05a87588
commit
b643f9c908
@ -1,6 +1,7 @@
|
|||||||
package controllers
|
package controllers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"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 +18,29 @@ 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{})
|
||||||
|
}
|
||||||
|
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-20240814062044-bfa86de5ad54 // 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
@ -108,6 +108,8 @@ cloud.o-forge.io/core/oc-lib v0.0.0-20240801071310-924a688a9d3f h1:w4KMhEFwcJrVh
|
|||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20240801071310-924a688a9d3f/go.mod h1:V5EL+NV2s9P1/BcFm3/icfLeBYVVMLl1Z0F0eecJZGo=
|
cloud.o-forge.io/core/oc-lib v0.0.0-20240801071310-924a688a9d3f/go.mod h1:V5EL+NV2s9P1/BcFm3/icfLeBYVVMLl1Z0F0eecJZGo=
|
||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20240814062044-bfa86de5ad54 h1:lUtmsGR9j4zb8L4oWPpHRZUifJIR4k35uTX8C/hXl7I=
|
cloud.o-forge.io/core/oc-lib v0.0.0-20240814062044-bfa86de5ad54 h1:lUtmsGR9j4zb8L4oWPpHRZUifJIR4k35uTX8C/hXl7I=
|
||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20240814062044-bfa86de5ad54/go.mod h1:tFM1H8v+lpHt+dTZAhYmYXu3eF+wOEd+HtcOiUbCCvQ=
|
cloud.o-forge.io/core/oc-lib v0.0.0-20240814062044-bfa86de5ad54/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=
|
||||||
@ -368,6 +370,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-workspace/routers"
|
_ "oc-workspace/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/workspace.json"
|
const defaultConfigFile = "/etc/oc/workspace.json"
|
||||||
const localConfigFile = "./docker_workspace.json"
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
configFile := ""
|
configFile := ""
|
||||||
var o *onion.Onion
|
var o *onion.Onion
|
||||||
l3 := onion.NewEnvLayerPrefix("_", "OCWORKSPACE_")
|
l3 := onion.NewEnvLayerPrefix("_", "OCWORKSPACE_")
|
||||||
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-workspace")
|
oclib.Init("oc-workspace")
|
||||||
// Normal beego init
|
// Normal beego init
|
||||||
|
BIN
oc-workspace
BIN
oc-workspace
Binary file not shown.
@ -16,6 +16,15 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
|
beego.GlobalControllerRouter["oc-workspace/controllers:VersionController"] = append(beego.GlobalControllerRouter["oc-workspace/controllers:VersionController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "Status",
|
||||||
|
Router: `/status`,
|
||||||
|
AllowHTTPMethods: []string{"get"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["oc-workspace/controllers:WorkspaceController"] = append(beego.GlobalControllerRouter["oc-workspace/controllers:WorkspaceController"],
|
beego.GlobalControllerRouter["oc-workspace/controllers:WorkspaceController"] = append(beego.GlobalControllerRouter["oc-workspace/controllers:WorkspaceController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "Post",
|
Method: "Post",
|
||||||
|
@ -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