From 96416bc259a538793c458c66d64807949fbe3350 Mon Sep 17 00:00:00 2001 From: mr Date: Tue, 15 Oct 2024 12:13:20 +0200 Subject: [PATCH] port --- controllers/resource.go | 29 ++++++++++++++++++++++++----- go.mod | 16 ++++++++-------- go.sum | 20 ++++++++++++++++++++ main.go | 2 +- 4 files changed, 53 insertions(+), 14 deletions(-) diff --git a/controllers/resource.go b/controllers/resource.go index 0776f95..0fd9b9d 100644 --- a/controllers/resource.go +++ b/controllers/resource.go @@ -16,7 +16,12 @@ type ResourceController struct { // @router / [get] func (o *ResourceController) GetAll() { results := map[string]interface{}{} - for _, resource := range []oclib.LibDataEnum{oclib.LibDataEnum(oclib.DATACENTER_RESOURCE), oclib.LibDataEnum(oclib.DATACENTER_RESOURCE), oclib.LibDataEnum(oclib.STORAGE_RESOURCE), oclib.LibDataEnum(oclib.PROCESSING_RESOURCE), oclib.LibDataEnum(oclib.WORKFLOW_RESOURCE)} { + for _, resource := range []oclib.LibDataEnum{ + oclib.LibDataEnum(oclib.DATA_RESOURCE), + oclib.LibDataEnum(oclib.DATACENTER_RESOURCE), + oclib.LibDataEnum(oclib.STORAGE_RESOURCE), + oclib.LibDataEnum(oclib.PROCESSING_RESOURCE), + oclib.LibDataEnum(oclib.WORKFLOW_RESOURCE)} { d := oclib.LoadAll(resource) if d.Code != 200 || len(d.Data) == 0 { results[resource.String()] = []interface{}{} @@ -36,7 +41,12 @@ func (o *ResourceController) GetAll() { func (o *ResourceController) Search() { search := o.Ctx.Input.Param(":search") results := map[string]interface{}{} - for _, resource := range []oclib.LibDataEnum{oclib.LibDataEnum(oclib.DATACENTER_RESOURCE), oclib.LibDataEnum(oclib.DATACENTER_RESOURCE), oclib.LibDataEnum(oclib.STORAGE_RESOURCE), oclib.LibDataEnum(oclib.PROCESSING_RESOURCE), oclib.LibDataEnum(oclib.WORKFLOW_RESOURCE)} { + for _, resource := range []oclib.LibDataEnum{ + oclib.LibDataEnum(oclib.DATA_RESOURCE), + oclib.LibDataEnum(oclib.DATACENTER_RESOURCE), + oclib.LibDataEnum(oclib.STORAGE_RESOURCE), + oclib.LibDataEnum(oclib.PROCESSING_RESOURCE), + oclib.LibDataEnum(oclib.WORKFLOW_RESOURCE)} { d := oclib.Search(nil, search, resource) if d.Code != 200 || len(d.Data) == 0 { results[resource.String()] = []interface{}{} @@ -56,8 +66,12 @@ func (o *ResourceController) Search() { func (o *ResourceController) Get() { id := o.Ctx.Input.Param(":id") results := map[string]interface{}{} - for _, resource := range []oclib.LibDataEnum{oclib.LibDataEnum(oclib.DATACENTER_RESOURCE), - oclib.LibDataEnum(oclib.DATACENTER_RESOURCE), oclib.LibDataEnum(oclib.STORAGE_RESOURCE), oclib.LibDataEnum(oclib.PROCESSING_RESOURCE), oclib.LibDataEnum(oclib.WORKFLOW_RESOURCE)} { + for _, resource := range []oclib.LibDataEnum{ + oclib.LibDataEnum(oclib.DATA_RESOURCE), + oclib.LibDataEnum(oclib.DATACENTER_RESOURCE), + oclib.LibDataEnum(oclib.STORAGE_RESOURCE), + oclib.LibDataEnum(oclib.PROCESSING_RESOURCE), + oclib.LibDataEnum(oclib.WORKFLOW_RESOURCE)} { d := oclib.LoadOne(resource, id) if d.Code != 200 { results[resource.String()] = nil @@ -77,7 +91,12 @@ func (o *ResourceController) Get() { func (o *ResourceController) Delete() { id := o.Ctx.Input.Param(":id") results := map[string]interface{}{} - for _, resource := range []oclib.LibDataEnum{oclib.LibDataEnum(oclib.DATACENTER_RESOURCE), oclib.LibDataEnum(oclib.DATACENTER_RESOURCE), oclib.LibDataEnum(oclib.STORAGE_RESOURCE), oclib.LibDataEnum(oclib.PROCESSING_RESOURCE), oclib.LibDataEnum(oclib.WORKFLOW_RESOURCE)} { + for _, resource := range []oclib.LibDataEnum{ + oclib.LibDataEnum(oclib.DATA_RESOURCE), + oclib.LibDataEnum(oclib.DATACENTER_RESOURCE), + oclib.LibDataEnum(oclib.STORAGE_RESOURCE), + oclib.LibDataEnum(oclib.PROCESSING_RESOURCE), + oclib.LibDataEnum(oclib.WORKFLOW_RESOURCE)} { d := oclib.DeleteOne(resource, id) if d.Code != 200 { results[resource.String()] = nil diff --git a/go.mod b/go.mod index d3af9ba..7725353 100644 --- a/go.mod +++ b/go.mod @@ -5,8 +5,8 @@ go 1.22.0 toolchain go1.22.4 require ( - cloud.o-forge.io/core/oc-lib v0.0.0-20240927112324-cdf513c2c454 - github.com/beego/beego/v2 v2.3.0 + cloud.o-forge.io/core/oc-lib v0.0.0-20241009111931-84024a143e67 + github.com/beego/beego/v2 v2.3.1 github.com/smartystreets/goconvey v1.7.2 ) @@ -49,12 +49,12 @@ require ( 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.0 // indirect - golang.org/x/crypto v0.27.0 // indirect - golang.org/x/net v0.29.0 // indirect + go.mongodb.org/mongo-driver v1.17.1 // indirect + golang.org/x/crypto v0.28.0 // indirect + golang.org/x/net v0.30.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 + golang.org/x/sys v0.26.0 // indirect + golang.org/x/text v0.19.0 // indirect + google.golang.org/protobuf v1.35.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 404d195..a0ddfec 100644 --- a/go.sum +++ b/go.sum @@ -4,9 +4,17 @@ cloud.o-forge.io/core/oc-lib v0.0.0-20240904122101-ad96b5046415 h1:X1i4EW0N9UNLn cloud.o-forge.io/core/oc-lib v0.0.0-20240904122101-ad96b5046415/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-20241007153821-ba6ac86bffaf h1:eFl+srvxX+SvVlTae14MC4o6f33oi0zsDDKyvoecPYA= +cloud.o-forge.io/core/oc-lib v0.0.0-20241007153821-ba6ac86bffaf/go.mod h1:t+zpCTVKVdHH/BImwtMYY2QIWLMXKgY4n/JhFm3Vpu8= +cloud.o-forge.io/core/oc-lib v0.0.0-20241009072916-ae49c40ea5e9 h1:UgN+WEjEJnQ1FFmSdRL7ilj0AfRQRhGQBeEqNRq+ly4= +cloud.o-forge.io/core/oc-lib v0.0.0-20241009072916-ae49c40ea5e9/go.mod h1:t+zpCTVKVdHH/BImwtMYY2QIWLMXKgY4n/JhFm3Vpu8= +cloud.o-forge.io/core/oc-lib v0.0.0-20241009111931-84024a143e67 h1:0CMdmukFqTrGv8smRCBYG2pVAFdZj4AEcyBhltyyqYM= +cloud.o-forge.io/core/oc-lib v0.0.0-20241009111931-84024a143e67/go.mod h1:t+zpCTVKVdHH/BImwtMYY2QIWLMXKgY4n/JhFm3Vpu8= 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/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= @@ -136,6 +144,8 @@ go.mongodb.org/mongo-driver v1.16.1 h1:rIVLL3q0IHM39dvE+z2ulZLp9ENZKThVfuvN/IiN4 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= 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= @@ -143,6 +153,8 @@ 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.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= +golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= 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= @@ -153,6 +165,8 @@ 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.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= +golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= 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= @@ -171,6 +185,8 @@ golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= 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.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= +golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= 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= @@ -181,6 +197,8 @@ golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= 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.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= +golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= 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= @@ -188,6 +206,8 @@ 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.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= +google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= 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= diff --git a/main.go b/main.go index 38c343a..60ce2cf 100644 --- a/main.go +++ b/main.go @@ -26,7 +26,7 @@ func main() { ) // 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"