copy resource in workflow

This commit is contained in:
mr 2024-07-30 12:08:13 +02:00
parent 250fefd0d8
commit 5405e91167
20 changed files with 194 additions and 33 deletions

View File

@ -0,0 +1,71 @@
package resource_model
import (
"encoding/json"
"cloud.o-forge.io/core/oc-lib/models/utils"
"github.com/google/uuid"
)
type AbstractResource struct {
utils.AbstractObject
ShortDescription string `json:"short_description,omitempty" bson:"short_description,omitempty" validate:"required"`
Description string `json:"description,omitempty" bson:"description,omitempty"`
Logo string `json:"logo,omitempty" bson:"logo,omitempty" validate:"required"`
Owner string `json:"owner,omitempty" bson:"owner,omitempty" validate:"required"`
OwnerLogo string `json:"owner_logo,omitempty" bson:"owner_logo,omitempty"`
SourceUrl string `json:"source_url,omitempty" bson:"source_url,omitempty" validate:"required"`
Price string `json:"price,omitempty" bson:"price,omitempty"`
License string `json:"license,omitempty" bson:"license,omitempty"`
ResourceModel *ResourceModel `json:"resource_model,omitempty" bson:"resource_model,omitempty"`
//Proxy *ResourceProxy `json:"proxy,omitempty" bson:"proxy,omitempty"`
}
type Model struct {
Type string `json:"type,omitempty" bson:"type,omitempty"`
Value interface{} `json:"value,omitempty" bson:"value,omitempty"`
ReadOnly bool `json:"readonly,omitempty" bson:"readonly,omitempty"`
}
type ResourceModel struct {
UUID string `json:"id,omitempty" bson:"id,omitempty" validate:"required"`
ResourceType string `json:"resource_type,omitempty" bson:"resource_type,omitempty" validate:"required"`
Model map[string]Model `json:"model,omitempty" bson:"model,omitempty"`
}
func (ao *ResourceModel) GetID() string {
return ao.UUID
}
func (r *ResourceModel) GenerateID() {
r.UUID = uuid.New().String()
}
func (d *ResourceModel) GetName() string {
return d.UUID
}
func (d *ResourceModel) GetAccessor() utils.Accessor {
data := &ResourceModelMongoAccessor{}
data.SetLogger(utils.RESOURCE_MODEL)
return data
}
func (dma *ResourceModel) Deserialize(j map[string]interface{}) utils.DBObject {
b, err := json.Marshal(j)
if err != nil {
return nil
}
json.Unmarshal(b, dma)
return dma
}
func (dma *ResourceModel) Serialize() map[string]interface{} {
var m map[string]interface{}
b, err := json.Marshal(dma)
if err != nil {
return nil
}
json.Unmarshal(b, &m)
return m
}

View File

@ -0,0 +1,71 @@
package resource_model
import (
"cloud.o-forge.io/core/oc-lib/dbs/mongo"
"cloud.o-forge.io/core/oc-lib/models/utils"
)
type ResourceModelMongoAccessor struct {
utils.AbstractAccessor
}
func (wfa *ResourceModelMongoAccessor) DeleteOne(id string) (utils.DBObject, int, error) {
return wfa.GenericDeleteOne(id, wfa)
}
func (wfa *ResourceModelMongoAccessor) UpdateOne(set utils.DBObject, id string) (utils.DBObject, int, error) {
return wfa.GenericUpdateOne(set, id, wfa, &ResourceModel{})
}
func (wfa *ResourceModelMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, int, error) {
return wfa.GenericStoreOne(data, wfa)
}
func (wfa *ResourceModelMongoAccessor) CopyOne(data utils.DBObject) (utils.DBObject, int, error) {
return wfa.GenericStoreOne(data, wfa)
}
func (wfa *ResourceModelMongoAccessor) LoadOne(id string) (utils.DBObject, int, error) {
var workflow ResourceModel
res_mongo, code, err := mongo.MONGOService.LoadOne(id, wfa.GetType())
if err != nil {
wfa.Logger.Error().Msg("Could not retrieve " + id + " from db. Error: " + err.Error())
return nil, code, err
}
res_mongo.Decode(&workflow)
return &workflow, 200, nil
}
func (wfa ResourceModelMongoAccessor) LoadAll() ([]utils.ShallowDBObject, int, error) {
objs := []utils.ShallowDBObject{}
res_mongo, code, err := mongo.MONGOService.LoadAll(wfa.GetType())
if err != nil {
wfa.Logger.Error().Msg("Could not retrieve any from db. Error: " + err.Error())
return nil, code, err
}
var results []ResourceModel
if err = res_mongo.All(mongo.MngoCtx, &results); err != nil {
return nil, 404, err
}
for _, r := range results {
objs = append(objs, &r)
}
return objs, 200, nil
}
func (wfa *ResourceModelMongoAccessor) Search(word string) ([]utils.ShallowDBObject, int, error) {
objs := []utils.ShallowDBObject{}
res_mongo, code, err := mongo.MONGOService.Search(word, []string{"resource_type"}, wfa.GetType())
if err != nil {
wfa.Logger.Error().Msg("Could not store to db. Error: " + err.Error())
return nil, code, err
}
var results []ResourceModel
if err = res_mongo.All(mongo.MngoCtx, &results); err != nil {
return nil, 404, err
}
for _, r := range results {
objs = append(objs, &r)
}
return objs, 200, nil
}

View File

@ -3,11 +3,12 @@ package data
import ( import (
"encoding/json" "encoding/json"
"cloud.o-forge.io/core/oc-lib/models/resource_model"
"cloud.o-forge.io/core/oc-lib/models/utils" "cloud.o-forge.io/core/oc-lib/models/utils"
) )
type DataResource struct { type DataResource struct {
utils.AbstractResource resource_model.AbstractResource
Protocols []string `json:"protocol,omitempty" bson:"protocol,omitempty"` //TODO Enum type Protocols []string `json:"protocol,omitempty" bson:"protocol,omitempty"` //TODO Enum type
DataType string `json:"datatype,omitempty" bson:"datatype,omitempty"` DataType string `json:"datatype,omitempty" bson:"datatype,omitempty"`
Example string `json:"example,omitempty" bson:"example,omitempty" description:"base64 encoded data"` Example string `json:"example,omitempty" bson:"example,omitempty" description:"base64 encoded data"`

View File

@ -14,10 +14,12 @@ func (dma *DataMongoAccessor) DeleteOne(id string) (utils.DBObject, int, error)
} }
func (dma *DataMongoAccessor) UpdateOne(set utils.DBObject, id string) (utils.DBObject, int, error) { func (dma *DataMongoAccessor) UpdateOne(set utils.DBObject, id string) (utils.DBObject, int, error) {
set.(*DataResource).ResourceModel = nil
return dma.GenericUpdateOne(set, id, dma, &DataResource{}) return dma.GenericUpdateOne(set, id, dma, &DataResource{})
} }
func (dma *DataMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, int, error) { func (dma *DataMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, int, error) {
data.(*DataResource).ResourceModel = nil
return dma.GenericStoreOne(data, dma) return dma.GenericStoreOne(data, dma)
} }

View File

@ -3,6 +3,7 @@ package data
import ( import (
"testing" "testing"
"cloud.o-forge.io/core/oc-lib/models/resource_model"
"cloud.o-forge.io/core/oc-lib/models/utils" "cloud.o-forge.io/core/oc-lib/models/utils"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
@ -10,7 +11,7 @@ import (
func TestStoreOneData(t *testing.T) { func TestStoreOneData(t *testing.T) {
d := DataResource{DataType: "jpeg", Example: "123456", d := DataResource{DataType: "jpeg", Example: "123456",
AbstractResource: utils.AbstractResource{ AbstractResource: resource_model.AbstractResource{
AbstractObject: utils.AbstractObject{Name: "testData"}, AbstractObject: utils.AbstractObject{Name: "testData"},
Description: "Lorem Ipsum", Description: "Lorem Ipsum",
Logo: "azerty.com", Logo: "azerty.com",
@ -28,7 +29,7 @@ func TestStoreOneData(t *testing.T) {
func TestLoadOneDate(t *testing.T) { func TestLoadOneDate(t *testing.T) {
d := DataResource{DataType: "jpeg", Example: "123456", d := DataResource{DataType: "jpeg", Example: "123456",
AbstractResource: utils.AbstractResource{ AbstractResource: resource_model.AbstractResource{
AbstractObject: utils.AbstractObject{Name: "testData"}, AbstractObject: utils.AbstractObject{Name: "testData"},
Description: "Lorem Ipsum", Description: "Lorem Ipsum",
Logo: "azerty.com", Logo: "azerty.com",

View File

@ -3,11 +3,12 @@ package datacenter
import ( import (
"encoding/json" "encoding/json"
"cloud.o-forge.io/core/oc-lib/models/resource_model"
"cloud.o-forge.io/core/oc-lib/models/utils" "cloud.o-forge.io/core/oc-lib/models/utils"
) )
type DatacenterResource struct { type DatacenterResource struct {
utils.AbstractResource resource_model.AbstractResource
CPUs []*CPU `bson:"cpus,omitempty" json:"cpus,omitempty"` CPUs []*CPU `bson:"cpus,omitempty" json:"cpus,omitempty"`
RAM *RAM `bson:"ram,omitempty" json:"ram,omitempty"` RAM *RAM `bson:"ram,omitempty" json:"ram,omitempty"`
GPUs []*GPU `bson:"gpus,omitempty" json:"gpus,omitempty"` GPUs []*GPU `bson:"gpus,omitempty" json:"gpus,omitempty"`

View File

@ -14,10 +14,12 @@ func (dca *DatacenterMongoAccessor) DeleteOne(id string) (utils.DBObject, int, e
} }
func (dca *DatacenterMongoAccessor) UpdateOne(set utils.DBObject, id string) (utils.DBObject, int, error) { func (dca *DatacenterMongoAccessor) UpdateOne(set utils.DBObject, id string) (utils.DBObject, int, error) {
set.(*DatacenterResource).ResourceModel = nil
return dca.GenericUpdateOne(set, id, dca, &DatacenterResource{}) return dca.GenericUpdateOne(set, id, dca, &DatacenterResource{})
} }
func (dca *DatacenterMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, int, error) { func (dca *DatacenterMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, int, error) {
data.(*DatacenterResource).ResourceModel = nil
return dca.GenericStoreOne(data, dca) return dca.GenericStoreOne(data, dca)
} }

View File

@ -3,6 +3,7 @@ package datacenter
import ( import (
"testing" "testing"
"cloud.o-forge.io/core/oc-lib/models/resource_model"
"cloud.o-forge.io/core/oc-lib/models/utils" "cloud.o-forge.io/core/oc-lib/models/utils"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
@ -10,7 +11,7 @@ import (
func TestStoreOneDatacenter(t *testing.T) { func TestStoreOneDatacenter(t *testing.T) {
dc := DatacenterResource{ dc := DatacenterResource{
AbstractResource: utils.AbstractResource{ AbstractResource: resource_model.AbstractResource{
AbstractObject: utils.AbstractObject{Name: "testDatacenter"}, AbstractObject: utils.AbstractObject{Name: "testDatacenter"},
Description: "Lorem Ipsum", Description: "Lorem Ipsum",
Logo: "azerty.com", Logo: "azerty.com",
@ -28,7 +29,7 @@ func TestStoreOneDatacenter(t *testing.T) {
func TestLoadOneDatacenter(t *testing.T) { func TestLoadOneDatacenter(t *testing.T) {
dc := DatacenterResource{ dc := DatacenterResource{
AbstractResource: utils.AbstractResource{ AbstractResource: resource_model.AbstractResource{
AbstractObject: utils.AbstractObject{Name: "testDatacenter"}, AbstractObject: utils.AbstractObject{Name: "testDatacenter"},
Description: "Lorem Ipsum", Description: "Lorem Ipsum",
Logo: "azerty.com", Logo: "azerty.com",

View File

@ -3,12 +3,13 @@ package processing
import ( import (
"encoding/json" "encoding/json"
"cloud.o-forge.io/core/oc-lib/models/resource_model"
"cloud.o-forge.io/core/oc-lib/models/resources/datacenter" "cloud.o-forge.io/core/oc-lib/models/resources/datacenter"
"cloud.o-forge.io/core/oc-lib/models/utils" "cloud.o-forge.io/core/oc-lib/models/utils"
) )
type ProcessingResource struct { type ProcessingResource struct {
utils.AbstractResource resource_model.AbstractResource
CPUs []*datacenter.CPU `bson:"cpus,omitempty" json:"cp_us,omitempty"` CPUs []*datacenter.CPU `bson:"cpus,omitempty" json:"cp_us,omitempty"`
GPUs []*datacenter.GPU `bson:"gpus,omitempty" json:"gp_us,omitempty"` GPUs []*datacenter.GPU `bson:"gpus,omitempty" json:"gp_us,omitempty"`
RAM datacenter.RAM `bson:"ram,omitempty" json:"ram,omitempty"` RAM datacenter.RAM `bson:"ram,omitempty" json:"ram,omitempty"`

View File

@ -14,10 +14,12 @@ func (pma *ProcessingMongoAccessor) DeleteOne(id string) (utils.DBObject, int, e
} }
func (pma *ProcessingMongoAccessor) UpdateOne(set utils.DBObject, id string) (utils.DBObject, int, error) { func (pma *ProcessingMongoAccessor) UpdateOne(set utils.DBObject, id string) (utils.DBObject, int, error) {
set.(*ProcessingResource).ResourceModel = nil
return pma.GenericUpdateOne(set, id, pma, &ProcessingResource{}) return pma.GenericUpdateOne(set, id, pma, &ProcessingResource{})
} }
func (pma *ProcessingMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, int, error) { func (pma *ProcessingMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, int, error) {
data.(*ProcessingResource).ResourceModel = nil
return pma.GenericStoreOne(data, pma) return pma.GenericStoreOne(data, pma)
} }

View File

@ -16,7 +16,7 @@ import (
type ResourceSet struct { type ResourceSet struct {
Datas []string `bson:"datas,omitempty" json:"datas,omitempty"` Datas []string `bson:"datas,omitempty" json:"datas,omitempty"`
Storages []string `bson:"storages,omitempty" json:"storages,omitempty"` Storages []string `bson:"storages,omitempty" json:"storages,omitempty"`
Processings []string `bson:"processing,omitempty" json:"processing,omitempty"` Processings []string `bson:"processings,omitempty" json:"processings,omitempty"`
Datacenters []string `bson:"datacenters,omitempty" json:"datacenters,omitempty"` Datacenters []string `bson:"datacenters,omitempty" json:"datacenters,omitempty"`
Workflows []string `bson:"workflows,omitempty" json:"workflows,omitempty"` Workflows []string `bson:"workflows,omitempty" json:"workflows,omitempty"`
@ -26,3 +26,11 @@ type ResourceSet struct {
DatacenterResources []*datacenter.DatacenterResource `bson:"-" json:"datacenter_resources,omitempty"` DatacenterResources []*datacenter.DatacenterResource `bson:"-" json:"datacenter_resources,omitempty"`
WorkflowResources []*w.WorkflowResource `bson:"-" json:"workflow_resources,omitempty"` WorkflowResources []*w.WorkflowResource `bson:"-" json:"workflow_resources,omitempty"`
} }
type ItemResource struct {
Data data.DataResource `bson:"data,omitempty" json:"data,omitempty"`
Processing processing.ProcessingResource `bson:"processing,omitempty" json:"processing,omitempty"`
Storage storage.StorageResource `bson:"storage,omitempty" json:"storage,omitempty"`
Datacenter datacenter.DatacenterResource `bson:"datacenter,omitempty" json:"datacenter,omitempty"`
Workflow w.WorkflowResource `bson:"workflow,omitempty" json:"workflow,omitempty"`
}

View File

@ -3,6 +3,7 @@ package storage
import ( import (
"encoding/json" "encoding/json"
"cloud.o-forge.io/core/oc-lib/models/resource_model"
"cloud.o-forge.io/core/oc-lib/models/utils" "cloud.o-forge.io/core/oc-lib/models/utils"
) )
@ -12,7 +13,7 @@ type URL struct {
} }
type StorageResource struct { type StorageResource struct {
utils.AbstractResource resource_model.AbstractResource
Acronym string `bson:"acronym,omitempty" json:"acronym,omitempty"` Acronym string `bson:"acronym,omitempty" json:"acronym,omitempty"`
Type string `bson:"type,omitempty" json:"type,omitempty"` Type string `bson:"type,omitempty" json:"type,omitempty"`
Size uint `bson:"size,omitempty" json:"size,omitempty"` Size uint `bson:"size,omitempty" json:"size,omitempty"`

View File

@ -14,10 +14,12 @@ func (sma *StorageMongoAccessor) DeleteOne(id string) (utils.DBObject, int, erro
} }
func (sma *StorageMongoAccessor) UpdateOne(set utils.DBObject, id string) (utils.DBObject, int, error) { func (sma *StorageMongoAccessor) UpdateOne(set utils.DBObject, id string) (utils.DBObject, int, error) {
set.(*StorageResource).ResourceModel = nil
return sma.GenericUpdateOne(set, id, sma, &StorageResource{}) return sma.GenericUpdateOne(set, id, sma, &StorageResource{})
} }
func (sma *StorageMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, int, error) { func (sma *StorageMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, int, error) {
data.(*StorageResource).ResourceModel = nil
return sma.GenericStoreOne(data, sma) return sma.GenericStoreOne(data, sma)
} }

View File

@ -3,6 +3,7 @@ package storage
import ( import (
"testing" "testing"
"cloud.o-forge.io/core/oc-lib/models/resource_model"
"cloud.o-forge.io/core/oc-lib/models/utils" "cloud.o-forge.io/core/oc-lib/models/utils"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
@ -10,7 +11,7 @@ import (
func TestStoreOneStorage(t *testing.T) { func TestStoreOneStorage(t *testing.T) {
s := StorageResource{Size: 123, Url: &URL{Protocol: "http", Path: "azerty.fr"}, s := StorageResource{Size: 123, Url: &URL{Protocol: "http", Path: "azerty.fr"},
AbstractResource: utils.AbstractResource{ AbstractResource: resource_model.AbstractResource{
AbstractObject: utils.AbstractObject{Name: "testData"}, AbstractObject: utils.AbstractObject{Name: "testData"},
Description: "Lorem Ipsum", Description: "Lorem Ipsum",
Logo: "azerty.com", Logo: "azerty.com",
@ -28,7 +29,7 @@ func TestStoreOneStorage(t *testing.T) {
func TestLoadOneStorage(t *testing.T) { func TestLoadOneStorage(t *testing.T) {
s := StorageResource{Size: 123, Url: &URL{Protocol: "http", Path: "azerty.fr"}, s := StorageResource{Size: 123, Url: &URL{Protocol: "http", Path: "azerty.fr"},
AbstractResource: utils.AbstractResource{ AbstractResource: resource_model.AbstractResource{
AbstractObject: utils.AbstractObject{Name: "testData"}, AbstractObject: utils.AbstractObject{Name: "testData"},
Description: "Lorem Ipsum", Description: "Lorem Ipsum",
Logo: "azerty.com", Logo: "azerty.com",

View File

@ -1,5 +1,7 @@
package graph package graph
import "cloud.o-forge.io/core/oc-lib/models/resources"
type Graph struct { type Graph struct {
Items map[string]GraphItem `bson:"items" json:"items" default:"{}" validate:"required"` Items map[string]GraphItem `bson:"items" json:"items" default:"{}" validate:"required"`
Links []GraphLink `bson:"links" json:"links" default:"{}" validate:"required"` Links []GraphLink `bson:"links" json:"links" default:"{}" validate:"required"`
@ -10,7 +12,7 @@ type GraphItem struct {
Width float64 `bson:"width" json:"width" validate:"required"` Width float64 `bson:"width" json:"width" validate:"required"`
Height float64 `bson:"height" json:"height" validate:"required"` Height float64 `bson:"height" json:"height" validate:"required"`
Position Position `bson:"position" json:"position" validate:"required"` Position Position `bson:"position" json:"position" validate:"required"`
ResourceID string `bson:"resource_id" json:"resource_id" validate:"required"` resources.ItemResource
} }
type GraphLink struct { type GraphLink struct {

View File

@ -3,11 +3,12 @@ package oclib
import ( import (
"encoding/json" "encoding/json"
"cloud.o-forge.io/core/oc-lib/models/resource_model"
"cloud.o-forge.io/core/oc-lib/models/utils" "cloud.o-forge.io/core/oc-lib/models/utils"
) )
type WorkflowResource struct { type WorkflowResource struct {
utils.AbstractResource resource_model.AbstractResource
WorkflowID string `bson:"workflow_id,omitempty" json:"workflow_id,omitempty"` WorkflowID string `bson:"workflow_id,omitempty" json:"workflow_id,omitempty"`
} }

View File

@ -14,10 +14,12 @@ func (wfa *WorkflowResourceMongoAccessor) DeleteOne(id string) (utils.DBObject,
} }
func (wfa *WorkflowResourceMongoAccessor) UpdateOne(set utils.DBObject, id string) (utils.DBObject, int, error) { func (wfa *WorkflowResourceMongoAccessor) UpdateOne(set utils.DBObject, id string) (utils.DBObject, int, error) {
set.(*WorkflowResource).ResourceModel = nil
return wfa.GenericUpdateOne(set, id, wfa, &WorkflowResource{}) return wfa.GenericUpdateOne(set, id, wfa, &WorkflowResource{})
} }
func (wfa *WorkflowResourceMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, int, error) { func (wfa *WorkflowResourceMongoAccessor) StoreOne(data utils.DBObject) (utils.DBObject, int, error) {
data.(*WorkflowResource).ResourceModel = nil
return wfa.GenericStoreOne(data, wfa) return wfa.GenericStoreOne(data, wfa)
} }

View File

@ -3,13 +3,14 @@ package oclib
import ( import (
"testing" "testing"
"cloud.o-forge.io/core/oc-lib/models/resource_model"
"cloud.o-forge.io/core/oc-lib/models/utils" "cloud.o-forge.io/core/oc-lib/models/utils"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
func TestStoreOneWorkflow(t *testing.T) { func TestStoreOneWorkflow(t *testing.T) {
w := WorkflowResource{AbstractResource: utils.AbstractResource{ w := WorkflowResource{AbstractResource: resource_model.AbstractResource{
AbstractObject: utils.AbstractObject{Name: "testWorkflow"}, AbstractObject: utils.AbstractObject{Name: "testWorkflow"},
Description: "Lorem Ipsum", Description: "Lorem Ipsum",
Logo: "azerty.com", Logo: "azerty.com",
@ -26,7 +27,7 @@ func TestStoreOneWorkflow(t *testing.T) {
} }
func TestLoadOneWorkflow(t *testing.T) { func TestLoadOneWorkflow(t *testing.T) {
w := WorkflowResource{AbstractResource: utils.AbstractResource{ w := WorkflowResource{AbstractResource: resource_model.AbstractResource{
AbstractObject: utils.AbstractObject{Name: "testWorkflow"}, AbstractObject: utils.AbstractObject{Name: "testWorkflow"},
Description: "Lorem Ipsum", Description: "Lorem Ipsum",
Logo: "azerty.com", Logo: "azerty.com",

View File

@ -91,20 +91,7 @@ func (dma *AbstractAccessor) GenericUpdateOne(set DBObject, id string, accessor
return accessor.LoadOne(id) return accessor.LoadOne(id)
} }
type AbstractResource struct { /*
AbstractObject
ShortDescription string `json:"short_description,omitempty" bson:"short_description,omitempty" validate:"required"`
Description string `json:"description,omitempty" bson:"description,omitempty"`
Logo string `json:"logo,omitempty" bson:"logo,omitempty" validate:"required"`
Owner string `json:"owner,omitempty" bson:"owner,omitempty" validate:"required"`
OwnerLogo string `json:"owner_logo,omitempty" bson:"owner_logo,omitempty"`
SourceUrl string `json:"source_url,omitempty" bson:"source_url,omitempty" validate:"required"`
Price string `json:"price,omitempty" bson:"price,omitempty"`
License string `json:"license,omitempty" bson:"license,omitempty"`
Inputs []interface{} `json:"inputs,omitempty" bson:"inputs,omitempty"`
Outputs []interface{} `json:"outputs,omitempty" bson:"outputs,omitempty"`
Proxy *ResourceProxy `json:"proxy,omitempty" bson:"proxy,omitempty"`
}
type ResourceProxy struct { type ResourceProxy struct {
Host string `json:"host,omitempty" bson:"host,omitempty"` Host string `json:"host,omitempty" bson:"host,omitempty"`
Port int `json:"port,omitempty" bson:"port,omitempty"` Port int `json:"port,omitempty" bson:"port,omitempty"`
@ -112,3 +99,4 @@ type ResourceProxy struct {
Args []string `json:"args,omitempty" bson:"args,omitempty"` Args []string `json:"args,omitempty" bson:"args,omitempty"`
EnvArgs map[string]interface{} `json:"env_args,omitempty" bson:"env_args,omitempty"` EnvArgs map[string]interface{} `json:"env_args,omitempty" bson:"env_args,omitempty"`
} }
*/

View File

@ -12,6 +12,7 @@ const (
WORKFLOW WORKFLOW
WORKFLOW_EXECUTION WORKFLOW_EXECUTION
WORKSPACE WORKSPACE
RESOURCE_MODEL
) )
var Str = [...]string{ var Str = [...]string{
@ -24,6 +25,7 @@ var Str = [...]string{
"workflow", "workflow",
"workflow_execution", "workflow_execution",
"workspace", "workspace",
"resource_model",
} }
func FromInt(i int) string { func FromInt(i int) string {