drone_plugin/config_handler/api_config.go

38 lines
818 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(deployEnv consts.Env) (string, error) {
retConfig := ""
for _, api := range al {
config, err := api.toDestinationConfig(deployEnv)
if err != nil {
return "", err
}
retConfig += config + "\n\n---\n\n"
}
return retConfig, nil
}
func (a Api) toDestinationConfig(deployEnv consts.Env) (string, error) {
var handler Handler
switch a.Type {
case go_handler.TypeGolang:
handler = go_handler.GoApiHandler{
NameSpace: a.Namespace,
Name: a.Name,
AliasName: a.AliasName,
Root: a.Root,
Port: a.Port,
Host: a.Host,
Path: a.Path,
DeployEnv: deployEnv,
}
}
return handler.ToDestinationConfig()
}