diff --git a/controllers/version.go b/controllers/version.go index b1522ae..6b08805 100644 --- a/controllers/version.go +++ b/controllers/version.go @@ -1,7 +1,7 @@ package controllers import ( - "cloud.o-forge.io/core/oc-lib/tools" + tools "cloud.o-forge.io/core/oc-lib/tools" beego "github.com/beego/beego/v2/server/web" ) @@ -24,18 +24,22 @@ func (c *VersionController) GetAll() { // @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": err.Error(), + "error": errStr, "code": code, } c.ServeJSON() diff --git a/go.mod b/go.mod index 0046513..7a2c7d2 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( ) require ( - cloud.o-forge.io/core/oc-lib v0.0.0-20240807165025-9040d141c8ca // indirect + cloud.o-forge.io/core/oc-lib v0.0.0-20240821093044-f64563c9ff06 // indirect filippo.io/edwards25519 v1.1.0 // indirect github.com/beego/bee/v2 v2.1.0 // indirect github.com/beorn7/perks v1.0.1 // indirect @@ -50,6 +50,9 @@ require ( github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/montanaflynn/stats v0.7.1 // 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/v2 v2.2.2 // indirect github.com/prometheus/client_golang v1.19.1 // indirect @@ -57,6 +60,7 @@ require ( github.com/prometheus/common v0.55.0 // indirect github.com/prometheus/procfs v0.15.1 // indirect github.com/rivo/uniseg v0.4.7 // indirect + github.com/robfig/cron/v3 v3.0.1 // indirect github.com/rs/zerolog v1.33.0 // indirect github.com/sagikazarmark/locafero v0.6.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect diff --git a/go.sum b/go.sum index 39ee5fe..daee2be 100644 --- a/go.sum +++ b/go.sum @@ -136,6 +136,8 @@ cloud.o-forge.io/core/oc-lib v0.0.0-20240801093327-c3e6f04dd89a h1:NLFcAtK2mTi26 cloud.o-forge.io/core/oc-lib v0.0.0-20240801093327-c3e6f04dd89a/go.mod h1:V5EL+NV2s9P1/BcFm3/icfLeBYVVMLl1Z0F0eecJZGo= cloud.o-forge.io/core/oc-lib v0.0.0-20240807165025-9040d141c8ca h1:Cc4kj+Aj2PRzC+1SFvwD/nichwWrerK2evwIn/KFoFk= cloud.o-forge.io/core/oc-lib v0.0.0-20240807165025-9040d141c8ca/go.mod h1:V5EL+NV2s9P1/BcFm3/icfLeBYVVMLl1Z0F0eecJZGo= +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= filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= @@ -396,6 +398,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/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= 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/ogier/pflag v0.0.1/go.mod h1:zkFki7tvTa0tafRvTBIZTvzYyAu6kQhPZFnshFFPE+g= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= @@ -444,6 +452,8 @@ github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= +github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= +github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= diff --git a/oc-catalog b/oc-catalog deleted file mode 100755 index 43bcbc3..0000000 Binary files a/oc-catalog and /dev/null differ diff --git a/routers/commentsRouter.go b/routers/commentsRouter.go index 47da015..4539406 100644 --- a/routers/commentsRouter.go +++ b/routers/commentsRouter.go @@ -268,6 +268,15 @@ func init() { Filters: nil, Params: nil}) + beego.GlobalControllerRouter["oc-catalog/controllers:VersionController"] = append(beego.GlobalControllerRouter["oc-catalog/controllers:VersionController"], + beego.ControllerComments{ + Method: "Status", + Router: `/status`, + AllowHTTPMethods: []string{"get"}, + MethodParams: param.Make(), + Filters: nil, + Params: nil}) + beego.GlobalControllerRouter["oc-catalog/controllers:WorkflowController"] = append(beego.GlobalControllerRouter["oc-catalog/controllers:WorkflowController"], beego.ControllerComments{ Method: "Post", diff --git a/swagger/swagger.json b/swagger/swagger.json index 2069ec8..ba709f1 100644 --- a/swagger/swagger.json +++ b/swagger/swagger.json @@ -646,6 +646,20 @@ } } }, + "/version/status": { + "get": { + "tags": [ + "version" + ], + "description": "get status\n\u003cbr\u003e", + "operationId": "VersionController.Status", + "responses": { + "200": { + "description": "" + } + } + } + }, "/workflow/": { "get": { "tags": [ diff --git a/swagger/swagger.yml b/swagger/swagger.yml index d4f1add..8ea3bad 100644 --- a/swagger/swagger.yml +++ b/swagger/swagger.yml @@ -484,6 +484,17 @@ paths: responses: "200": description: "" + /version/status: + get: + tags: + - version + description: |- + get status +
+ operationId: VersionController.Status + responses: + "200": + description: "" /workflow/: get: tags: