36 lines
896 B
Go
36 lines
896 B
Go
package config_handler
|
|
|
|
import (
|
|
"git.icechen.cn/pkg/drone_plugin/consts"
|
|
"git.icechen.cn/pkg/drone_plugin/go_handler"
|
|
)
|
|
|
|
func (al ApiList) toDestinationConfig(nameSpace string, deployEnv consts.Env, serviceEnv map[string]string) (string, error) {
|
|
retConfig := ""
|
|
for _, api := range al {
|
|
config, err := api.toDestinationConfig(nameSpace, deployEnv, serviceEnv)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
retConfig += config + "\n\n---\n\n"
|
|
}
|
|
return retConfig, nil
|
|
}
|
|
|
|
func (a Api) toDestinationConfig(nameSpace string, deployEnv consts.Env, serviceEnv map[string]string) (string, error) {
|
|
var handler Handler
|
|
switch a.Type {
|
|
case go_handler.TypeGolang:
|
|
handler = go_handler.GoApiHandler{
|
|
NameSpace: nameSpace,
|
|
Name: a.Name,
|
|
Root: a.Root,
|
|
Port: a.Port,
|
|
DeployEnv: deployEnv,
|
|
ServiceEnv: serviceEnv,
|
|
}
|
|
}
|
|
|
|
return handler.ToDestinationConfig()
|
|
}
|