added user input handling methods
This commit is contained in:
@@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user