drone_plugin/config_handler/service_config.go

36 lines
794 B
Go

package config_handler
import (
"git.icechen.cn/pkg/drone_plugin/consts"
"git.icechen.cn/pkg/drone_plugin/go_handler"
)
func (sl ServiceList) toDestinationConfig(deployEnv consts.Env) (string, error) {
retConfig := ""
for _, service := range sl {
config, err := service.toDestinationConfig(deployEnv)
if err != nil {
return "", err
}
retConfig += config + "\n\n---\n\n"
}
return retConfig, nil
}
func (s Service) toDestinationConfig(deployEnv consts.Env) (string, error) {
var handler Handler
switch s.Type {
case go_handler.TypeGolang:
handler = go_handler.GoServiceHandler{
NameSpace: s.Namespace,
Name: s.Name,
AliasName: s.AliasName,
Root: s.Root,
Port: s.Port,
DeployEnv: deployEnv,
}
}
return handler.ToDestinationConfig()
}