update
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
5a893702ee
commit
76571a6b0b
|
@ -54,7 +54,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(cfg.Name, cfg.Service.toServiceEnv())
|
||||
destinationApi, err := modifiedApiList.toDestinationConfig(cfg.Name, cfg.toServiceEnv())
|
||||
if err != nil {
|
||||
logrus.Error(err)
|
||||
return nil, err
|
||||
|
@ -62,7 +62,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(cfg.Name)
|
||||
destinationService, err := modifiedServiceList.toDestinationConfig(cfg.Name, cfg.toServiceEnv())
|
||||
if err != nil {
|
||||
logrus.Error(err)
|
||||
return nil, err
|
||||
|
|
|
@ -3,6 +3,7 @@ package config_handler
|
|||
import (
|
||||
"git.icechen.cn/pkg/drone_plugin/git"
|
||||
"gopkg.in/yaml.v3"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const TypeMonorepo = "monorepo" // 单库类型
|
||||
|
@ -15,6 +16,15 @@ type Config struct {
|
|||
Service ServiceList `json:"service" yaml:"service"`
|
||||
}
|
||||
|
||||
func (c Config) toServiceEnv() map[string]string {
|
||||
sl := c.Service
|
||||
retMap := make(map[string]string)
|
||||
for _, service := range sl {
|
||||
retMap[strings.ToUpper("SERVICE_"+service.Name)] = c.Name + "-" + service.Name + ":" + service.Port
|
||||
}
|
||||
return retMap
|
||||
}
|
||||
|
||||
type (
|
||||
ApiList []Api
|
||||
Api struct {
|
||||
|
@ -24,7 +34,6 @@ type (
|
|||
Port string `json:"port" yaml:"port"`
|
||||
}
|
||||
)
|
||||
|
||||
type (
|
||||
ServiceList []Service
|
||||
Service struct {
|
||||
|
|
|
@ -2,21 +2,12 @@ package config_handler
|
|||
|
||||
import (
|
||||
"git.icechen.cn/pkg/drone_plugin/go_handler"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func (sl ServiceList) toServiceEnv() map[string]string {
|
||||
retMap := make(map[string]string)
|
||||
for _, service := range sl {
|
||||
retMap[strings.ToUpper("SERVICE_"+service.Name)] = service.Name + ":" + service.Port
|
||||
}
|
||||
return retMap
|
||||
}
|
||||
|
||||
func (sl ServiceList) toDestinationConfig(nameSpace string) (string, error) {
|
||||
func (sl ServiceList) toDestinationConfig(nameSpace string, serviceEnv map[string]string) (string, error) {
|
||||
retConfig := ""
|
||||
for _, service := range sl {
|
||||
config, err := service.toDestinationConfig(nameSpace, sl.toServiceEnv())
|
||||
config, err := service.toDestinationConfig(nameSpace, serviceEnv)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue