30 Commits

Author SHA1 Message Date
0d4eb13f96 Ajouter .gitattributes 2025-11-01 16:36:18 +01:00
pb
457a16bb7c Merge branch 'main' of https://cloud.o-forge.io/core/oc-shared 2025-08-12 16:37:41 +02:00
pb
af99625674 Update go.mod and go.sum 2025-08-12 16:37:06 +02:00
pb
d54496262b Mise à jour des fichiers go.mod et go.sum 2025-08-12 16:23:05 +02:00
mr
8dacac7314 oclib 2025-06-24 17:00:41 +02:00
mr
816cdd880d oc lib -> nats search 2025-06-24 09:08:39 +02:00
mr
1379a71ff9 deploy adjustment 2025-06-16 09:18:53 +02:00
mr
e45f7c2bf8 adjustment 2025-03-28 08:48:39 +01:00
mr
d76473bb0f dev launch mode 2025-03-06 09:32:58 +01:00
mr
edc8915e2f neo oclib 2025-02-21 11:17:22 +01:00
mr
7452451f28 traefik 2025-02-19 12:03:53 +01:00
mr
75b90ac64c oclib update 2025-02-18 14:59:52 +01:00
mr
47eb681f3b Merge branch 'feature/payment' 2025-02-13 10:21:33 +01:00
mr
b0de32c0d3 neo oc-lib 2025-02-06 08:52:23 +01:00
mr
ed9e98e5f9 neo workflow 2025-02-05 08:38:19 +01:00
mr
7d391e4059 working oc-shared 2025-01-17 17:20:37 +01:00
plm
f56a5d0dd3 levelup beego + cors integration 2025-01-15 16:32:57 +01:00
plm
90ac9b4d44 Pushing modifications for k8s integration 2025-01-15 09:40:55 +01:00
mr
3b65fb934b neo oc lib 2024-11-21 11:00:57 +01:00
mr
6567dc68a5 Working update 2024-11-19 15:07:47 +01:00
mr
e9eeac3738 test 2024-11-14 10:47:21 +01:00
mr
c4d2081bf2 oclib 2024-11-08 14:02:56 +01:00
mr
73b2446397 oclib 2024-11-07 13:38:16 +01:00
mr
f3566e1120 shared 2024-11-04 14:27:30 +01:00
mr
863b413258 shared 2024-10-30 17:09:17 +01:00
mr
d34a960c96 oclib 2024-10-30 13:59:10 +01:00
mr
7c994437e0 shared traefik 2024-10-30 10:45:04 +01:00
mr
c8038f42c1 retablish port 2024-10-15 12:15:29 +02:00
mr
6af13d4f0d Merge branch 'master' of https://cloud.o-forge.io/core/oc-shared 2024-10-15 11:00:42 +02:00
mr
3b8c543697 Neo oc-whared for local deployment 2024-10-15 11:00:39 +02:00
18 changed files with 387 additions and 505 deletions

3
.gitattributes vendored Normal file
View File

@@ -0,0 +1,3 @@
# Force Go as the main language
*.go linguist-detectable=true
* linguist-language=Go

View File

@@ -1,29 +1,45 @@
FROM golang:alpine AS deps
WORKDIR /app
COPY go.mod go.sum ./
RUN sed -i '/replace/d' go.mod
RUN go mod download
#----------------------------------------------------------------------------------------------
FROM golang:alpine AS builder
WORKDIR /app
COPY . .
RUN apk add git
RUN go get github.com/beego/bee/v2 && go install github.com/beego/bee/v2@master
RUN go install github.com/beego/bee/v2@latest
RUN timeout 15 bee run -gendoc=true -downdoc=true -runmode=dev || :
WORKDIR /oc-shared
RUN sed -i 's/http:\/\/127.0.0.1:8080\/swagger\/swagger.json/swagger.json/g' swagger/index.html
COPY --from=deps /go/pkg /go/pkg
COPY --from=deps /app/go.mod /app/go.sum ./
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" .
RUN export CGO_ENABLED=0 && \
export GOOS=linux && \
export GOARCH=amd64 && \
export BUILD_FLAGS="-ldflags='-w -s'"
RUN ls /app
COPY . .
FROM scratch
RUN sed -i '/replace/d' go.mod
RUN bee pack
RUN mkdir -p /app/extracted && tar -zxvf oc-shared.tar.gz -C /app/extracted
RUN sed -i 's/http:\/\/127.0.0.1:8080\/swagger\/swagger.json/swagger.json/g' /app/extracted/swagger/index.html
#----------------------------------------------------------------------------------------------
FROM golang:alpine
WORKDIR /app
COPY --from=builder /app/oc-shared /usr/bin/
COPY --from=builder /app/swagger /app/swagger
COPY docker_shared.json /etc/oc/shared.json
COPY --from=builder /app/extracted/oc-shared /usr/bin/
COPY --from=builder /app/extracted/swagger /app/swagger
COPY --from=builder /app/extracted/docker_shared.json /etc/oc/shared.json
EXPOSE 8080

40
Makefile Normal file
View File

@@ -0,0 +1,40 @@
.DEFAULT_GOAL := all
build: clean
bee pack
run:
bee run -gendoc=true -downdoc=true
purge:
lsof -t -i:8091 | xargs kill | true
run-dev:
bee generate routers && bee run -gendoc=true -downdoc=true -runmode=prod
dev: purge run-dev
debug:
bee run -downdebug -gendebug
clean:
rm -rf oc-shared.tar.gz
docker:
DOCKER_BUILDKIT=1 docker build -t oc-shared -f Dockerfile . --build-arg=HOST=$(HOST)
docker tag oc-shared:latest oc/oc-shared:0.0.1
publish-kind:
kind load docker-image oc/oc-shared:0.0.1 --name opencloud | true
publish-registry:
@echo "TODO"
docker-deploy:
docker compose up -d
run-docker: docker publish-kind publish-registry docker-deploy
all: docker publish-kind publish-registry
.PHONY: build run clean docker publish-kind publish-registry

View File

@@ -6,6 +6,8 @@ To build :
bee generate routers
bee run -gendoc=true -downdoc=true
OR
make dev
If default Swagger page is displayed instead of tyour api, change url in swagger/index.html file to :

View File

@@ -6,6 +6,7 @@ import (
"slices"
oclib "cloud.o-forge.io/core/oc-lib"
"cloud.o-forge.io/core/oc-lib/config"
"cloud.o-forge.io/core/oc-lib/tools"
beego "github.com/beego/beego/v2/server/web"
)
@@ -17,31 +18,34 @@ type CollaborativeAreaController struct {
var paths = map[tools.DataType]map[tools.METHOD]string{ // paths used to call other OC services
tools.COLLABORATIVE_AREA: {
tools.DELETE: "/oc/shared/workspace/:id?is_remote=true",
tools.POST: "/oc/shared/workspace/?is_remote=true",
tools.DELETE: "/collaborative_area/:id?is_remote=true",
tools.POST: "/collaborative_area/?is_remote=true",
},
tools.WORKSPACE: {
tools.DELETE: "/oc/workspace/:id?is_remote=true",
tools.POST: "/oc/workspace/?is_remote=true",
tools.DELETE: "/:id?is_remote=true",
tools.POST: "/?is_remote=true",
},
tools.WORKFLOW: {
tools.DELETE: "/oc/workflow/:id?is_remote=true",
tools.POST: "/oc/workflow/?is_remote=true",
tools.DELETE: "/:id?is_remote=true",
tools.POST: "/?is_remote=true",
},
tools.PEER: {
tools.POST: "/oc/peer",
tools.POST: "/status/",
},
}
// @Title Search
// @Description search shared workspace
// @Param search path string true "the word search you want to get"
// @Param is_draft query string false "draft wished"
// @Success 200 {shared workspace} models.shared_workspace
// @router /search/:search [get]
func (o *CollaborativeAreaController) Search() {
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
// store and return Id or post with UUID
search := o.Ctx.Input.Param(":search")
o.Data["json"] = oclib.Search(nil, search, oclib.LibDataEnum(tools.COLLABORATIVE_AREA))
isDraft := o.Ctx.Input.Query("is_draft")
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, nil).Search(nil, search, isDraft == "true")
o.ServeJSON()
}
@@ -52,6 +56,7 @@ func (o *CollaborativeAreaController) Search() {
// @Success 200 {shared workspace} models.shared_workspace
// @router /:id [put]
func (o *CollaborativeAreaController) Put() {
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
// store and return Id or post with UUID
var res map[string]interface{}
id := o.Ctx.Input.Param(":id")
@@ -59,7 +64,7 @@ func (o *CollaborativeAreaController) Put() {
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
caller.Disabled = oclib.IsQueryParamsEquals(o.Ctx.Input, "is_remote", true)
fmt.Println("UPDATE", res)
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(tools.COLLABORATIVE_AREA), res, id, caller)
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, caller).UpdateOne(res, id)
o.ServeJSON()
}
@@ -69,20 +74,24 @@ func (o *CollaborativeAreaController) Put() {
// @Success 200 {shared workspace} models.shared_workspace
// @router / [post]
func (o *CollaborativeAreaController) Post() {
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
caller.Disabled = oclib.IsQueryParamsEquals(o.Ctx.Input, "is_remote", true)
var res map[string]interface{}
json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res)
o.Data["json"] = oclib.StoreOne(oclib.LibDataEnum(tools.COLLABORATIVE_AREA), res, caller)
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, caller).StoreOne(res)
o.ServeJSON()
}
// @Title GetAll
// @Description find shared workspace by id
// @Param is_draft query string false "draft wished"
// @Success 200 {shared_workspace} models.shared_workspace
// @router / [get]
func (o *CollaborativeAreaController) GetAll() {
o.Data["json"] = oclib.LoadAll(oclib.LibDataEnum(tools.COLLABORATIVE_AREA))
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
isDraft := o.Ctx.Input.Query("is_draft")
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, nil).LoadAll(isDraft == "true")
o.ServeJSON()
}
@@ -92,23 +101,25 @@ func (o *CollaborativeAreaController) GetAll() {
// @Success 200 {shared workspace} models.shared_workspace
// @router /:id [get]
func (o *CollaborativeAreaController) Get() {
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
id := o.Ctx.Input.Param(":id")
o.Data["json"] = oclib.LoadOne(oclib.LibDataEnum(tools.COLLABORATIVE_AREA), id)
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, nil).LoadOne(id)
o.ServeJSON()
}
// @Title Add Workspace
// @Title Remove Workspace
// @Description find shared workspace by id
// @Param id path string true "the id you want to get"
// @Param id2 path string true "the id you want to add"
// @Success 200 {shared workspace} models.shared_workspace
// @router /:id/workspace/:id2 [delete]
func (o *CollaborativeAreaController) RemoveWorkspace() {
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
caller.Disabled = oclib.IsQueryParamsEquals(o.Ctx.Input, "is_remote", true)
id := o.Ctx.Input.Param(":id")
id2 := o.Ctx.Input.Param(":id2")
r := oclib.LoadOne(oclib.LibDataEnum(tools.COLLABORATIVE_AREA), id)
r := oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, nil).LoadOne(id)
shared := r.ToCollaborativeArea()
newWorkspace := []string{}
if slices.Contains(shared.Workspaces, id2) {
@@ -119,7 +130,8 @@ func (o *CollaborativeAreaController) RemoveWorkspace() {
}
shared.Workspaces = newWorkspace
}
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(tools.COLLABORATIVE_AREA), shared.Serialize(), id, caller)
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, caller).UpdateOne(
shared.Serialize(shared), id)
o.ServeJSON()
}
@@ -130,23 +142,22 @@ func (o *CollaborativeAreaController) RemoveWorkspace() {
// @Success 200 {shared workspace} models.shared_workspace
// @router /:id/workflow/:id2 [delete]
func (o *CollaborativeAreaController) RemoveWorkflow() {
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
caller.Disabled = oclib.IsQueryParamsEquals(o.Ctx.Input, "is_remote", true)
id := o.Ctx.Input.Param(":id")
id2 := o.Ctx.Input.Param(":id2")
r := oclib.LoadOne(oclib.LibDataEnum(tools.COLLABORATIVE_AREA), id)
fmt.Println("RemoveWorkflow", r)
r := oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, nil).LoadOne(id)
shared := r.ToCollaborativeArea()
newWorkflows := []string{}
if slices.Contains(shared.Workflows, id2) {
for _, w := range shared.Workflows {
if w != id2 {
newWorkflows = append(newWorkflows, w)
}
}
shared.Workflows = newWorkflows
}
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(tools.COLLABORATIVE_AREA), shared.Serialize(), id, caller)
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, caller).UpdateOne(
shared.Serialize(shared), id)
o.ServeJSON()
}
@@ -157,14 +168,15 @@ func (o *CollaborativeAreaController) RemoveWorkflow() {
// @Success 200 {shared workspace} models.shared_workspace
// @router /:id/peer/:id2 [delete]
func (o *CollaborativeAreaController) RemovePeer() {
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
caller.Disabled = oclib.IsQueryParamsEquals(o.Ctx.Input, "is_remote", true)
id := o.Ctx.Input.Param(":id")
id2 := o.Ctx.Input.Param(":id2")
r := oclib.LoadOne(oclib.LibDataEnum(tools.COLLABORATIVE_AREA), id)
r := oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, nil).LoadOne(id)
shared := r.ToCollaborativeArea()
newPeers := []string{}
if shared.CreatorID != id2 {
newPeers := map[string][]string{}
if shared.CreatorID == id2 {
o.Data["json"] = map[string]interface{}{
"data": nil,
"code": 409,
@@ -173,15 +185,28 @@ func (o *CollaborativeAreaController) RemovePeer() {
o.ServeJSON()
return
}
if slices.Contains(shared.Peers, id) && shared.CreatorID != id2 {
for _, peer := range shared.Peers {
if shared.AllowedPeersGroup != nil {
keys := make([]string, len(shared.AllowedPeersGroup))
i := 0
for k := range shared.AllowedPeersGroup {
keys[i] = k
i++
}
if slices.Contains(keys, id) && shared.CreatorID != id2 {
for _, peer := range keys {
if peer != id2 {
newPeers = append(newPeers, peer)
if config.GetConfig().Whitelist {
newPeers[peer] = []string{"*"}
} else {
newPeers[peer] = []string{}
}
}
shared.Peers = newPeers
}
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(tools.COLLABORATIVE_AREA), shared.Serialize(), id, caller)
shared.AllowedPeersGroup = newPeers
}
}
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, caller).UpdateOne(
shared.Serialize(shared), id)
o.ServeJSON()
}
@@ -192,11 +217,12 @@ func (o *CollaborativeAreaController) RemovePeer() {
// @Success 200 {shared workspace} models.shared_workspace
// @router /:id/rule/:id2 [delete]
func (o *CollaborativeAreaController) RemoveRule() {
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
caller.Disabled = oclib.IsQueryParamsEquals(o.Ctx.Input, "is_remote", true)
id := o.Ctx.Input.Param(":id")
id2 := o.Ctx.Input.Param(":id2")
r := oclib.LoadOne(oclib.LibDataEnum(tools.COLLABORATIVE_AREA), id)
r := oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, nil).LoadOne(id)
shared := r.ToCollaborativeArea()
newRules := []string{}
if shared != nil && slices.Contains(shared.Rules, id2) {
@@ -207,7 +233,8 @@ func (o *CollaborativeAreaController) RemoveRule() {
}
shared.Rules = newRules
}
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(tools.COLLABORATIVE_AREA), shared.Serialize(), id, caller)
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, caller).UpdateOne(
shared.Serialize(shared), id)
o.ServeJSON()
}
@@ -218,11 +245,12 @@ func (o *CollaborativeAreaController) RemoveRule() {
// @Success 200 {shared workspace} models.shared_workspace
// @router /:id/workspace/:id2 [post]
func (o *CollaborativeAreaController) AddWorkspace() {
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
caller.Disabled = oclib.IsQueryParamsEquals(o.Ctx.Input, "is_remote", true)
id := o.Ctx.Input.Param(":id")
id2 := o.Ctx.Input.Param(":id2")
r := oclib.LoadOne(oclib.LibDataEnum(tools.COLLABORATIVE_AREA), id)
r := oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, nil).LoadOne(id)
if r.Code != 200 {
o.Data["json"] = r
o.ServeJSON()
@@ -232,7 +260,8 @@ func (o *CollaborativeAreaController) AddWorkspace() {
if shared != nil && !slices.Contains(shared.Workspaces, id2) {
shared.Workspaces = append(shared.Workspaces, id2)
}
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(tools.COLLABORATIVE_AREA), shared.Serialize(), id, caller)
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, caller).UpdateOne(
shared.Serialize(shared), id)
o.ServeJSON()
}
@@ -243,16 +272,23 @@ func (o *CollaborativeAreaController) AddWorkspace() {
// @Success 200 {shared workspace} models.shared_workspace
// @router /:id/workflow/:id2 [post]
func (o *CollaborativeAreaController) AddWorkflow() {
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
caller.Disabled = oclib.IsQueryParamsEquals(o.Ctx.Input, "is_remote", true)
id := o.Ctx.Input.Param(":id")
id2 := o.Ctx.Input.Param(":id2")
r := oclib.LoadOne(oclib.LibDataEnum(tools.COLLABORATIVE_AREA), id)
r := oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, nil).LoadOne(id)
if r.Code != 200 {
o.Data["json"] = r
o.ServeJSON()
return
}
shared := r.ToCollaborativeArea()
if shared != nil && !slices.Contains(shared.Workflows, id2) {
shared.Workflows = append(shared.Workflows, id2)
}
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(tools.COLLABORATIVE_AREA), shared.Serialize(), id, caller)
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, caller).UpdateOne(
shared.Serialize(shared), id)
o.ServeJSON()
}
@@ -260,19 +296,29 @@ func (o *CollaborativeAreaController) AddWorkflow() {
// @Description find shared workspace by id
// @Param id path string true "the id you want to get"
// @Param id2 path string true "the id you want to add"
// @Param body body models.workspace true "The shared workspace content"
// @Success 200 {shared workspace} models.shared_workspace
// @router /:id/peer/:id2 [post]
func (o *CollaborativeAreaController) AddPeer() {
var res []string
json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res)
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
caller.Disabled = oclib.IsQueryParamsEquals(o.Ctx.Input, "is_remote", true)
id := o.Ctx.Input.Param(":id")
id2 := o.Ctx.Input.Param(":id2")
r := oclib.LoadOne(oclib.LibDataEnum(tools.COLLABORATIVE_AREA), id)
r := oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, nil).LoadOne(id)
shared := r.ToCollaborativeArea()
if shared != nil && !slices.Contains(shared.Peers, id2) {
shared.Peers = append(shared.Peers, id2)
if shared.AllowedPeersGroup == nil {
shared.AllowedPeersGroup = map[string][]string{}
}
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(tools.COLLABORATIVE_AREA), shared.Serialize(), id, caller)
if config.GetConfig().Whitelist && len(res) == 0 {
shared.AllowedPeersGroup[id2] = []string{"*"}
} else {
shared.AllowedPeersGroup[id2] = res
}
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, caller).UpdateOne(
shared.Serialize(shared), id)
o.ServeJSON()
}
@@ -283,16 +329,17 @@ func (o *CollaborativeAreaController) AddPeer() {
// @Success 200 {shared workspace} models.shared_workspace
// @router /:id/rule/:id2 [post]
func (o *CollaborativeAreaController) AddRule() {
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
caller.Disabled = oclib.IsQueryParamsEquals(o.Ctx.Input, "is_remote", true)
id := o.Ctx.Input.Param(":id")
id2 := o.Ctx.Input.Param(":id2")
r := oclib.LoadOne(oclib.LibDataEnum(tools.COLLABORATIVE_AREA), id)
r := oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, nil).LoadOne(id)
shared := r.ToCollaborativeArea()
if shared != nil && !slices.Contains(shared.Rules, id2) {
shared.Rules = append(shared.Rules, id2)
}
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(tools.COLLABORATIVE_AREA), shared.Serialize(), id, caller)
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, caller).UpdateOne(shared.Serialize(shared), id)
o.ServeJSON()
}
@@ -302,9 +349,10 @@ func (o *CollaborativeAreaController) AddRule() {
// @Success 200 {shared workspace} delete success!
// @router /:id [delete]
func (o *CollaborativeAreaController) Delete() {
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
id := o.Ctx.Input.Param(":id")
caller := tools.NewHTTPCaller(paths) // caller used to send to peers
caller.Disabled = oclib.IsQueryParamsEquals(o.Ctx.Input, "is_remote", true)
o.Data["json"] = oclib.DeleteOne(oclib.LibDataEnum(tools.COLLABORATIVE_AREA), id, caller)
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.COLLABORATIVE_AREA), user, peerID, groups, caller).DeleteOne(id)
o.ServeJSON()
}

View File

@@ -15,12 +15,15 @@ type RuleController struct {
// @Title Search
// @Description search rule
// @Param search path string true "the word search you want to get"
// @Param is_draft query string false "draft wished"
// @Success 200 {rule} models.rule
// @router /search/:search [get]
func (o *RuleController) Search() {
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
// store and return Id or post with UUID
search := o.Ctx.Input.Param(":search")
o.Data["json"] = oclib.Search(nil, search, oclib.LibDataEnum(oclib.RULE))
isDraft := o.Ctx.Input.Query("is_draft")
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.RULE), user, peerID, groups, nil).Search(nil, search, isDraft == "true")
o.ServeJSON()
}
@@ -31,11 +34,12 @@ func (o *RuleController) Search() {
// @Success 200 {rule} models.rule
// @router /:id [put]
func (o *RuleController) Put() {
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
// store and return ID or post with UUID
var res map[string]interface{}
id := o.Ctx.Input.Param(":id")
json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res)
o.Data["json"] = oclib.UpdateOne(oclib.LibDataEnum(oclib.RULE), res, id)
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.RULE), user, peerID, groups, nil).UpdateOne(res, id)
o.ServeJSON()
}
@@ -45,18 +49,22 @@ func (o *RuleController) Put() {
// @Success 200 {rule} models.rule
// @router / [post]
func (o *RuleController) Post() {
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
var res map[string]interface{}
json.Unmarshal(o.Ctx.Input.CopyBody(10000), &res)
o.Data["json"] = oclib.StoreOne(oclib.LibDataEnum(oclib.RULE), res)
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.RULE), user, peerID, groups, nil).StoreOne(res)
o.ServeJSON()
}
// @Title GetAll
// @Description find rule by id
// @Param is_draft query string false "draft wished"
// @Success 200 {rule} models.rule
// @router / [get]
func (o *RuleController) GetAll() {
o.Data["json"] = oclib.LoadAll(oclib.LibDataEnum(oclib.RULE))
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
isDraft := o.Ctx.Input.Query("is_draft")
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.RULE), user, peerID, groups, nil).LoadAll(isDraft == "true")
o.ServeJSON()
}
@@ -66,8 +74,9 @@ func (o *RuleController) GetAll() {
// @Success 200 {rule} models.rule
// @router /:id [get]
func (o *RuleController) Get() {
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
id := o.Ctx.Input.Param(":id")
o.Data["json"] = oclib.LoadOne(oclib.LibDataEnum(oclib.RULE), id)
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.RULE), user, peerID, groups, nil).LoadOne(id)
o.ServeJSON()
}
@@ -77,7 +86,8 @@ func (o *RuleController) Get() {
// @Success 200 {rule} delete success!
// @router /:id [delete]
func (o *RuleController) Delete() {
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
id := o.Ctx.Input.Param(":id")
o.Data["json"] = oclib.DeleteOne(oclib.LibDataEnum(oclib.RULE), id)
o.Data["json"] = oclib.NewRequest(oclib.LibDataEnum(oclib.RULE), user, peerID, groups, nil).DeleteOne(id)
o.ServeJSON()
}

View File

@@ -15,7 +15,10 @@ type VersionController struct {
// @Success 200
// @router / [get]
func (c *VersionController) GetAll() {
c.Data["json"] = map[string]string{"version": "1"}
c.Data["json"] = map[string]string{
"service": "oc-shared",
"version": "1",
}
c.ServeJSON()
}

View File

@@ -1,34 +0,0 @@
version: '3.4'
services:
mongo:
image: 'mongo:latest'
networks:
- catalog
ports:
- 27017:27017
container_name: mongo
volumes:
- oc-catalog-data:/data/db
- oc-catalog-data:/data/configdb
mongo-express:
image: "mongo-express:latest"
restart: always
depends_on:
- mongo
networks:
- catalog
ports:
- 8081:8081
environment:
- ME_CONFIG_BASICAUTH_USERNAME=test
- ME_CONFIG_BASICAUTH_PASSWORD=test
volumes:
oc-catalog-data:
networks:
catalog:
external: true
# name: catalog

View File

@@ -8,9 +8,18 @@ services:
ports:
- 8091:8080
container_name: oc-shared
labels:
- "traefik.enable=true"
- "traefik.http.routers.shared.entrypoints=web"
- "traefik.http.routers.shared.rule=PathPrefix(`/shared`)"
- "traefik.http.middlewares.shared-rewrite.replacepathregex.regex=^/shared(.*)"
- "traefik.http.middlewares.shared-rewrite.replacepathregex.replacement=/oc$$1"
- "traefik.http.routers.shared.middlewares=shared-rewrite"
- "traefik.http.services.shared.loadbalancer.server.port=8080"
- "traefik.http.middlewares.shared.forwardauth.address=http://oc-auth:8080/oc/forward"
networks:
- catalog
- oc
networks:
catalog:
oc:
external: true

View File

@@ -1,4 +1,5 @@
{
"MONGO_URL":"mongodb://mongo:27017/",
"NATS_URL":"nats://nats:4222",
"MONGO_DATABASE":"DC_myDC"
}

49
go.mod
View File

@@ -1,57 +1,58 @@
module oc-shared
go 1.22.0
go 1.23.0
toolchain go1.22.4
toolchain go1.24.0
require (
cloud.o-forge.io/core/oc-lib v0.0.0-20241002120813-a09a04e1a71e
github.com/beego/beego/v2 v2.3.1
cloud.o-forge.io/core/oc-lib v0.0.0-20250808141553-f4b0cf5683de
github.com/beego/beego/v2 v2.3.8
)
require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/biter777/countries v1.7.5 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/gabriel-vasile/mimetype v1.4.5 // indirect
github.com/gabriel-vasile/mimetype v1.4.9 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.22.1 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/go-playground/validator/v10 v10.27.0 // indirect
github.com/golang/snappy v1.0.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/goraz/onion v0.1.3 // indirect
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/klauspost/compress v1.17.10 // indirect
github.com/klauspost/compress v1.18.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
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/nats.go v1.44.0 // indirect
github.com/nats-io/nkeys v0.4.11 // indirect
github.com/nats-io/nuid v1.0.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.20.2 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.58.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
github.com/prometheus/client_golang v1.23.0 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.65.0 // indirect
github.com/prometheus/procfs v0.17.0 // indirect
github.com/robfig/cron v1.2.0 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/rs/zerolog v1.33.0 // indirect
github.com/rs/zerolog v1.34.0 // indirect
github.com/shiena/ansicolor v0.0.0-20230509054315-a9deabde6e02 // indirect
github.com/smartystreets/goconvey v1.7.2 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect
go.mongodb.org/mongo-driver v1.17.1 // indirect
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/text v0.18.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
go.mongodb.org/mongo-driver v1.17.4 // indirect
golang.org/x/crypto v0.41.0 // indirect
golang.org/x/net v0.43.0 // indirect
golang.org/x/sync v0.16.0 // indirect
golang.org/x/sys v0.35.0 // indirect
golang.org/x/text v0.28.0 // indirect
google.golang.org/protobuf v1.36.7 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

123
go.sum
View File

@@ -1,20 +1,12 @@
cloud.o-forge.io/core/oc-lib v0.0.0-20240904135449-4f0ab6a3760f h1:v9mw3uNg/DJswOvHooMu8/BMedA+vIXbma+8iUwsjUI=
cloud.o-forge.io/core/oc-lib v0.0.0-20240904135449-4f0ab6a3760f/go.mod h1:FIJD0taWLJ5pjQLJ6sfE2KlTkvbmk5SMcyrxdjsaVz0=
cloud.o-forge.io/core/oc-lib v0.0.0-20240927112324-cdf513c2c454 h1:F5/oBMypnb6Mdvcf6N8y8v/DgfglPQ6VsQUY7hjC2zA=
cloud.o-forge.io/core/oc-lib v0.0.0-20240927112324-cdf513c2c454/go.mod h1:FIJD0taWLJ5pjQLJ6sfE2KlTkvbmk5SMcyrxdjsaVz0=
cloud.o-forge.io/core/oc-lib v0.0.0-20241002084552-3c1a84011ecc h1:1R4stJxXDMQ6joJZl9gQ2TUGW6S2jct2lhHUubPChs0=
cloud.o-forge.io/core/oc-lib v0.0.0-20241002084552-3c1a84011ecc/go.mod h1:FIJD0taWLJ5pjQLJ6sfE2KlTkvbmk5SMcyrxdjsaVz0=
cloud.o-forge.io/core/oc-lib v0.0.0-20241002102322-c309d9762350 h1:ybK3Qz1inr9xgrJwbHjSOTNaFIyX+AVINyzqcsvpATY=
cloud.o-forge.io/core/oc-lib v0.0.0-20241002102322-c309d9762350/go.mod h1:FIJD0taWLJ5pjQLJ6sfE2KlTkvbmk5SMcyrxdjsaVz0=
cloud.o-forge.io/core/oc-lib v0.0.0-20241002120813-a09a04e1a71e h1:77QHk5JSf0q13B/Ai3xjcsGSS7nX+9AfxcsYz5oDo/A=
cloud.o-forge.io/core/oc-lib v0.0.0-20241002120813-a09a04e1a71e/go.mod h1:t+zpCTVKVdHH/BImwtMYY2QIWLMXKgY4n/JhFm3Vpu8=
cloud.o-forge.io/core/oc-lib v0.0.0-20250808141553-f4b0cf5683de h1:s47eEnWRCjBMOxbec5ROHztuwu0Zo7MuXgqWizgkiXU=
cloud.o-forge.io/core/oc-lib v0.0.0-20250808141553-f4b0cf5683de/go.mod h1:vHWauJsS6ryf7UDqq8hRXoYD5RsONxcFTxeZPOztEuI=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/beego/beego/v2 v2.3.0 h1:iECVwzm6egw6iw6tkWrEDqXG4NQtKLQ6QBSYqlM6T/I=
github.com/beego/beego/v2 v2.3.0/go.mod h1:Ob/5BJ9fIKZLd4s9ZV3o9J6odkkIyL83et+p98gyYXo=
github.com/beego/beego/v2 v2.3.1 h1:7MUKMpJYzOXtCUsTEoXOxsDV/UcHw6CPbaWMlthVNsc=
github.com/beego/beego/v2 v2.3.1/go.mod h1:5cqHsOHJIxkq44tBpRvtDe59GuVRVv/9/tyVDxd5ce4=
github.com/beego/beego/v2 v2.3.8 h1:wplhB1pF4TxR+2SS4PUej8eDoH4xGfxuHfS7wAk9VBc=
github.com/beego/beego/v2 v2.3.8/go.mod h1:8vl9+RrXqvodrl9C8yivX1e6le6deCK6RWeq8R7gTTg=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/biter777/countries v1.7.5 h1:MJ+n3+rSxWQdqVJU8eBy9RqcdH6ePPn4PJHocVWUa+Q=
github.com/biter777/countries v1.7.5/go.mod h1:1HSpZ526mYqKJcpT5Ti1kcGQ0L0SrXWIaptUWjFfv2E=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/coreos/etcd v3.3.17+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
@@ -29,23 +21,21 @@ github.com/elazarl/go-bindata-assetfs v1.0.1 h1:m0kkaHRKEu7tUIUFVwhGGGYClXvyl4RE
github.com/elazarl/go-bindata-assetfs v1.0.1/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4=
github.com/etcd-io/etcd v3.3.17+incompatible/go.mod h1:cdZ77EstHBwVtD6iTgzgvogwcjo9m4iOqoijouPJ4bs=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/gabriel-vasile/mimetype v1.4.5 h1:J7wGKdGu33ocBOhGy0z653k/lFKLFDPJMG8Gql0kxn4=
github.com/gabriel-vasile/mimetype v1.4.5/go.mod h1:ibHel+/kbxn9x2407k1izTA1S81ku1z/DlgOW2QE0M4=
github.com/gabriel-vasile/mimetype v1.4.9 h1:5k+WDwEsD9eTLL8Tz3L0VnmVh9QxGjRmjBvAG7U/oYY=
github.com/gabriel-vasile/mimetype v1.4.9/go.mod h1:WnSQhFKJuBlRyLiKohA/2DtIlPFAbguNaG7QCHcyGok=
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.22.0 h1:k6HsTZ0sTnROkhS//R0O+55JgM8C4Bx7ia+JlgcnOao=
github.com/go-playground/validator/v10 v10.22.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
github.com/go-playground/validator/v10 v10.22.1 h1:40JcKH+bBNGFczGuoBYgX4I6m/i27HYW8P9FDk5PbgA=
github.com/go-playground/validator/v10 v10.22.1/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
github.com/go-playground/validator/v10 v10.27.0 h1:w8+XrWVMhGkxOaaowyKH35gFydVHOvC0/uWoy2Fzwn4=
github.com/go-playground/validator/v10 v10.27.0/go.mod h1:I5QpIEbmr8On7W0TktmJAumgzX4CA1XNl4ZmDuVHKKo=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/golang/snappy v1.0.0 h1:Oy607GVXHs7RtbggtPBnr2RmDArIsAefDwvrdWvRhGs=
github.com/golang/snappy v1.0.0/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
@@ -59,10 +49,8 @@ github.com/imdario/mergo v0.3.8/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJ
github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
github.com/klauspost/compress v1.17.10 h1:oXAz+Vh0PMUvJczoi+flxpnBEPxoER1IaAnU/NMPtT0=
github.com/klauspost/compress v1.17.10/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
@@ -72,8 +60,9 @@ github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
@@ -89,10 +78,10 @@ github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8
github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
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/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/nats.go v1.44.0 h1:ECKVrDLdh/kDPV1g0gAQ+2+m2KprqZK5O/eJAyAnH2M=
github.com/nats-io/nats.go v1.44.0/go.mod h1:iRWIPokVIFbVijxuMQq4y9ttaBTMe0SFdlZfMDd+33g=
github.com/nats-io/nkeys v0.4.11 h1:q44qGV008kYd9W1b1nEBkNzvnWxtRSQ7A8BoqRrcfa0=
github.com/nats-io/nkeys v0.4.11/go.mod h1:szDimtgmfOi9n25JpfIdGw12tZFYXqhGxjhVxsatHVE=
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/ogier/pflag v0.0.1/go.mod h1:zkFki7tvTa0tafRvTBIZTvzYyAu6kQhPZFnshFFPE+g=
@@ -101,21 +90,21 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v1.20.2 h1:5ctymQzZlyOON1666svgwn3s6IKWgfbjsejTMiXIyjg=
github.com/prometheus/client_golang v1.20.2/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
github.com/prometheus/common v0.58.0 h1:N+N8vY4/23r6iYfD3UQZUoJPnUYAo7v6LG5XZxjZTXo=
github.com/prometheus/common v0.58.0/go.mod h1:GpWM7dewqmVYcd7SmRaiWVe9SSqjf0UrwnYnpEZNuT0=
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
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/prometheus/client_golang v1.23.0 h1:ust4zpdl9r4trLY/gSjlm07PuiBq2ynaXXlptpfy8Uc=
github.com/prometheus/client_golang v1.23.0/go.mod h1:i/o0R9ByOnHX0McrTMTyhYvKE4haaf2mW08I+jGAjEE=
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
github.com/prometheus/common v0.65.0 h1:QDwzd+G1twt//Kwj/Ww6E9FQq1iVMmODnILtW1t2VzE=
github.com/prometheus/common v0.65.0/go.mod h1:0gZns+BLRQ3V6NdaerOhMbwwRbNh9hkGINtQAsP5GS8=
github.com/prometheus/procfs v0.17.0 h1:FuLQ+05u4ZI+SS/w9+BWEM2TXiHKsUQ9TADiRH7DuK0=
github.com/prometheus/procfs v0.17.0/go.mod h1:oPQLaDAMRbA+u8H5Pbfq+dl3VDAvHxMUOVhe0wYB2zw=
github.com/robfig/cron v1.2.0 h1:ZjScXvvxeQ63Dbyxy76Fj3AT3Ut0aKsyd2/tl3DTMuQ=
github.com/robfig/cron v1.2.0/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfmt2k=
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8=
github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0=
github.com/rs/zerolog v1.34.0 h1:k43nTLIwcTVQAncfCw4KZ2VY6ukYoZaBPNOE8txlOeY=
github.com/rs/zerolog v1.34.0/go.mod h1:bJsvje4Z08ROH4Nhs5iH600c3IkWhwp44iRc54W6wYQ=
github.com/shiena/ansicolor v0.0.0-20230509054315-a9deabde6e02 h1:v9ezJDHA1XGxViAUSIoO/Id7Fl63u6d0YmsAm+/p2hs=
github.com/shiena/ansicolor v0.0.0-20230509054315-a9deabde6e02/go.mod h1:RF16/A3L0xSa0oSERcnhd8Pu3IXSDZSK2gmGIMsttFE=
github.com/skarademir/naturalsort v0.0.0-20150715044055-69a5d87bef62/go.mod h1:oIdVclZaltY1Nf7OQUkg1/2jImBJ+ZfKZuDIRSwk3p0=
@@ -127,8 +116,8 @@ github.com/smartystreets/goconvey v1.7.2 h1:9RBaZCeXEQ3UselpuwUQHltGVXvdwm6cv1hg
github.com/smartystreets/goconvey v1.7.2/go.mod h1:Vw0tHAZW6lzCRk3xgdin6fKYcG+G3Pg9vgXWeJpQFMM=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY=
@@ -138,33 +127,27 @@ github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gi
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 h1:ilQV1hzziu+LLM3zUTJ0trRztfwgjqKnBWNtSRkbmwM=
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfSfmXjznFBSZNN13rSJjlIOI1fUNAtF7rmI=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.mongodb.org/mongo-driver v1.16.1 h1:rIVLL3q0IHM39dvE+z2ulZLp9ENZKThVfuvN/IiN4l8=
go.mongodb.org/mongo-driver v1.16.1/go.mod h1:oB6AhJQvFQL4LEHyXi6aJzQJtBiTQHiAd83l0GdFaiw=
go.mongodb.org/mongo-driver v1.17.0 h1:Hp4q2MCjvY19ViwimTs00wHi7G4yzxh4/2+nTx8r40k=
go.mongodb.org/mongo-driver v1.17.0/go.mod h1:wwWm/+BuOddhcq3n68LKRmgk2wXzmF6s0SFOa0GINL4=
go.mongodb.org/mongo-driver v1.17.1 h1:Wic5cJIwJgSpBhe3lx3+/RybR5PiYRMpVFgO7cOHyIM=
go.mongodb.org/mongo-driver v1.17.1/go.mod h1:wwWm/+BuOddhcq3n68LKRmgk2wXzmF6s0SFOa0GINL4=
go.mongodb.org/mongo-driver v1.17.4 h1:jUorfmVzljjr0FLzYQsGP8cgN/qzzxlY9Vh0C9KFXVw=
go.mongodb.org/mongo-driver v1.17.4/go.mod h1:Hy04i7O2kC4RS06ZrhPRqj/u4DTYkFDAAccj+rVKqgQ=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191112222119-e1110fd1c708/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
golang.org/x/crypto v0.41.0 h1:WKYxWedPGCTVVl5+WHSSrOBT0O8lx32+zxmHxijgXp4=
golang.org/x/crypto v0.41.0/go.mod h1:pO5AFd7FA68rFak7rOAGVuygIISepHftHnr8dr6+sUc=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE=
golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191115151921-52ab43148777/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -175,23 +158,23 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng=
golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
google.golang.org/protobuf v1.36.7 h1:IgrO7UwFQGJdRNXH/sQux4R1Dj1WAKcLElzeeRaXV2A=
google.golang.org/protobuf v1.36.7/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=

19
main.go
View File

@@ -5,12 +5,13 @@ import (
oclib "cloud.o-forge.io/core/oc-lib"
beego "github.com/beego/beego/v2/server/web"
"github.com/beego/beego/v2/server/web/filter/cors"
)
const appname = "oc-shared"
func main() {
// Init the oc-lib
// Init the oc-lib
oclib.Init(appname)
@@ -21,20 +22,22 @@ func main() {
oclib.SetConfig(
o.GetStringDefault("MONGO_URL", "mongodb://127.0.0.1:27017"),
o.GetStringDefault("MONGO_DATABASE", "DC_myDC"),
"",
o.GetStringDefault("NATS_URL", "nats://localhost:4222"),
o.GetStringDefault("LOKI_URL", ""),
o.GetStringDefault("LOG_LEVEL", "info"),
)
/* PATHS ARE REFERENCE FOR INNER SERVICE OF DISTANT OC
* PATHS ARE USED TO CALL OTHER OC SERVICES
* NAMES ARE CANONICAL NAMES OF THE SERVICES
*/
// Beego init
beego.BConfig.AppName = appname
beego.BConfig.Listen.HTTPPort = 8080
beego.BConfig.Listen.HTTPPort = o.GetIntDefault("port", 8080)
beego.BConfig.WebConfig.DirectoryIndex = true
beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
AllowAllOrigins: true,
AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
AllowHeaders: []string{"Origin", "Authorization", "Content-Type"},
ExposeHeaders: []string{"Content-Length", "Content-Type"},
AllowCredentials: true,
}))
beego.Run()
}

BIN
oc-shared

Binary file not shown.

View File

@@ -14,17 +14,17 @@ import (
)
func init() {
ns := beego.NewNamespace("/oc",
beego.NSNamespace("/shared/collaborative_area",
ns := beego.NewNamespace("/oc/",
beego.NSNamespace("/collaborative_area",
beego.NSInclude(
&controllers.CollaborativeAreaController{},
),
),
beego.NSNamespace("/shared/collaborative_area/rule",
beego.NSNamespace("/rule",
beego.NSInclude(
&controllers.RuleController{},
),
),
),
beego.NSNamespace("/version",
beego.NSInclude(
&controllers.VersionController{},

View File

@@ -1,5 +1,5 @@
{
"port":8080,
"port":8091,
"MONGO_URL":"mongodb://localhost:27017/",
"MONGO_DATABASE":"DC_myDC"
}

View File

@@ -9,19 +9,27 @@
"email": "admin@o-cloud.io"
},
"license": {
"name": "MIT",
"url": "https://opensource.org/license/mit"
"name": "AGPL",
"url": "https://www.gnu.org/licenses/agpl-3.0.html"
}
},
"basePath": "/oc",
"basePath": "/oc/",
"paths": {
"/shared/collaborative_area/": {
"/collaborative_area/": {
"get": {
"tags": [
"shared/collaborative_area"
"collaborative_area"
],
"description": "find shared workspace by id\n\u003cbr\u003e",
"operationId": "CollaborativeAreaController.GetAll",
"parameters": [
{
"in": "query",
"name": "is_draft",
"description": "draft wished",
"type": "string"
}
],
"responses": {
"200": {
"description": "{shared_workspace} models.shared_workspace"
@@ -30,7 +38,7 @@
},
"post": {
"tags": [
"shared/collaborative_area"
"collaborative_area"
],
"description": "create shared workspace\n\u003cbr\u003e",
"operationId": "CollaborativeAreaController.Create",
@@ -52,144 +60,10 @@
}
}
},
"/shared/collaborative_area/rule/": {
"/collaborative_area/search/{search}": {
"get": {
"tags": [
"shared/collaborative_area/rule"
],
"description": "find rule by id\n\u003cbr\u003e",
"operationId": "RuleController.GetAll",
"responses": {
"200": {
"description": "{rule} models.rule"
}
}
},
"post": {
"tags": [
"shared/collaborative_area/rule"
],
"description": "create rule\n\u003cbr\u003e",
"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/collaborative_area/rule/search/{search}": {
"get": {
"tags": [
"shared/collaborative_area/rule"
],
"description": "search rule\n\u003cbr\u003e",
"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/collaborative_area/rule/{id}": {
"get": {
"tags": [
"shared/collaborative_area/rule"
],
"description": "find rule by id\n\u003cbr\u003e",
"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/collaborative_area/rule"
],
"description": "create rules\n\u003cbr\u003e",
"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/collaborative_area/rule"
],
"description": "delete the rule\n\u003cbr\u003e",
"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/collaborative_area/search/{search}": {
"get": {
"tags": [
"shared/collaborative_area"
"collaborative_area"
],
"description": "search shared workspace\n\u003cbr\u003e",
"operationId": "CollaborativeAreaController.Search",
@@ -200,6 +74,12 @@
"description": "the word search you want to get",
"required": true,
"type": "string"
},
{
"in": "query",
"name": "is_draft",
"description": "draft wished",
"type": "string"
}
],
"responses": {
@@ -209,10 +89,10 @@
}
}
},
"/shared/collaborative_area/{id}": {
"/collaborative_area/{id}": {
"get": {
"tags": [
"shared/collaborative_area"
"collaborative_area"
],
"description": "find shared workspace by id\n\u003cbr\u003e",
"operationId": "CollaborativeAreaController.Get",
@@ -233,7 +113,7 @@
},
"put": {
"tags": [
"shared/collaborative_area"
"collaborative_area"
],
"description": "create shared workspaces\n\u003cbr\u003e",
"operationId": "CollaborativeAreaController.Update",
@@ -263,7 +143,7 @@
},
"delete": {
"tags": [
"shared/collaborative_area"
"collaborative_area"
],
"description": "delete the shared workspace\n\u003cbr\u003e",
"operationId": "CollaborativeAreaController.Delete",
@@ -283,10 +163,10 @@
}
}
},
"/shared/collaborative_area/{id}/peer/{id2}": {
"/collaborative_area/{id}/peer/{id2}": {
"post": {
"tags": [
"shared/collaborative_area"
"collaborative_area"
],
"description": "find shared workspace by id\n\u003cbr\u003e",
"operationId": "CollaborativeAreaController.Add Peer",
@@ -304,6 +184,15 @@
"description": "the id you want to add",
"required": true,
"type": "string"
},
{
"in": "body",
"name": "body",
"description": "The shared workspace content",
"required": true,
"schema": {
"$ref": "#/definitions/models.workspace"
}
}
],
"responses": {
@@ -314,7 +203,7 @@
},
"delete": {
"tags": [
"shared/collaborative_area"
"collaborative_area"
],
"description": "find shared workspace by id\n\u003cbr\u003e",
"operationId": "CollaborativeAreaController.Remove Peer",
@@ -341,10 +230,10 @@
}
}
},
"/shared/collaborative_area/{id}/rule/{id2}": {
"/collaborative_area/{id}/rule/{id2}": {
"post": {
"tags": [
"shared/collaborative_area"
"collaborative_area"
],
"description": "find shared workspace by id\n\u003cbr\u003e",
"operationId": "CollaborativeAreaController.Add Rule",
@@ -372,7 +261,7 @@
},
"delete": {
"tags": [
"shared/collaborative_area"
"collaborative_area"
],
"description": "find shared workspace by id\n\u003cbr\u003e",
"operationId": "CollaborativeAreaController.Remove Rule",
@@ -399,10 +288,10 @@
}
}
},
"/shared/collaborative_area/{id}/workflow/{id2}": {
"/collaborative_area/{id}/workflow/{id2}": {
"post": {
"tags": [
"shared/collaborative_area"
"collaborative_area"
],
"description": "find shared workspace by id\n\u003cbr\u003e",
"operationId": "CollaborativeAreaController.Add Workflow",
@@ -430,7 +319,7 @@
},
"delete": {
"tags": [
"shared/collaborative_area"
"collaborative_area"
],
"description": "find shared workspace by id\n\u003cbr\u003e",
"operationId": "CollaborativeAreaController.Remove Workflow",
@@ -457,10 +346,10 @@
}
}
},
"/shared/collaborative_area/{id}/workspace/{id2}": {
"/collaborative_area/{id}/workspace/{id2}": {
"post": {
"tags": [
"shared/collaborative_area"
"collaborative_area"
],
"description": "find shared workspace by id\n\u003cbr\u003e",
"operationId": "CollaborativeAreaController.Add Workspace",
@@ -488,10 +377,10 @@
},
"delete": {
"tags": [
"shared/collaborative_area"
"collaborative_area"
],
"description": "find shared workspace by id\n\u003cbr\u003e",
"operationId": "CollaborativeAreaController.Add Workspace",
"operationId": "CollaborativeAreaController.Remove Workspace",
"parameters": [
{
"in": "path",
@@ -560,13 +449,9 @@
},
"tags": [
{
"name": "shared/collaborative_area",
"name": "collaborative_area",
"description": "Operations about workspace\n"
},
{
"name": "shared/collaborative_area/rule",
"description": "Operations about rule\n"
},
{
"name": "version",
"description": "VersionController operations for Version\n"

View File

@@ -8,24 +8,29 @@ info:
contact:
email: admin@o-cloud.io
license:
name: MIT
url: https://opensource.org/license/mit
basePath: /oc
name: AGPL
url: https://www.gnu.org/licenses/agpl-3.0.html
basePath: /oc/
paths:
/shared/collaborative_area/:
/collaborative_area/:
get:
tags:
- shared/collaborative_area
- collaborative_area
description: |-
find shared workspace by id
<br>
operationId: CollaborativeAreaController.GetAll
parameters:
- in: query
name: is_draft
description: draft wished
type: string
responses:
"200":
description: '{shared_workspace} models.shared_workspace'
post:
tags:
- shared/collaborative_area
- collaborative_area
description: |-
create shared workspace
<br>
@@ -40,10 +45,10 @@ paths:
responses:
"200":
description: '{shared workspace} models.shared_workspace'
/shared/collaborative_area/{id}:
/collaborative_area/{id}:
get:
tags:
- shared/collaborative_area
- collaborative_area
description: |-
find shared workspace by id
<br>
@@ -59,7 +64,7 @@ paths:
description: '{shared workspace} models.shared_workspace'
put:
tags:
- shared/collaborative_area
- collaborative_area
description: |-
create shared workspaces
<br>
@@ -81,7 +86,7 @@ paths:
description: '{shared workspace} models.shared_workspace'
delete:
tags:
- shared/collaborative_area
- collaborative_area
description: |-
delete the shared workspace
<br>
@@ -95,10 +100,10 @@ paths:
responses:
"200":
description: '{shared workspace} delete success!'
/shared/collaborative_area/{id}/peer/{id2}:
/collaborative_area/{id}/peer/{id2}:
post:
tags:
- shared/collaborative_area
- collaborative_area
description: |-
find shared workspace by id
<br>
@@ -114,12 +119,18 @@ paths:
description: the id you want to add
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/collaborative_area
- collaborative_area
description: |-
find shared workspace by id
<br>
@@ -138,10 +149,10 @@ paths:
responses:
"200":
description: '{shared workspace} models.shared_workspace'
/shared/collaborative_area/{id}/rule/{id2}:
/collaborative_area/{id}/rule/{id2}:
post:
tags:
- shared/collaborative_area
- collaborative_area
description: |-
find shared workspace by id
<br>
@@ -162,7 +173,7 @@ paths:
description: '{shared workspace} models.shared_workspace'
delete:
tags:
- shared/collaborative_area
- collaborative_area
description: |-
find shared workspace by id
<br>
@@ -181,10 +192,10 @@ paths:
responses:
"200":
description: '{shared workspace} models.shared_workspace'
/shared/collaborative_area/{id}/workflow/{id2}:
/collaborative_area/{id}/workflow/{id2}:
post:
tags:
- shared/collaborative_area
- collaborative_area
description: |-
find shared workspace by id
<br>
@@ -205,7 +216,7 @@ paths:
description: '{shared workspace} models.shared_workspace'
delete:
tags:
- shared/collaborative_area
- collaborative_area
description: |-
find shared workspace by id
<br>
@@ -224,10 +235,10 @@ paths:
responses:
"200":
description: '{shared workspace} models.shared_workspace'
/shared/collaborative_area/{id}/workspace/{id2}:
/collaborative_area/{id}/workspace/{id2}:
post:
tags:
- shared/collaborative_area
- collaborative_area
description: |-
find shared workspace by id
<br>
@@ -248,11 +259,11 @@ paths:
description: '{shared workspace} models.shared_workspace'
delete:
tags:
- shared/collaborative_area
- collaborative_area
description: |-
find shared workspace by id
<br>
operationId: CollaborativeAreaController.Add Workspace
operationId: CollaborativeAreaController.Remove Workspace
parameters:
- in: path
name: id
@@ -267,110 +278,10 @@ paths:
responses:
"200":
description: '{shared workspace} models.shared_workspace'
/shared/collaborative_area/rule/:
/collaborative_area/search/{search}:
get:
tags:
- shared/collaborative_area/rule
description: |-
find rule by id
<br>
operationId: RuleController.GetAll
responses:
"200":
description: '{rule} models.rule'
post:
tags:
- shared/collaborative_area/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/collaborative_area/rule/{id}:
get:
tags:
- shared/collaborative_area/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/collaborative_area/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/collaborative_area/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/collaborative_area/rule/search/{search}:
get:
tags:
- shared/collaborative_area/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/collaborative_area/search/{search}:
get:
tags:
- shared/collaborative_area
- collaborative_area
description: |-
search shared workspace
<br>
@@ -381,6 +292,10 @@ paths:
description: the word search you want to get
required: true
type: string
- in: query
name: is_draft
description: draft wished
type: string
responses:
"200":
description: '{shared workspace} models.shared_workspace'
@@ -417,12 +332,9 @@ definitions:
title: workspace
type: object
tags:
- name: shared/collaborative_area
- name: collaborative_area
description: |
Operations about workspace
- name: shared/collaborative_area/rule
description: |
Operations about rule
- name: version
description: |
VersionController operations for Version