shared new oclib + routers

This commit is contained in:
mr 2024-08-22 10:49:26 +02:00
parent 5b75ed0473
commit a5a86f44c5
7 changed files with 260 additions and 264 deletions

View File

@ -1,7 +1,6 @@
package controllers package controllers
import ( import (
oclib "cloud.o-forge.io/core/oc-lib"
"cloud.o-forge.io/core/oc-lib/tools" "cloud.o-forge.io/core/oc-lib/tools"
beego "github.com/beego/beego/v2/server/web" beego "github.com/beego/beego/v2/server/web"
) )
@ -28,13 +27,6 @@ func (c *VersionController) Status() {
errStr := "" errStr := ""
api := tools.API{} api := tools.API{}
state, code, err := api.GetState() 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 { if err != nil {
errStr = err.Error() errStr = err.Error()
} }

2
go.mod
View File

@ -11,7 +11,7 @@ require (
) )
require ( require (
cloud.o-forge.io/core/oc-lib v0.0.0-20240821093044-f64563c9ff06 // indirect cloud.o-forge.io/core/oc-lib v0.0.0-20240822065024-fb80e05d6a7b // 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

4
go.sum
View File

@ -116,6 +116,10 @@ cloud.o-forge.io/core/oc-lib v0.0.0-20240813084212-4911e32ec215 h1:Ra1RbFC41IFxJ
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 h1:sYveE1C/0mpSr+ZmOYxuZ3fTWID7mr5hPiq0jQenv3Q=
cloud.o-forge.io/core/oc-lib v0.0.0-20240821093044-f64563c9ff06/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU= cloud.o-forge.io/core/oc-lib v0.0.0-20240821093044-f64563c9ff06/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
cloud.o-forge.io/core/oc-lib v0.0.0-20240821140757-39030a0a80e8 h1:y4hngS1bedPKYXecTCcZk2WkuQNFazD11rMng9dmIzI=
cloud.o-forge.io/core/oc-lib v0.0.0-20240821140757-39030a0a80e8/go.mod h1:1hhYh5QWAbYw9cKplQ0ZD9PMgU8t6gPqiYF8sldv1HU=
cloud.o-forge.io/core/oc-lib v0.0.0-20240822065024-fb80e05d6a7b h1:A7NBwTXoHTg/oDbnxnnSdiT85kZY4VvhcbUeb3q7Irk=
cloud.o-forge.io/core/oc-lib v0.0.0-20240822065024-fb80e05d6a7b/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=

BIN
oc-shared

Binary file not shown.

View File

@ -14,13 +14,13 @@ import (
) )
func init() { func init() {
ns := beego.NewNamespace("/oc/shared/", ns := beego.NewNamespace("/oc",
beego.NSNamespace("/workspace", beego.NSNamespace("/shared/workspace",
beego.NSInclude( beego.NSInclude(
&controllers.SharedWorkspaceController{}, &controllers.SharedWorkspaceController{},
), ),
), ),
beego.NSNamespace("/workspace/rule", beego.NSNamespace("/shared/workspace/rule",
beego.NSInclude( beego.NSInclude(
&controllers.RuleController{}, &controllers.RuleController{},
), ),

View File

@ -13,40 +13,12 @@
"url": "http://www.apache.org/licenses/LICENSE-2.0.html" "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
} }
}, },
"basePath": "/oc/shared/", "basePath": "/oc",
"paths": { "paths": {
"/version/": { "/shared/workspace/": {
"get": { "get": {
"tags": [ "tags": [
"version" "shared/workspace"
],
"description": "get version\n\u003cbr\u003e",
"operationId": "VersionController.GetAll",
"responses": {
"200": {
"description": ""
}
}
}
},
"/version/status": {
"get": {
"tags": [
"version"
],
"description": "get status\n\u003cbr\u003e",
"operationId": "VersionController.Status",
"responses": {
"200": {
"description": ""
}
}
}
},
"/workspace/": {
"get": {
"tags": [
"workspace"
], ],
"description": "find shared workspace by id\n\u003cbr\u003e", "description": "find shared workspace by id\n\u003cbr\u003e",
"operationId": "SharedWorkspaceController.GetAll", "operationId": "SharedWorkspaceController.GetAll",
@ -58,7 +30,7 @@
}, },
"post": { "post": {
"tags": [ "tags": [
"workspace" "shared/workspace"
], ],
"description": "create shared workspace\n\u003cbr\u003e", "description": "create shared workspace\n\u003cbr\u003e",
"operationId": "SharedWorkspaceController.Create", "operationId": "SharedWorkspaceController.Create",
@ -80,10 +52,10 @@
} }
} }
}, },
"/workspace/rule/": { "/shared/workspace/rule/": {
"get": { "get": {
"tags": [ "tags": [
"workspace/rule" "shared/workspace/rule"
], ],
"description": "find rule by id\n\u003cbr\u003e", "description": "find rule by id\n\u003cbr\u003e",
"operationId": "RuleController.GetAll", "operationId": "RuleController.GetAll",
@ -95,7 +67,7 @@
}, },
"post": { "post": {
"tags": [ "tags": [
"workspace/rule" "shared/workspace/rule"
], ],
"description": "create rule\n\u003cbr\u003e", "description": "create rule\n\u003cbr\u003e",
"operationId": "RuleController.Create", "operationId": "RuleController.Create",
@ -117,10 +89,10 @@
} }
} }
}, },
"/workspace/rule/search/{search}": { "/shared/workspace/rule/search/{search}": {
"get": { "get": {
"tags": [ "tags": [
"workspace/rule" "shared/workspace/rule"
], ],
"description": "search rule\n\u003cbr\u003e", "description": "search rule\n\u003cbr\u003e",
"operationId": "RuleController.Search", "operationId": "RuleController.Search",
@ -140,10 +112,10 @@
} }
} }
}, },
"/workspace/rule/{id}": { "/shared/workspace/rule/{id}": {
"get": { "get": {
"tags": [ "tags": [
"workspace/rule" "shared/workspace/rule"
], ],
"description": "find rule by id\n\u003cbr\u003e", "description": "find rule by id\n\u003cbr\u003e",
"operationId": "RuleController.Get", "operationId": "RuleController.Get",
@ -164,7 +136,7 @@
}, },
"put": { "put": {
"tags": [ "tags": [
"workspace/rule" "shared/workspace/rule"
], ],
"description": "create rules\n\u003cbr\u003e", "description": "create rules\n\u003cbr\u003e",
"operationId": "RuleController.Update", "operationId": "RuleController.Update",
@ -194,7 +166,7 @@
}, },
"delete": { "delete": {
"tags": [ "tags": [
"workspace/rule" "shared/workspace/rule"
], ],
"description": "delete the rule\n\u003cbr\u003e", "description": "delete the rule\n\u003cbr\u003e",
"operationId": "RuleController.Delete", "operationId": "RuleController.Delete",
@ -214,10 +186,10 @@
} }
} }
}, },
"/workspace/search/{search}": { "/shared/workspace/search/{search}": {
"get": { "get": {
"tags": [ "tags": [
"workspace" "shared/workspace"
], ],
"description": "search shared workspace\n\u003cbr\u003e", "description": "search shared workspace\n\u003cbr\u003e",
"operationId": "SharedWorkspaceController.Search", "operationId": "SharedWorkspaceController.Search",
@ -237,10 +209,10 @@
} }
} }
}, },
"/workspace/{id}": { "/shared/workspace/{id}": {
"get": { "get": {
"tags": [ "tags": [
"workspace" "shared/workspace"
], ],
"description": "find shared workspace by id\n\u003cbr\u003e", "description": "find shared workspace by id\n\u003cbr\u003e",
"operationId": "SharedWorkspaceController.Get", "operationId": "SharedWorkspaceController.Get",
@ -261,7 +233,7 @@
}, },
"put": { "put": {
"tags": [ "tags": [
"workspace" "shared/workspace"
], ],
"description": "create shared workspaces\n\u003cbr\u003e", "description": "create shared workspaces\n\u003cbr\u003e",
"operationId": "SharedWorkspaceController.Update", "operationId": "SharedWorkspaceController.Update",
@ -291,7 +263,7 @@
}, },
"delete": { "delete": {
"tags": [ "tags": [
"workspace" "shared/workspace"
], ],
"description": "delete the shared workspace\n\u003cbr\u003e", "description": "delete the shared workspace\n\u003cbr\u003e",
"operationId": "SharedWorkspaceController.Delete", "operationId": "SharedWorkspaceController.Delete",
@ -310,6 +282,34 @@
} }
} }
} }
},
"/version/": {
"get": {
"tags": [
"version"
],
"description": "get version\n\u003cbr\u003e",
"operationId": "VersionController.GetAll",
"responses": {
"200": {
"description": ""
}
}
}
},
"/version/status": {
"get": {
"tags": [
"version"
],
"description": "get status\n\u003cbr\u003e",
"operationId": "VersionController.Status",
"responses": {
"200": {
"description": ""
}
}
}
} }
}, },
"definitions": { "definitions": {
@ -328,11 +328,11 @@
}, },
"tags": [ "tags": [
{ {
"name": "workspace", "name": "shared/workspace",
"description": "Operations about workspace\n" "description": "Operations about workspace\n"
}, },
{ {
"name": "workspace/rule", "name": "shared/workspace/rule",
"description": "Operations about rule\n" "description": "Operations about rule\n"
}, },
{ {

View File

@ -10,8 +10,208 @@ info:
license: license:
name: Apache 2.0 name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html url: http://www.apache.org/licenses/LICENSE-2.0.html
basePath: /oc/shared/ basePath: /oc
paths: paths:
/shared/workspace/:
get:
tags:
- shared/workspace
description: |-
find shared workspace by id
<br>
operationId: SharedWorkspaceController.GetAll
responses:
"200":
description: '{shared_workspace} models.shared_workspace'
post:
tags:
- shared/workspace
description: |-
create shared workspace
<br>
operationId: SharedWorkspaceController.Create
parameters:
- in: body
name: data
description: body for data content (Json format)
required: true
schema:
$ref: '#/definitions/json'
responses:
"200":
description: '{shared workspace} models.shared_workspace'
/shared/workspace/{id}:
get:
tags:
- shared/workspace
description: |-
find shared workspace by id
<br>
operationId: SharedWorkspaceController.Get
parameters:
- in: path
name: id
description: the id you want to get
required: true
type: string
responses:
"200":
description: '{shared workspace} models.shared_workspace'
put:
tags:
- shared/workspace
description: |-
create shared workspaces
<br>
operationId: SharedWorkspaceController.Update
parameters:
- in: path
name: id
description: the shared workspace id you want to get
required: true
type: string
- in: body
name: body
description: The shared workspace content
required: true
schema:
$ref: '#/definitions/models.workspace'
responses:
"200":
description: '{shared workspace} models.shared_workspace'
delete:
tags:
- shared/workspace
description: |-
delete the shared workspace
<br>
operationId: SharedWorkspaceController.Delete
parameters:
- in: path
name: id
description: The id you want to delete
required: true
type: string
responses:
"200":
description: '{shared workspace} delete success!'
/shared/workspace/rule/:
get:
tags:
- shared/workspace/rule
description: |-
find rule by id
<br>
operationId: RuleController.GetAll
responses:
"200":
description: '{rule} models.rule'
post:
tags:
- shared/workspace/rule
description: |-
create rule
<br>
operationId: RuleController.Create
parameters:
- in: body
name: data
description: body for data content (Json format)
required: true
schema:
$ref: '#/definitions/json'
responses:
"200":
description: '{rule} models.rule'
/shared/workspace/rule/{id}:
get:
tags:
- shared/workspace/rule
description: |-
find rule by id
<br>
operationId: RuleController.Get
parameters:
- in: path
name: id
description: the id you want to get
required: true
type: string
responses:
"200":
description: '{rule} models.rule'
put:
tags:
- shared/workspace/rule
description: |-
create rules
<br>
operationId: RuleController.Update
parameters:
- in: path
name: id
description: the rule id you want to get
required: true
type: string
- in: body
name: body
description: The rule content
required: true
schema:
$ref: '#/definitions/models.rule'
responses:
"200":
description: '{rule} models.rule'
delete:
tags:
- shared/workspace/rule
description: |-
delete the rule
<br>
operationId: RuleController.Delete
parameters:
- in: path
name: id
description: The id you want to delete
required: true
type: string
responses:
"200":
description: '{rule} delete success!'
/shared/workspace/rule/search/{search}:
get:
tags:
- shared/workspace/rule
description: |-
search rule
<br>
operationId: RuleController.Search
parameters:
- in: path
name: search
description: the word search you want to get
required: true
type: string
responses:
"200":
description: '{rule} models.rule'
/shared/workspace/search/{search}:
get:
tags:
- shared/workspace
description: |-
search shared workspace
<br>
operationId: SharedWorkspaceController.Search
parameters:
- in: path
name: search
description: the word search you want to get
required: true
type: string
responses:
"200":
description: '{shared workspace} models.shared_workspace'
/version/: /version/:
get: get:
tags: tags:
@ -34,206 +234,6 @@ paths:
responses: responses:
"200": "200":
description: "" description: ""
/workspace/:
get:
tags:
- workspace
description: |-
find shared workspace by id
<br>
operationId: SharedWorkspaceController.GetAll
responses:
"200":
description: '{shared_workspace} models.shared_workspace'
post:
tags:
- workspace
description: |-
create shared workspace
<br>
operationId: SharedWorkspaceController.Create
parameters:
- in: body
name: data
description: body for data content (Json format)
required: true
schema:
$ref: '#/definitions/json'
responses:
"200":
description: '{shared workspace} models.shared_workspace'
/workspace/{id}:
get:
tags:
- workspace
description: |-
find shared workspace by id
<br>
operationId: SharedWorkspaceController.Get
parameters:
- in: path
name: id
description: the id you want to get
required: true
type: string
responses:
"200":
description: '{shared workspace} models.shared_workspace'
put:
tags:
- workspace
description: |-
create shared workspaces
<br>
operationId: SharedWorkspaceController.Update
parameters:
- in: path
name: id
description: the shared workspace id you want to get
required: true
type: string
- in: body
name: body
description: The shared workspace content
required: true
schema:
$ref: '#/definitions/models.workspace'
responses:
"200":
description: '{shared workspace} models.shared_workspace'
delete:
tags:
- workspace
description: |-
delete the shared workspace
<br>
operationId: SharedWorkspaceController.Delete
parameters:
- in: path
name: id
description: The id you want to delete
required: true
type: string
responses:
"200":
description: '{shared workspace} delete success!'
/workspace/rule/:
get:
tags:
- workspace/rule
description: |-
find rule by id
<br>
operationId: RuleController.GetAll
responses:
"200":
description: '{rule} models.rule'
post:
tags:
- workspace/rule
description: |-
create rule
<br>
operationId: RuleController.Create
parameters:
- in: body
name: data
description: body for data content (Json format)
required: true
schema:
$ref: '#/definitions/json'
responses:
"200":
description: '{rule} models.rule'
/workspace/rule/{id}:
get:
tags:
- workspace/rule
description: |-
find rule by id
<br>
operationId: RuleController.Get
parameters:
- in: path
name: id
description: the id you want to get
required: true
type: string
responses:
"200":
description: '{rule} models.rule'
put:
tags:
- workspace/rule
description: |-
create rules
<br>
operationId: RuleController.Update
parameters:
- in: path
name: id
description: the rule id you want to get
required: true
type: string
- in: body
name: body
description: The rule content
required: true
schema:
$ref: '#/definitions/models.rule'
responses:
"200":
description: '{rule} models.rule'
delete:
tags:
- workspace/rule
description: |-
delete the rule
<br>
operationId: RuleController.Delete
parameters:
- in: path
name: id
description: The id you want to delete
required: true
type: string
responses:
"200":
description: '{rule} delete success!'
/workspace/rule/search/{search}:
get:
tags:
- workspace/rule
description: |-
search rule
<br>
operationId: RuleController.Search
parameters:
- in: path
name: search
description: the word search you want to get
required: true
type: string
responses:
"200":
description: '{rule} models.rule'
/workspace/search/{search}:
get:
tags:
- workspace
description: |-
search shared workspace
<br>
operationId: SharedWorkspaceController.Search
parameters:
- in: path
name: search
description: the word search you want to get
required: true
type: string
responses:
"200":
description: '{shared workspace} models.shared_workspace'
definitions: definitions:
json: json:
title: json title: json
@ -245,10 +245,10 @@ definitions:
title: workspace title: workspace
type: object type: object
tags: tags:
- name: workspace - name: shared/workspace
description: | description: |
Operations about workspace Operations about workspace
- name: workspace/rule - name: shared/workspace/rule
description: | description: |
Operations about rule Operations about rule
- name: version - name: version