Extend
This commit is contained in:
@@ -63,7 +63,7 @@ func (o *GeneralController) GetAll() {
|
|||||||
o.ServeJSON()
|
o.ServeJSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
func Websocket(ctx context.Context, user string, groups []string, dataType int, conn *websocket.Conn) {
|
func Websocket(ctx context.Context, user string, groups []string, dataType int, conn *websocket.Conn, extend ...string) {
|
||||||
defer conn.Close()
|
defer conn.Close()
|
||||||
done := make(chan struct{})
|
done := make(chan struct{})
|
||||||
go func() {
|
go func() {
|
||||||
@@ -80,6 +80,8 @@ func Websocket(ctx context.Context, user string, groups []string, dataType int,
|
|||||||
close(ch)
|
close(ch)
|
||||||
infrastructure.SearchMu.Lock()
|
infrastructure.SearchMu.Lock()
|
||||||
delete(infrastructure.SearchStream, user)
|
delete(infrastructure.SearchStream, user)
|
||||||
|
delete(infrastructure.SearchStreamSeen, user)
|
||||||
|
delete(infrastructure.SearchStreamExtend, user)
|
||||||
infrastructure.SearchMu.Unlock()
|
infrastructure.SearchMu.Unlock()
|
||||||
}
|
}
|
||||||
fmt.Println("CLOSE !")
|
fmt.Println("CLOSE !")
|
||||||
|
|||||||
@@ -3,8 +3,10 @@ package controllers
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
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"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -36,6 +38,7 @@ func (o *PurchaseController) Post() {
|
|||||||
|
|
||||||
// @Title GetAll
|
// @Title GetAll
|
||||||
// @Description find compute by id
|
// @Description find compute by id
|
||||||
|
// @Param extend query string false "extend"
|
||||||
// @Param is_draft query string false "draft wished"
|
// @Param is_draft query string false "draft wished"
|
||||||
// @Param offset query string false "offset wished"
|
// @Param offset query string false "offset wished"
|
||||||
// @Param limit query string false "limit wished"
|
// @Param limit query string false "limit wished"
|
||||||
@@ -44,14 +47,21 @@ func (o *PurchaseController) Post() {
|
|||||||
func (o *PurchaseController) GetAll() {
|
func (o *PurchaseController) GetAll() {
|
||||||
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||||
isDraft := o.Ctx.Input.Query("is_draft")
|
isDraft := o.Ctx.Input.Query("is_draft")
|
||||||
|
extend := strings.Split(o.Ctx.Input.Query("extend"), ",")
|
||||||
offset, _ := strconv.Atoi(o.Ctx.Input.Query("offset"))
|
offset, _ := strconv.Atoi(o.Ctx.Input.Query("offset"))
|
||||||
limit, _ := strconv.Atoi(o.Ctx.Input.Query("limit"))
|
limit, _ := strconv.Atoi(o.Ctx.Input.Query("limit"))
|
||||||
o.Data["json"] = oclib.NewRequest(purchase_collection, user, peerID, groups, nil).LoadAll(isDraft == "true", int64(offset), int64(limit))
|
s := oclib.NewRequest(purchase_collection, user, peerID, groups, nil).LoadAll(isDraft == "true", int64(offset), int64(limit))
|
||||||
|
o.Data["json"] = map[string]interface{}{
|
||||||
|
"data": oclib.GetExtends(s.Data, extend...),
|
||||||
|
"code": 200,
|
||||||
|
"err": nil,
|
||||||
|
}
|
||||||
o.ServeJSON()
|
o.ServeJSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Title Get
|
// @Title Get
|
||||||
// @Description find compute by key word
|
// @Description find compute by key word
|
||||||
|
// @Param extend query string false "extend"
|
||||||
// @Param search path string true "the search you want to get"
|
// @Param search path string true "the search you want to get"
|
||||||
// @Param is_draft query string false "draft wished"
|
// @Param is_draft query string false "draft wished"
|
||||||
// @Param offset query string false "offset wished"
|
// @Param offset query string false "offset wished"
|
||||||
@@ -62,20 +72,38 @@ func (o *PurchaseController) Search() {
|
|||||||
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||||
isDraft := o.Ctx.Input.Query("is_draft")
|
isDraft := o.Ctx.Input.Query("is_draft")
|
||||||
search := o.Ctx.Input.Param(":search")
|
search := o.Ctx.Input.Param(":search")
|
||||||
|
extend := strings.Split(o.Ctx.Input.Query("extend"), ",")
|
||||||
offset, _ := strconv.Atoi(o.Ctx.Input.Query("offset"))
|
offset, _ := strconv.Atoi(o.Ctx.Input.Query("offset"))
|
||||||
limit, _ := strconv.Atoi(o.Ctx.Input.Query("limit"))
|
limit, _ := strconv.Atoi(o.Ctx.Input.Query("limit"))
|
||||||
o.Data["json"] = oclib.NewRequest(purchase_collection, user, peerID, groups, nil).Search(nil, search, isDraft == "true", int64(offset), int64(limit))
|
s := oclib.NewRequest(purchase_collection, user, peerID, groups, nil).Search(nil, search, isDraft == "true", int64(offset), int64(limit))
|
||||||
|
o.Data["json"] = map[string]interface{}{
|
||||||
|
"data": oclib.GetExtends(s.Data, extend...),
|
||||||
|
"code": 200,
|
||||||
|
"err": nil,
|
||||||
|
}
|
||||||
o.ServeJSON()
|
o.ServeJSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Title Get
|
// @Title Get
|
||||||
// @Description find compute by id
|
// @Description find compute by id
|
||||||
|
// @Param extend query string false "extend"
|
||||||
// @Param id path string true "the id you want to get"
|
// @Param id path string true "the id you want to get"
|
||||||
// @Success 200 {compute} models.compute
|
// @Success 200 {compute} models.compute
|
||||||
// @router /:id [get]
|
// @router /:id [get]
|
||||||
func (o *PurchaseController) Get() {
|
func (o *PurchaseController) Get() {
|
||||||
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||||
id := o.Ctx.Input.Param(":id")
|
id := o.Ctx.Input.Param(":id")
|
||||||
o.Data["json"] = oclib.NewRequest(purchase_collection, user, peerID, groups, nil).LoadOne(id)
|
extend := strings.Split(o.Ctx.Input.Query("extend"), ",")
|
||||||
|
data := oclib.NewRequest(purchase_collection, user, peerID, groups, nil).LoadOne(id)
|
||||||
|
if data.Data != nil {
|
||||||
|
m := oclib.GetExtend(data.Data, data.Data.Extend(extend...), map[tools.DataType]map[string]interface{}{})
|
||||||
|
o.Data["json"] = map[string]interface{}{
|
||||||
|
"data": m,
|
||||||
|
"code": 200,
|
||||||
|
"err": nil,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
o.Data["json"] = data
|
||||||
|
}
|
||||||
o.ServeJSON()
|
o.ServeJSON()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
|
|
||||||
oclib "cloud.o-forge.io/core/oc-lib"
|
oclib "cloud.o-forge.io/core/oc-lib"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/resources"
|
"cloud.o-forge.io/core/oc-lib/models/resources"
|
||||||
|
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||||
"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"
|
||||||
)
|
)
|
||||||
@@ -26,6 +27,9 @@ func resourceTypeEnum(t string, special bool) []oclib.LibDataEnum {
|
|||||||
if t == "compute" || t == "resource" {
|
if t == "compute" || t == "resource" {
|
||||||
e = append(e, oclib.LibDataEnum(oclib.COMPUTE_RESOURCE))
|
e = append(e, oclib.LibDataEnum(oclib.COMPUTE_RESOURCE))
|
||||||
}
|
}
|
||||||
|
if t == "service" || t == "resource" {
|
||||||
|
e = append(e, oclib.LibDataEnum(oclib.SERVICE_RESOURCE))
|
||||||
|
}
|
||||||
if t == "data" || t == "resource" {
|
if t == "data" || t == "resource" {
|
||||||
e = append(e, oclib.LibDataEnum(oclib.DATA_RESOURCE))
|
e = append(e, oclib.LibDataEnum(oclib.DATA_RESOURCE))
|
||||||
}
|
}
|
||||||
@@ -70,19 +74,20 @@ func (o *ResourceController) GetAll() {
|
|||||||
offset, _ := strconv.Atoi(o.Ctx.Input.Query("offset"))
|
offset, _ := strconv.Atoi(o.Ctx.Input.Query("offset"))
|
||||||
limit, _ := strconv.Atoi(o.Ctx.Input.Query("limit"))
|
limit, _ := strconv.Atoi(o.Ctx.Input.Query("limit"))
|
||||||
|
|
||||||
m := map[string][]map[string]interface{}{}
|
m := map[string][]utils.ShallowDBObject{}
|
||||||
for _, col := range o.collection(false) {
|
for _, col := range o.collection(false) {
|
||||||
if m[col.String()] == nil {
|
if m[col.String()] == nil {
|
||||||
m[col.String()] = []map[string]interface{}{}
|
m[col.String()] = []utils.ShallowDBObject{}
|
||||||
}
|
}
|
||||||
s := oclib.NewRequest(col, user, peerID, groups, nil).LoadAll(isDraft == "true", int64(offset), int64(limit))
|
s := oclib.NewRequest(col, user, peerID, groups, nil).LoadAll(isDraft == "true", int64(offset), int64(limit))
|
||||||
for _, d := range s.Data {
|
m[col.String()] = append(m[col.String()], s.Data...)
|
||||||
m[col.String()] = append(m[col.String()], oclib.GetExtend(d, d.Extend(extend...)))
|
}
|
||||||
}
|
mm := map[string]interface{}{}
|
||||||
|
for k, v := range m {
|
||||||
|
mm[k] = oclib.GetExtends(v, extend...)
|
||||||
}
|
}
|
||||||
o.Data["json"] = map[string]interface{}{
|
o.Data["json"] = map[string]interface{}{
|
||||||
"data": m,
|
"data": mm,
|
||||||
"code": 200,
|
"code": 200,
|
||||||
"err": nil,
|
"err": nil,
|
||||||
}
|
}
|
||||||
@@ -107,19 +112,21 @@ func (o *ResourceController) Search() {
|
|||||||
offset, _ := strconv.Atoi(o.Ctx.Input.Query("offset"))
|
offset, _ := strconv.Atoi(o.Ctx.Input.Query("offset"))
|
||||||
limit, _ := strconv.Atoi(o.Ctx.Input.Query("limit"))
|
limit, _ := strconv.Atoi(o.Ctx.Input.Query("limit"))
|
||||||
|
|
||||||
m := map[string][]map[string]interface{}{}
|
m := map[string][]utils.ShallowDBObject{}
|
||||||
|
fmt.Println(o.collection(false))
|
||||||
for _, col := range o.collection(false) {
|
for _, col := range o.collection(false) {
|
||||||
if m[col.String()] == nil {
|
if m[col.String()] == nil {
|
||||||
m[col.String()] = []map[string]interface{}{}
|
m[col.String()] = []utils.ShallowDBObject{}
|
||||||
}
|
}
|
||||||
s := oclib.NewRequest(col, user, peerID, groups, nil).Search(nil, search, isDraft == "true", int64(offset), int64(limit))
|
s := oclib.NewRequest(col, user, peerID, groups, nil).Search(nil, search, isDraft == "true", int64(offset), int64(limit))
|
||||||
for _, d := range s.Data {
|
m[col.String()] = append(m[col.String()], s.Data...)
|
||||||
m[col.String()] = append(m[col.String()], oclib.GetExtend(d, d.Extend(extend...)))
|
}
|
||||||
}
|
mm := map[string]interface{}{}
|
||||||
|
for k, v := range m {
|
||||||
|
mm[k] = oclib.GetExtends(v, extend...)
|
||||||
}
|
}
|
||||||
o.Data["json"] = map[string]interface{}{
|
o.Data["json"] = map[string]interface{}{
|
||||||
"data": m,
|
"data": mm,
|
||||||
"code": 200,
|
"code": 200,
|
||||||
"err": nil,
|
"err": nil,
|
||||||
}
|
}
|
||||||
@@ -163,22 +170,21 @@ func (o *ResourceController) SearchExtended() {
|
|||||||
limit, _ := strconv.Atoi(o.Ctx.Input.Query("limit"))
|
limit, _ := strconv.Atoi(o.Ctx.Input.Query("limit"))
|
||||||
var res map[string]interface{}
|
var res map[string]interface{}
|
||||||
json.Unmarshal(o.Ctx.Input.CopyBody(100000), &res)
|
json.Unmarshal(o.Ctx.Input.CopyBody(100000), &res)
|
||||||
m := map[string][]map[string]interface{}{}
|
m := map[string][]utils.ShallowDBObject{}
|
||||||
for _, col := range o.collection(false) {
|
for _, col := range o.collection(false) {
|
||||||
if m[col.String()] == nil {
|
if m[col.String()] == nil {
|
||||||
m[col.String()] = []map[string]interface{}{}
|
m[col.String()] = []utils.ShallowDBObject{}
|
||||||
}
|
}
|
||||||
fmt.Println(res, oclib.FiltersFromFlatMap(res, GetResource(col)))
|
|
||||||
|
|
||||||
s := oclib.NewRequest(col, user, peerID, groups, nil).Search(
|
s := oclib.NewRequest(col, user, peerID, groups, nil).Search(
|
||||||
oclib.FiltersFromFlatMap(res, GetResource(col)), "", isDraft == "true", int64(offset), int64(limit))
|
oclib.FiltersFromFlatMap(res, GetResource(col)), "", isDraft == "true", int64(offset), int64(limit))
|
||||||
for _, d := range s.Data {
|
m[col.String()] = append(m[col.String()], s.Data...)
|
||||||
m[col.String()] = append(m[col.String()], oclib.GetExtend(d, d.Extend(extend...)))
|
}
|
||||||
}
|
mm := map[string]interface{}{}
|
||||||
|
for k, v := range m {
|
||||||
|
mm[k] = oclib.GetExtends(v, extend...)
|
||||||
}
|
}
|
||||||
o.Data["json"] = map[string]interface{}{
|
o.Data["json"] = map[string]interface{}{
|
||||||
"data": m,
|
"data": mm,
|
||||||
"code": 200,
|
"code": 200,
|
||||||
"err": nil,
|
"err": nil,
|
||||||
}
|
}
|
||||||
@@ -197,10 +203,11 @@ func (o *ResourceController) Get() {
|
|||||||
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||||
id := o.Ctx.Input.Param(":id")
|
id := o.Ctx.Input.Param(":id")
|
||||||
extend := strings.Split(o.Ctx.Input.Query("extend"), ",")
|
extend := strings.Split(o.Ctx.Input.Query("extend"), ",")
|
||||||
fmt.Println(user, groups, peerID)
|
fmt.Println("COLLECTIOn", o.collection(false))
|
||||||
for _, col := range o.collection(false) {
|
for _, col := range o.collection(false) {
|
||||||
if d := oclib.NewRequest(col, user, peerID, groups, nil).LoadOne(id); d.Data != nil {
|
if d := oclib.NewRequest(col, user, peerID, groups, nil).LoadOne(id); d.Data != nil {
|
||||||
o.Data["json"] = oclib.GetExtend(d.Data, d.Data.Extend(extend...))
|
fmt.Println("EXTEND", d.Data.Extend(extend...), extend)
|
||||||
|
o.Data["json"] = oclib.GetExtend(d.Data, d.Data.Extend(extend...), map[tools.DataType]map[string]interface{}{})
|
||||||
break
|
break
|
||||||
} else {
|
} else {
|
||||||
o.Data["json"] = d
|
o.Data["json"] = d
|
||||||
|
|||||||
4
go.mod
4
go.mod
@@ -3,7 +3,7 @@ module oc-catalog
|
|||||||
go 1.25.0
|
go 1.25.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20260421124504-0c6efee27626
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260429050913-47d487ea8011
|
||||||
github.com/beego/beego/v2 v2.3.8
|
github.com/beego/beego/v2 v2.3.8
|
||||||
github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674
|
github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674
|
||||||
github.com/smartystreets/goconvey v1.7.2
|
github.com/smartystreets/goconvey v1.7.2
|
||||||
@@ -83,7 +83,7 @@ require (
|
|||||||
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect
|
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect
|
||||||
go.mongodb.org/mongo-driver v1.17.4 // indirect
|
go.mongodb.org/mongo-driver v1.17.4 // indirect
|
||||||
golang.org/x/crypto v0.44.0 // indirect
|
golang.org/x/crypto v0.44.0 // indirect
|
||||||
golang.org/x/net v0.47.0
|
golang.org/x/net v0.47.0 // indirect
|
||||||
golang.org/x/sync v0.18.0 // indirect
|
golang.org/x/sync v0.18.0 // indirect
|
||||||
golang.org/x/sys v0.38.0 // indirect
|
golang.org/x/sys v0.38.0 // indirect
|
||||||
golang.org/x/text v0.31.0 // indirect
|
golang.org/x/text v0.31.0 // indirect
|
||||||
|
|||||||
52
go.sum
52
go.sum
@@ -1,25 +1,37 @@
|
|||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20260330082109-a4ab3285e34c h1:M0y5jI9BO7fyi1nMa2S2hhY0jDbBC+Bg56+5tp9g/vs=
|
|
||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20260330082109-a4ab3285e34c/go.mod h1:+ENuvBfZdESSvecoqGY/wSvRlT3vinEolxKgwbOhUpA=
|
|
||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20260331181901-f3b5a54545ee h1:iJ1kgMbBOBIHwS4jHOVB5zFqOd7J9ZlweQBuchnmvT0=
|
|
||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20260331181901-f3b5a54545ee/go.mod h1:+ENuvBfZdESSvecoqGY/wSvRlT3vinEolxKgwbOhUpA=
|
|
||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20260401110447-20cac09f9d6f h1:yyp4UIBTEQWcmoD2T+Acb6dZfl7PWaLSRPwlpEOQxnE=
|
|
||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20260401110447-20cac09f9d6f/go.mod h1:+ENuvBfZdESSvecoqGY/wSvRlT3vinEolxKgwbOhUpA=
|
|
||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20260402074304-ad12f02a7024 h1:xxadsmNJoXdbzK+GsHtCLoKBmowe3n52iZtFZy0PVjk=
|
|
||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20260402074304-ad12f02a7024/go.mod h1:+ENuvBfZdESSvecoqGY/wSvRlT3vinEolxKgwbOhUpA=
|
|
||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20260402080126-2bc45557938b h1:jkvJ1+aiitFPlc+/8U1Z3Ss8UwxdUQhoh3NarZuT/ow=
|
|
||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20260402080126-2bc45557938b/go.mod h1:+ENuvBfZdESSvecoqGY/wSvRlT3vinEolxKgwbOhUpA=
|
|
||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20260403121807-913d9b3dfb0a h1:H7K91js08Vyx307MW6BwQ/kqNGTrQVMaR3xvrIrc2W8=
|
|
||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20260403121807-913d9b3dfb0a/go.mod h1:+ENuvBfZdESSvecoqGY/wSvRlT3vinEolxKgwbOhUpA=
|
|
||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20260407063242-2e9f4cb9f466 h1:1xy9pZenAkT1eHY+3ruzYimaLrCKRzYovJgjO61QSok=
|
|
||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20260407063242-2e9f4cb9f466/go.mod h1:+ENuvBfZdESSvecoqGY/wSvRlT3vinEolxKgwbOhUpA=
|
|
||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20260407073631-5dbe55e63081 h1:Fl08ZK6LrzkyFxxhTS+GAyEGiNR8kPvoBefo4iUVP/M=
|
|
||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20260407073631-5dbe55e63081/go.mod h1:+ENuvBfZdESSvecoqGY/wSvRlT3vinEolxKgwbOhUpA=
|
|
||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20260408143421-92eb2663bc69 h1:3QmJSTWSUoq1pVXsCLv0+nmmKBVwcdHXMp+GTFaVZQA=
|
|
||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20260408143421-92eb2663bc69/go.mod h1:+ENuvBfZdESSvecoqGY/wSvRlT3vinEolxKgwbOhUpA=
|
|
||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20260421123652-bbaea4fec401 h1:S4Bz4mudEx7IUthnHdmZVKwVmc2r2Tw5L6J9hYiXqr8=
|
|
||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20260421123652-bbaea4fec401/go.mod h1:JynnOb3eMr9VZW1mHq+Vsl3tzx6gPhPsGKpQD/dtEBc=
|
|
||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20260421124504-0c6efee27626 h1:JOXbpVUlz5D3ajT48+2N4lmULb+c4/o2WAAHc60XbeA=
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260421124504-0c6efee27626 h1:JOXbpVUlz5D3ajT48+2N4lmULb+c4/o2WAAHc60XbeA=
|
||||||
cloud.o-forge.io/core/oc-lib v0.0.0-20260421124504-0c6efee27626/go.mod h1:JynnOb3eMr9VZW1mHq+Vsl3tzx6gPhPsGKpQD/dtEBc=
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260421124504-0c6efee27626/go.mod h1:JynnOb3eMr9VZW1mHq+Vsl3tzx6gPhPsGKpQD/dtEBc=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260422071421-17a45eb5d1ee h1:G+Soi+DIicwNjJQ3kgI27ckHcXsEyRetHx65NXGQgkU=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260422071421-17a45eb5d1ee/go.mod h1:JynnOb3eMr9VZW1mHq+Vsl3tzx6gPhPsGKpQD/dtEBc=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260422071808-a08c9b084d11 h1:B2iakt1sH9i6UWZtXw1qUhixM+sDBG6Ef5U4N+G9bFI=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260422071808-a08c9b084d11/go.mod h1:JynnOb3eMr9VZW1mHq+Vsl3tzx6gPhPsGKpQD/dtEBc=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260422074816-6741e929ccf6 h1:nG/5E2c3eXHnmPP1WLOMemY0aij2xQe7nJ+rIkQi9mg=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260422074816-6741e929ccf6/go.mod h1:JynnOb3eMr9VZW1mHq+Vsl3tzx6gPhPsGKpQD/dtEBc=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260422082406-94e3ebbdd9bf h1:e4NDKCOep7uqKs6flEyU0C7Khxp1FK8oBTD2tbNUK9w=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260422082406-94e3ebbdd9bf/go.mod h1:JynnOb3eMr9VZW1mHq+Vsl3tzx6gPhPsGKpQD/dtEBc=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260422085552-da237b1d263c h1:W2Tp63hMA3N/pYs1M3+pvLNd6uMtV/IgZr4CiPbkO7s=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260422085552-da237b1d263c/go.mod h1:JynnOb3eMr9VZW1mHq+Vsl3tzx6gPhPsGKpQD/dtEBc=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260422091539-b92634ccbae2 h1:0/F7U0o+SANqqyQqJ1H3uRky6eUO+bBhGdFktfbaa30=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260422091539-b92634ccbae2/go.mod h1:JynnOb3eMr9VZW1mHq+Vsl3tzx6gPhPsGKpQD/dtEBc=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260422092532-5cda4fdd4010 h1:9yDRSmvuc5RzK0M/XLUihHk/NpVWuUVdGMmf05L8W/0=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260422092532-5cda4fdd4010/go.mod h1:JynnOb3eMr9VZW1mHq+Vsl3tzx6gPhPsGKpQD/dtEBc=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260422093821-c208e2ccefc8 h1:+m6/0EUoP97rEm+NYz4T8zZZwpjOaFv0FoVbEea4cjc=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260422093821-c208e2ccefc8/go.mod h1:JynnOb3eMr9VZW1mHq+Vsl3tzx6gPhPsGKpQD/dtEBc=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260422094708-51e2dcc40409 h1:Xy0Py1oEE/75L0PwO/MeWjwZDMmc+DkJHkGtFAh2WTY=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260422094708-51e2dcc40409/go.mod h1:JynnOb3eMr9VZW1mHq+Vsl3tzx6gPhPsGKpQD/dtEBc=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260422095416-a4366d3a09a4 h1:aGgx7WqqqGmJw7OC/FJkgYfVmCsdjYZPSytdZcamEUQ=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260422095416-a4366d3a09a4/go.mod h1:JynnOb3eMr9VZW1mHq+Vsl3tzx6gPhPsGKpQD/dtEBc=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260422121328-538496cd6015 h1:ak8z12vC07LI/lpB6B9KJ/nLZy9J+Ez14G1iNDjRdQY=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260422121328-538496cd6015/go.mod h1:JynnOb3eMr9VZW1mHq+Vsl3tzx6gPhPsGKpQD/dtEBc=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260423074839-e70e89b630b7 h1:WdExXiecLnST8a7gAh6Z9Xd1Q+0/EjTy1P+b9ABoga8=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260423074839-e70e89b630b7/go.mod h1:JynnOb3eMr9VZW1mHq+Vsl3tzx6gPhPsGKpQD/dtEBc=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260427091650-f048b420d74d h1:jzgwgbZDASalQJSYbPF/L2L2RSP2OAbqhMB4YUXK27M=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260427091650-f048b420d74d/go.mod h1:JynnOb3eMr9VZW1mHq+Vsl3tzx6gPhPsGKpQD/dtEBc=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260427105228-26fc02c5b236 h1:8beImgKDK7iwj0P9eJJ+pIlgHm7kCguCvjzztYjaSFs=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260427105228-26fc02c5b236/go.mod h1:JynnOb3eMr9VZW1mHq+Vsl3tzx6gPhPsGKpQD/dtEBc=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260427111114-318fd522895d h1:VDx58DIq91kA4IEDgWQ4alv32Djcp1y77yw56wmPEe0=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260427111114-318fd522895d/go.mod h1:JynnOb3eMr9VZW1mHq+Vsl3tzx6gPhPsGKpQD/dtEBc=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260429050913-47d487ea8011 h1:owV5pQ+mS5xDCKEcGTO+BgsyYrKjkISL8LDsmjEb/3s=
|
||||||
|
cloud.o-forge.io/core/oc-lib v0.0.0-20260429050913-47d487ea8011/go.mod h1:JynnOb3eMr9VZW1mHq+Vsl3tzx6gPhPsGKpQD/dtEBc=
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0=
|
github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0=
|
||||||
github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
|
github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
|
||||||
|
|||||||
@@ -478,7 +478,6 @@ func createDockerProcessingResource(
|
|||||||
},
|
},
|
||||||
Infrastructure: enum.DOCKER,
|
Infrastructure: enum.DOCKER,
|
||||||
OpenSource: true,
|
OpenSource: true,
|
||||||
IsService: false,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := range tags {
|
for i := range tags {
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ var ressourceCols = []oclib.LibDataEnum{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var SearchMu sync.RWMutex
|
var SearchMu sync.RWMutex
|
||||||
|
var SearchStreamExtend = map[string][]string{}
|
||||||
var SearchStream = map[string]chan []byte{}
|
var SearchStream = map[string]chan []byte{}
|
||||||
var SearchStreamSeen = map[string][]string{}
|
var SearchStreamSeen = map[string][]string{}
|
||||||
|
|
||||||
@@ -31,6 +32,7 @@ func EmitNATS(user string, groups []string, message tools.PropalgationMessage) {
|
|||||||
SearchMu.Lock()
|
SearchMu.Lock()
|
||||||
SearchStream[user] = make(chan []byte, 128)
|
SearchStream[user] = make(chan []byte, 128)
|
||||||
SearchStreamSeen[user] = make([]string, 128)
|
SearchStreamSeen[user] = make([]string, 128)
|
||||||
|
SearchStreamExtend[user] = make([]string, 128)
|
||||||
SearchMu.Unlock()
|
SearchMu.Unlock()
|
||||||
tools.NewNATSCaller().SetNATSPub(tools.PROPALGATION_EVENT, tools.NATSResponse{
|
tools.NewNATSCaller().SetNATSPub(tools.PROPALGATION_EVENT, tools.NATSResponse{
|
||||||
FromApp: "oc-catalog",
|
FromApp: "oc-catalog",
|
||||||
@@ -76,14 +78,21 @@ func ListenNATS() {
|
|||||||
p.SetNotInCatalog(true)
|
p.SetNotInCatalog(true)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SearchMu.Lock()
|
||||||
wrapped, merr := json.Marshal(map[string]interface{}{
|
wrapped, merr := json.Marshal(map[string]interface{}{
|
||||||
"dtype": p.GetType(),
|
"dtype": p.GetType(),
|
||||||
"data": p,
|
"data": p,
|
||||||
})
|
})
|
||||||
|
if a := SearchStreamExtend[resp.User]; len(a) > 0 {
|
||||||
|
wrapped, merr = json.Marshal(map[string]interface{}{
|
||||||
|
"dtype": p.GetType(),
|
||||||
|
"data": oclib.GetExtend(p, p.Extend(a...), map[tools.DataType]map[string]interface{}{}),
|
||||||
|
})
|
||||||
|
}
|
||||||
if merr != nil {
|
if merr != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
SearchMu.Lock()
|
|
||||||
if SearchStreamSeen[resp.User] != nil && slices.Contains(SearchStreamSeen[resp.User], p.GetID()) {
|
if SearchStreamSeen[resp.User] != nil && slices.Contains(SearchStreamSeen[resp.User], p.GetID()) {
|
||||||
SearchStream[resp.User] <- wrapped // TODO when do we update it in our catalog ?
|
SearchStream[resp.User] <- wrapped // TODO when do we update it in our catalog ?
|
||||||
}
|
}
|
||||||
|
|||||||
5
main.go
5
main.go
@@ -5,6 +5,7 @@ import (
|
|||||||
_ "oc-catalog/routers"
|
_ "oc-catalog/routers"
|
||||||
|
|
||||||
oclib "cloud.o-forge.io/core/oc-lib"
|
oclib "cloud.o-forge.io/core/oc-lib"
|
||||||
|
"cloud.o-forge.io/core/oc-lib/config"
|
||||||
"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"
|
||||||
)
|
)
|
||||||
@@ -22,5 +23,7 @@ func main() {
|
|||||||
go infrastructure.ListenNATS()
|
go infrastructure.ListenNATS()
|
||||||
go infrastructure.StartDockerScraper()
|
go infrastructure.StartDockerScraper()
|
||||||
|
|
||||||
beego.Run()
|
if config.GetConfig().IsApi {
|
||||||
|
beego.Run()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ func TypedSearchHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
search := parts[len(parts)-1]
|
search := parts[len(parts)-1]
|
||||||
dt := "resource"
|
dt := "resource"
|
||||||
t := "partner"
|
t := "partner"
|
||||||
|
extend := strings.Split(r.URL.Query().Get("extend"), ",")
|
||||||
if len(parts) >= 3 {
|
if len(parts) >= 3 {
|
||||||
dt = parts[len(parts)-3]
|
dt = parts[len(parts)-3]
|
||||||
}
|
}
|
||||||
@@ -51,14 +52,19 @@ func TypedSearchHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
if dataType <= 0 {
|
if dataType <= 0 {
|
||||||
dataType = -1
|
dataType = -1
|
||||||
}
|
}
|
||||||
user, _, groups := oclib.ExtractTokenInfo(*r)
|
user, _, groups := oclib.ExtractTokenInfoWs(*r)
|
||||||
b, _ := json.Marshal(map[string]string{"search": search, "type": t})
|
b, _ := json.Marshal(map[string]string{"search": search, "type": t})
|
||||||
infrastructure.EmitNATS(user, groups, tools.PropalgationMessage{
|
infrastructure.EmitNATS(user, groups, tools.PropalgationMessage{
|
||||||
Action: tools.PB_SEARCH,
|
Action: tools.PB_SEARCH,
|
||||||
DataType: dataType,
|
DataType: dataType,
|
||||||
Payload: b,
|
Payload: b,
|
||||||
})
|
})
|
||||||
controllers.Websocket(r.Context(), user, groups, dataType, conn)
|
if len(extend) > 0 {
|
||||||
|
controllers.Websocket(r.Context(), user, groups, dataType, conn, extend...)
|
||||||
|
} else {
|
||||||
|
controllers.Websocket(r.Context(), user, groups, dataType, conn)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|||||||
@@ -231,6 +231,12 @@
|
|||||||
"description": "find compute by id\n\u003cbr\u003e",
|
"description": "find compute by id\n\u003cbr\u003e",
|
||||||
"operationId": "PurchaseController.GetAll",
|
"operationId": "PurchaseController.GetAll",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "query",
|
||||||
|
"name": "extend",
|
||||||
|
"description": "extend",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"in": "query",
|
"in": "query",
|
||||||
"name": "is_draft",
|
"name": "is_draft",
|
||||||
@@ -288,6 +294,12 @@
|
|||||||
"description": "find compute by key word\n\u003cbr\u003e",
|
"description": "find compute by key word\n\u003cbr\u003e",
|
||||||
"operationId": "PurchaseController.Get",
|
"operationId": "PurchaseController.Get",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "query",
|
||||||
|
"name": "extend",
|
||||||
|
"description": "extend",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"in": "path",
|
"in": "path",
|
||||||
"name": "search",
|
"name": "search",
|
||||||
@@ -329,6 +341,12 @@
|
|||||||
"description": "find compute by id\n\u003cbr\u003e",
|
"description": "find compute by id\n\u003cbr\u003e",
|
||||||
"operationId": "PurchaseController.Get",
|
"operationId": "PurchaseController.Get",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "query",
|
||||||
|
"name": "extend",
|
||||||
|
"description": "extend",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"in": "path",
|
"in": "path",
|
||||||
"name": "id",
|
"name": "id",
|
||||||
@@ -352,6 +370,12 @@
|
|||||||
"description": "list all resources across all types\n\u003cbr\u003e",
|
"description": "list all resources across all types\n\u003cbr\u003e",
|
||||||
"operationId": "ResourceController.GetAll",
|
"operationId": "ResourceController.GetAll",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
|
{
|
||||||
|
"in": "query",
|
||||||
|
"name": "extend",
|
||||||
|
"description": "extend",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"in": "path",
|
"in": "path",
|
||||||
"name": "type",
|
"name": "type",
|
||||||
@@ -429,6 +453,12 @@
|
|||||||
"description": "false",
|
"description": "false",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"in": "query",
|
||||||
|
"name": "extend",
|
||||||
|
"description": "extend",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"in": "query",
|
"in": "query",
|
||||||
"name": "offset",
|
"name": "offset",
|
||||||
@@ -483,7 +513,13 @@
|
|||||||
{
|
{
|
||||||
"in": "query",
|
"in": "query",
|
||||||
"name": "is_draft",
|
"name": "is_draft",
|
||||||
"description": "draft wished",
|
"description": "draft wished$",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"in": "query",
|
||||||
|
"name": "extend",
|
||||||
|
"description": "extend",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -533,6 +569,12 @@
|
|||||||
"name": "is_draft",
|
"name": "is_draft",
|
||||||
"description": "draft wished",
|
"description": "draft wished",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"in": "query",
|
||||||
|
"name": "extend",
|
||||||
|
"description": "extend",
|
||||||
|
"type": "string"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
|
|||||||
@@ -183,6 +183,10 @@ paths:
|
|||||||
<br>
|
<br>
|
||||||
operationId: PurchaseController.GetAll
|
operationId: PurchaseController.GetAll
|
||||||
parameters:
|
parameters:
|
||||||
|
- in: query
|
||||||
|
name: extend
|
||||||
|
description: extend
|
||||||
|
type: string
|
||||||
- in: query
|
- in: query
|
||||||
name: is_draft
|
name: is_draft
|
||||||
description: draft wished
|
description: draft wished
|
||||||
@@ -224,6 +228,10 @@ paths:
|
|||||||
<br>
|
<br>
|
||||||
operationId: PurchaseController.Get
|
operationId: PurchaseController.Get
|
||||||
parameters:
|
parameters:
|
||||||
|
- in: query
|
||||||
|
name: extend
|
||||||
|
description: extend
|
||||||
|
type: string
|
||||||
- in: path
|
- in: path
|
||||||
name: id
|
name: id
|
||||||
description: the id you want to get
|
description: the id you want to get
|
||||||
@@ -241,6 +249,10 @@ paths:
|
|||||||
<br>
|
<br>
|
||||||
operationId: PurchaseController.Get
|
operationId: PurchaseController.Get
|
||||||
parameters:
|
parameters:
|
||||||
|
- in: query
|
||||||
|
name: extend
|
||||||
|
description: extend
|
||||||
|
type: string
|
||||||
- in: path
|
- in: path
|
||||||
name: search
|
name: search
|
||||||
description: the search you want to get
|
description: the search you want to get
|
||||||
@@ -270,6 +282,10 @@ paths:
|
|||||||
<br>
|
<br>
|
||||||
operationId: ResourceController.GetAll
|
operationId: ResourceController.GetAll
|
||||||
parameters:
|
parameters:
|
||||||
|
- in: query
|
||||||
|
name: extend
|
||||||
|
description: extend
|
||||||
|
type: string
|
||||||
- in: path
|
- in: path
|
||||||
name: type
|
name: type
|
||||||
description: the type you want to get
|
description: the type you want to get
|
||||||
@@ -335,6 +351,10 @@ paths:
|
|||||||
name: is_draft
|
name: is_draft
|
||||||
description: draft wished
|
description: draft wished
|
||||||
type: string
|
type: string
|
||||||
|
- in: query
|
||||||
|
name: extend
|
||||||
|
description: extend
|
||||||
|
type: string
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: '{resource} models.resource'
|
description: '{resource} models.resource'
|
||||||
@@ -403,6 +423,10 @@ paths:
|
|||||||
name: is_draft
|
name: is_draft
|
||||||
description: "false"
|
description: "false"
|
||||||
type: string
|
type: string
|
||||||
|
- in: query
|
||||||
|
name: extend
|
||||||
|
description: extend
|
||||||
|
type: string
|
||||||
- in: query
|
- in: query
|
||||||
name: offset
|
name: offset
|
||||||
description: "false"
|
description: "false"
|
||||||
@@ -441,7 +465,11 @@ paths:
|
|||||||
type: string
|
type: string
|
||||||
- in: query
|
- in: query
|
||||||
name: is_draft
|
name: is_draft
|
||||||
description: draft wished
|
description: draft wished$
|
||||||
|
type: string
|
||||||
|
- in: query
|
||||||
|
name: extend
|
||||||
|
description: extend
|
||||||
type: string
|
type: string
|
||||||
- in: query
|
- in: query
|
||||||
name: offset
|
name: offset
|
||||||
|
|||||||
Reference in New Issue
Block a user