drone_plugin/config_handler/api_config.go

32 lines
768 B
Go
Raw Normal View History

2021-12-29 23:23:35 +08:00
package config_handler
import "git.icechen.cn/pkg/drone_plugin/go_handler"
func (al ApiList) toDestinationConfig(nameSpace string, serviceEnv map[string]string) (string, error) {
retConfig := ""
for _, api := range al {
config, err := api.toDestinationConfig(nameSpace, serviceEnv)
if err != nil {
return "", err
}
retConfig += config + "\n\n---\n\n"
}
return retConfig, nil
}
func (a Api) toDestinationConfig(nameSpace string, 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,
ServiceEnv: serviceEnv,
}
}
return handler.ToDestinationConfig()
}