32 lines
768 B
Go
32 lines
768 B
Go
|
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()
|
||
|
}
|