update
continuous-integration/drone/push Build is passing

This commit is contained in:
2021-12-29 20:24:21 +08:00
parent 745daedf91
commit 9d2f9d6c32
5 changed files with 76 additions and 30 deletions
+2 -2
View File
@@ -50,7 +50,7 @@ func (p *plugin) Find(ctx context.Context, req *config.Request) (*drone.Config,
// 4. 根据文件树以及原始配置文件的信息,组装需要构建的服务的ci信息
// 4.1 api
modifiedApiList := getModifiedApi(cfg.Api, modifiedFileList)
destinationApi, err := modifiedApiList.toDestinationConfig()
destinationApi, err := modifiedApiList.toDestinationConfig(cfg.Name)
if err != nil {
logrus.Error(err)
return nil, err
@@ -58,7 +58,7 @@ func (p *plugin) Find(ctx context.Context, req *config.Request) (*drone.Config,
// 4.2 service
modifiedServiceList := getModifiedService(cfg.Service, modifiedFileList)
destinationService, err := modifiedServiceList.toDestinationConfig()
destinationService, err := modifiedServiceList.toDestinationConfig(cfg.Name)
if err != nil {
logrus.Error(err)
return nil, err
+14 -12
View File
@@ -6,10 +6,10 @@ type Handler interface {
ToDestinationConfig() (string, error)
}
func (al ApiList) toDestinationConfig() (string, error) {
func (al ApiList) toDestinationConfig(nameSpace string) (string, error) {
retConfig := ""
for _, api := range al {
config, err := api.toDestinationConfig()
config, err := api.toDestinationConfig(nameSpace)
if err != nil {
return "", err
}
@@ -18,24 +18,25 @@ func (al ApiList) toDestinationConfig() (string, error) {
return retConfig, nil
}
func (a Api) toDestinationConfig() (string, error) {
func (a Api) toDestinationConfig(nameSpace string) (string, error) {
var handler Handler
switch a.Type {
case go_handler.TypeGolang:
handler = go_handler.GoApiHandler{
Name: a.Name,
Root: a.Root,
Port: a.Port,
NameSpace: nameSpace,
Name: a.Name,
Root: a.Root,
Port: a.Port,
}
}
return handler.ToDestinationConfig()
}
func (sl ServiceList) toDestinationConfig() (string, error) {
func (sl ServiceList) toDestinationConfig(nameSpace string) (string, error) {
retConfig := ""
for _, service := range sl {
config, err := service.toDestinationConfig()
config, err := service.toDestinationConfig(nameSpace)
if err != nil {
return "", err
}
@@ -44,14 +45,15 @@ func (sl ServiceList) toDestinationConfig() (string, error) {
return retConfig, nil
}
func (s Service) toDestinationConfig() (string, error) {
func (s Service) toDestinationConfig(nameSpace string) (string, error) {
var handler Handler
switch s.Type {
case go_handler.TypeGolang:
handler = go_handler.GoApiHandler{
Name: s.Name,
Root: s.Root,
Port: s.Port,
NameSpace: nameSpace,
Name: s.Name,
Root: s.Root,
Port: s.Port,
}
}