added user input handling methods

This commit is contained in:
pb
2024-03-22 11:27:25 +01:00
parent 28ed951ee5
commit 8a03ad205d
2 changed files with 37 additions and 1 deletions

View File

@@ -1,6 +1,9 @@
package models
import (
"fmt"
"strings"
"cloud.o-forge.io/core/oc-catalog/models/rtype"
"cloud.o-forge.io/core/oc-catalog/services"
"github.com/beego/beego/v2/core/logs"
@@ -170,3 +173,20 @@ func GetMultipleComputing(IDs []string) (object *[]ComputingModel, err error) {
func PostOneComputing(obj ComputingNEWModel) (ID string, err error) {
return postOneResource(obj, rtype.COMPUTING)
}
func (obj ComputingModel) AddUserInput(inputs map[string]interface{} ){
// So far only a few input to handle so a switch with a case for each type of attribute
// is enough, to prevent too much complexity
for key, value := range inputs {
switch strings.ToLower(key) {
case "command":
obj.Command = value.(string)
case "arguments":
obj.Arguments = value.([]string)
case "env" :
obj.Environment = value.([]string)
default:
logs.Alert(fmt.Printf("%s is not an attribute of storage componants", key))
}
}
}