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))
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -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"
 | 
			
		||||
@@ -12,7 +15,7 @@ type StorageNEWModel struct {
 | 
			
		||||
	Description      string `json:"description" required:"true"`
 | 
			
		||||
	ShortDescription string `json:"short_description" required:"true" validate:"required"`
 | 
			
		||||
	Logo             string `json:"logo" required:"true" validate:"required"`
 | 
			
		||||
	// Type             string `json:"type,omitempty" required:"true"`
 | 
			
		||||
	Type             string `json:"type,omitempty" required:"true"`
 | 
			
		||||
 | 
			
		||||
	DCacronym string `json:"DCacronym" required:"true" description:"Unique ID of the DC where it is the storage"`
 | 
			
		||||
	URL string `json:"URL"`
 | 
			
		||||
@@ -137,3 +140,16 @@ func GetMultipleStorage(IDs []string) (object *[]StorageModel, err error) {
 | 
			
		||||
 | 
			
		||||
	return object, err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (obj StorageModel) 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 "URL":
 | 
			
		||||
			obj.URL = value.(string)
 | 
			
		||||
		default:
 | 
			
		||||
			logs.Alert(fmt.Printf("%s is not an attribute of storage componants", key))
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user