drone_plugin/config_handler/service_config.go

36 lines
794 B
Go
Raw Normal View History

2021-12-29 23:23:35 +08:00
package config_handler
import (
2021-12-30 20:06:10 +08:00
"git.icechen.cn/pkg/drone_plugin/consts"
2021-12-29 23:23:35 +08:00
"git.icechen.cn/pkg/drone_plugin/go_handler"
)
2022-01-10 17:51:52 +08:00
func (sl ServiceList) toDestinationConfig(deployEnv consts.Env) (string, error) {
2021-12-29 23:23:35 +08:00
retConfig := ""
for _, service := range sl {
2022-01-10 17:51:52 +08:00
config, err := service.toDestinationConfig(deployEnv)
2021-12-29 23:23:35 +08:00
if err != nil {
return "", err
}
retConfig += config + "\n\n---\n\n"
}
return retConfig, nil
}
2022-01-10 17:51:52 +08:00
func (s Service) toDestinationConfig(deployEnv consts.Env) (string, error) {
2021-12-29 23:23:35 +08:00
var handler Handler
switch s.Type {
case go_handler.TypeGolang:
handler = go_handler.GoServiceHandler{
2022-01-10 17:51:52 +08:00
NameSpace: s.Namespace,
Name: s.Name,
AliasName: s.AliasName,
Root: s.Root,
Port: s.Port,
DeployEnv: deployEnv,
2021-12-29 23:23:35 +08:00
}
}
return handler.ToDestinationConfig()
}