adding inputs output struct based on argo naming for now

This commit is contained in:
mr 2025-01-27 14:30:47 +01:00
parent 7ca360be6a
commit 9b8acb83cb
2 changed files with 19 additions and 9 deletions

View File

@ -17,6 +17,7 @@ import (
"cloud.o-forge.io/core/oc-lib/models"
"cloud.o-forge.io/core/oc-lib/models/collaborative_area"
"cloud.o-forge.io/core/oc-lib/models/collaborative_area/rules/rule"
mm "cloud.o-forge.io/core/oc-lib/models/common/models"
"cloud.o-forge.io/core/oc-lib/models/order"
"cloud.o-forge.io/core/oc-lib/models/peer"
"cloud.o-forge.io/core/oc-lib/models/resources"
@ -206,13 +207,19 @@ func SetConfig(mongoUrl string, database string, natsUrl string, lokiUrl string,
for _, model := range []string{tools.DATA_RESOURCE.String(), tools.PROCESSING_RESOURCE.String(), tools.STORAGE_RESOURCE.String(), tools.COMPUTE_RESOURCE.String(), tools.WORKFLOW_RESOURCE.String()} {
data, code, _ := accessor.Search(nil, model, true)
if code == 404 || len(data) == 0 {
refs := map[string]string{}
m := map[string]resource_model.Model{}
var modelref map[string]map[string]resource_model.Model
outputs := []mm.Param{}
// for now only processing is specified here (not an elegant way)
if model == tools.DATA_RESOURCE.String() || model == tools.STORAGE_RESOURCE.String() {
refs["path"] = "string"
outputs = []mm.Param{
mm.Param{
Attr: "source",
Readonly: true,
},
}
}
if model == tools.PROCESSING_RESOURCE.String() {
m := map[string]resource_model.Model{}
m["command"] = resource_model.Model{
Type: "string",
ReadOnly: false,
@ -229,13 +236,15 @@ func SetConfig(mongoUrl string, database string, natsUrl string, lokiUrl string,
Type: "map[string]string",
ReadOnly: false,
}
modelref = map[string]map[string]resource_model.Model{
"container": m,
}
}
accessor.StoreOne(&resource_model.ResourceModel{
ResourceType: model,
VarRefs: refs,
Model: map[string]map[string]resource_model.Model{
"container": m,
},
Outputs: outputs,
Model: modelref,
})
}
}

View File

@ -3,6 +3,7 @@ package resource_model
import (
"encoding/json"
"cloud.o-forge.io/core/oc-lib/models/common/models"
"cloud.o-forge.io/core/oc-lib/models/utils"
"cloud.o-forge.io/core/oc-lib/tools"
)
@ -21,8 +22,8 @@ type ResourceModel struct {
utils.AbstractObject
ResourceType string `json:"resource_type,omitempty" bson:"resource_type,omitempty" validate:"required"`
Model map[string]map[string]Model `json:"model,omitempty" bson:"model,omitempty"`
Inputs []string `json:"inputs,omitempty" bson:"inputs,omitempty"`
Outputs []string `json:"outputs,omitempty" bson:"outputs,omitempty"`
Inputs []models.Param `json:"inputs,omitempty" bson:"inputs,omitempty"`
Outputs []models.Param `json:"outputs,omitempty" bson:"outputs,omitempty"`
}
func (d *ResourceModel) StoreDraftDefault() {