44 lines
1.0 KiB
Go
44 lines
1.0 KiB
Go
package config
|
|
|
|
import (
|
|
"fmt"
|
|
schmod "gitlink.org.cn/cloudream/scheduler/common/models"
|
|
"gitlink.org.cn/cloudream/scheduler/executor/internal/task/create_ecs"
|
|
)
|
|
|
|
var CloudName string
|
|
|
|
func InitCloud(createECS map[string]interface{}) {
|
|
|
|
cloud, ok := createECS["cloud"].(string)
|
|
CloudName = cloud
|
|
if !ok {
|
|
fmt.Println("Invalid JSON structure: cloud field is missing or not a string")
|
|
return
|
|
}
|
|
|
|
auth_config, ok := createECS["auth_config"].(map[string]interface{})
|
|
if !ok {
|
|
fmt.Println("Invalid JSON structure: config section is missing or malformed")
|
|
return
|
|
}
|
|
|
|
ecs_config, ok := createECS["ecs_config"].(map[string]interface{})
|
|
if !ok {
|
|
fmt.Println("Invalid JSON structure: config section is missing or malformed")
|
|
return
|
|
}
|
|
|
|
switch cloud {
|
|
case schmod.AliCloud:
|
|
create_ecs.AliConfig(auth_config, ecs_config)
|
|
case schmod.HuaweiCloud:
|
|
create_ecs.HWCloudConfig(auth_config, ecs_config)
|
|
case schmod.SugonCloud:
|
|
create_ecs.SugonCloudConfig(auth_config, ecs_config)
|
|
default:
|
|
fmt.Println("Unsupported cloud type:", cloud)
|
|
return
|
|
}
|
|
}
|