From e6b65546a6ab1d6d73745ba87df7bfd5639cace2 Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Thu, 28 Nov 2024 10:39:53 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E5=8F=91=E5=B8=83Deploy?= =?UTF-8?q?PipelineConfigManager=E9=9C=80=E6=94=AF=E6=8C=81=E6=89=B9?= =?UTF-8?q?=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1298640549675008]发布DeployPipelineConfigManager需支持批量 http://192.168.0.96:8090/demo/rdm.html#/story-detail/939050947543040/939050947543042/1298640549675008 --- .../api/job/ListDeployJobModuleApi.java | 1 + .../util/DeployPipelineConfigManager.java | 180 +++++++++--------- 2 files changed, 90 insertions(+), 91 deletions(-) diff --git a/src/main/java/neatlogic/module/deploy/api/job/ListDeployJobModuleApi.java b/src/main/java/neatlogic/module/deploy/api/job/ListDeployJobModuleApi.java index 0ceceb9d..1d251276 100644 --- a/src/main/java/neatlogic/module/deploy/api/job/ListDeployJobModuleApi.java +++ b/src/main/java/neatlogic/module/deploy/api/job/ListDeployJobModuleApi.java @@ -113,6 +113,7 @@ public class ListDeployJobModuleApi extends PrivateApiComponentBase { .withEnvIdList(Collections.singletonList(envId)) .isHasBuildOrDeployTypeTool(true) .isUpdateConfig(false) + .isUpdateProfile(false) .getDeployAppConfigList(); // Map appConfigVoMap = appConfigVoList.stream().collect(Collectors.toMap(o -> o.getAppSystemId().toString() + "-" + o.getAppModuleId().toString() + "-" + o.getEnvId().toString(), e -> e)); for (ResourceVo resourceVo : moduleResourceList) { diff --git a/src/main/java/neatlogic/module/deploy/util/DeployPipelineConfigManager.java b/src/main/java/neatlogic/module/deploy/util/DeployPipelineConfigManager.java index 93175ae8..139e0c98 100644 --- a/src/main/java/neatlogic/module/deploy/util/DeployPipelineConfigManager.java +++ b/src/main/java/neatlogic/module/deploy/util/DeployPipelineConfigManager.java @@ -86,6 +86,10 @@ public class DeployPipelineConfigManager { * 是否需要更新配置信息中场景名称、预置参数集名称、操作对应工具信息 */ private boolean isUpdateConfig = true; + /** + * 是否需要更新配置信息中预置参数集 + */ + private boolean isUpdateProfile = true; public Builder(Long appSystemId) { this.appSystemId = appSystemId; @@ -154,8 +158,60 @@ public class DeployPipelineConfigManager { return this; } + public Builder isUpdateProfile(boolean _isUpdateProfile) { + this.isUpdateProfile = _isUpdateProfile; + return this; + } + + /** + * 获取流水线配置信息 + * @return + */ public DeployPipelineConfigVo getConfig() { - DeployPipelineConfigVo deployPipelineConfig = getDeployPipelineConfig(appSystemId, appModuleId, envId, isAppSystemDraft, isAppModuleDraft, isEnvDraft, profileIdList); + String targetLevel; + DeployPipelineConfigVo appConfig; + DeployPipelineConfigVo moduleOverrideConfig = null; + DeployPipelineConfigVo envOverrideConfig = null; + DeployAppConfigVo searchVo = new DeployAppConfigVo(appSystemId, appModuleId, envId); + if (appModuleId == 0L && envId == 0L) { + targetLevel = "应用"; + //查询应用层流水线配置信息 + appConfig = getDeployPipelineConfigVo(searchVo, isAppSystemDraft); + if (appConfig == null) { + if (isAppSystemDraft) { + return null; + } else { + appConfig = new DeployPipelineConfigVo(); + } + } + } else if (appModuleId == 0L) { + // 如果是访问环境层配置信息,moduleId不能为空 + throw new ParamNotExistsException("moduleId"); + } else if (envId == 0L) { + targetLevel = "模块"; + //查询应用层配置信息 + appConfig = getDeployPipelineConfigVo(new DeployAppConfigVo(appSystemId), false); + if (appConfig == null) { + appConfig = new DeployPipelineConfigVo(); + } + moduleOverrideConfig = getDeployPipelineConfigVo(searchVo, isAppModuleDraft); + if (isAppModuleDraft && moduleOverrideConfig == null) { + return null; + } + } else { + targetLevel = "环境"; + //查询应用层配置信息 + appConfig = getDeployPipelineConfigVo(new DeployAppConfigVo(appSystemId), false); + if (appConfig == null) { + appConfig = new DeployPipelineConfigVo(); + } + moduleOverrideConfig = getDeployPipelineConfigVo(new DeployAppConfigVo(appSystemId, appModuleId), false); + envOverrideConfig = getDeployPipelineConfigVo(searchVo, isEnvDraft); + if (isEnvDraft && envOverrideConfig == null) { + return null; + } + } + DeployPipelineConfigVo deployPipelineConfig = mergeDeployPipelineConfig(appConfig, moduleOverrideConfig, envOverrideConfig, targetLevel, isUpdateProfile, profileIdList); specialHandling(deployPipelineConfig, isDeleteDisabledPhase, isUpdateConfig, isHasBuildOrDeployTypeTool); return deployPipelineConfig; } @@ -204,7 +260,7 @@ public class DeployPipelineConfigManager { moduleOverrideConfig = getDeployPipelineConfigVo(appSystemId, appModuleId, 0L, deployAppConfigList); envOverrideConfig = getDeployPipelineConfigVo(appSystemId, appModuleId, envId, deployAppConfigList); } - DeployPipelineConfigVo deployPipelineConfigVo = mergeDeployPipelineConfig(appConfig, moduleOverrideConfig, envOverrideConfig, targetLevel, profileIdList); + DeployPipelineConfigVo deployPipelineConfigVo = mergeDeployPipelineConfig(appConfig, moduleOverrideConfig, envOverrideConfig, targetLevel, isUpdateProfile, profileIdList); specialHandling(deployPipelineConfigVo, isDeleteDisabledPhase, isUpdateConfig, isHasBuildOrDeployTypeTool); DeployAppConfigVo deployAppConfig = new DeployAppConfigVo(); deployAppConfig.setAppSystemId(appSystemId); @@ -348,65 +404,6 @@ public class DeployPipelineConfigManager { } } - /** - * 获取流水线配置信息 - * - * @param appSystemId 应用id - * @param appModuleId 应用模块id - * @param envId 环境id - * @param isAppSystemDraft 是否取应用层配置草稿 - * @param isAppModuleDraft 是否取模块层配置草稿 - * @param isEnvDraft 是否取环境层配置草稿 - * @return 配置 - */ - private static DeployPipelineConfigVo getDeployPipelineConfig(Long appSystemId, Long appModuleId, Long envId, boolean isAppSystemDraft, boolean isAppModuleDraft, boolean isEnvDraft, List profileIdList) { - String targetLevel; - DeployPipelineConfigVo appConfig; - DeployPipelineConfigVo moduleOverrideConfig = null; - DeployPipelineConfigVo envOverrideConfig = null; - DeployAppConfigVo searchVo = new DeployAppConfigVo(appSystemId, appModuleId, envId); - if (appModuleId == 0L && envId == 0L) { - targetLevel = "应用"; - //查询应用层流水线配置信息 - appConfig = getDeployPipelineConfigVo(searchVo, isAppSystemDraft); - if (appConfig == null) { - if (isAppSystemDraft) { - return null; - } else { - appConfig = new DeployPipelineConfigVo(); - } - } - } else if (appModuleId == 0L) { - // 如果是访问环境层配置信息,moduleId不能为空 - throw new ParamNotExistsException("moduleId"); - } else if (envId == 0L) { - targetLevel = "模块"; - //查询应用层配置信息 - appConfig = getDeployPipelineConfigVo(new DeployAppConfigVo(appSystemId), false); - if (appConfig == null) { - appConfig = new DeployPipelineConfigVo(); - } - moduleOverrideConfig = getDeployPipelineConfigVo(searchVo, isAppModuleDraft); - if (isAppModuleDraft && moduleOverrideConfig == null) { - return null; - } - } else { - targetLevel = "环境"; - //查询应用层配置信息 - appConfig = getDeployPipelineConfigVo(new DeployAppConfigVo(appSystemId), false); - if (appConfig == null) { - appConfig = new DeployPipelineConfigVo(); - } - moduleOverrideConfig = getDeployPipelineConfigVo(new DeployAppConfigVo(appSystemId, appModuleId), false); - envOverrideConfig = getDeployPipelineConfigVo(searchVo, isEnvDraft); - if (isEnvDraft && envOverrideConfig == null) { - return null; - } - } - DeployPipelineConfigVo deployPipelineConfigVo = mergeDeployPipelineConfig(appConfig, moduleOverrideConfig, envOverrideConfig, targetLevel, profileIdList); - return deployPipelineConfigVo; - } - private static DeployPipelineConfigVo getDeployPipelineConfigVo(DeployAppConfigVo searchVo, boolean isDraft) { if (isDraft) { DeployAppConfigVo deployAppConfigDraftVo = deployAppConfigMapper.getAppConfigDraft(searchVo); @@ -574,7 +571,7 @@ public class DeployPipelineConfigManager { * @param profileIdList 预置参数集id列表 * @return 目标层配置信息 */ - private static DeployPipelineConfigVo mergeDeployPipelineConfig(DeployPipelineConfigVo appConfig, DeployPipelineConfigVo moduleOverrideConfig, DeployPipelineConfigVo envOverrideConfig, String targetLevel, List profileIdList) { + private static DeployPipelineConfigVo mergeDeployPipelineConfig(DeployPipelineConfigVo appConfig, DeployPipelineConfigVo moduleOverrideConfig, DeployPipelineConfigVo envOverrideConfig, String targetLevel, boolean isUpdateProfile, List profileIdList) { if (Objects.equals(targetLevel, "应用")) { } else if (Objects.equals(targetLevel, "模块")) { @@ -597,39 +594,40 @@ public class DeployPipelineConfigManager { mergeDeployPipelineConfig(appConfig, envOverrideConfig); } } - - if (CollectionUtils.isEmpty(profileIdList)) { - profileIdList = new ArrayList<>(getProfileIdSet(appConfig)); - } - if (CollectionUtils.isNotEmpty(profileIdList)) { - IAutoexecProfileCrossoverService autoexecProfileCrossoverService = CrossoverServiceFactory.getApi(IAutoexecProfileCrossoverService.class); - List profileList = autoexecProfileCrossoverService.getProfileVoListByIdList(profileIdList); - if (CollectionUtils.isNotEmpty(profileList)) { - List deployProfileList = getDeployProfileList(profileList); - List overrideProfileList = appConfig.getOverrideProfileList(); - mergeDeployPipelineConfigProfileList(deployProfileList, overrideProfileList); - if (Objects.equals(targetLevel, "应用")) { - - } else if (Objects.equals(targetLevel, "模块")) { - overrideProfileList = null; - if (moduleOverrideConfig != null) { - overrideProfileList = moduleOverrideConfig.getOverrideProfileList(); - } + if (isUpdateProfile) { + if (CollectionUtils.isEmpty(profileIdList)) { + profileIdList = new ArrayList<>(getProfileIdSet(appConfig)); + } + if (CollectionUtils.isNotEmpty(profileIdList)) { + IAutoexecProfileCrossoverService autoexecProfileCrossoverService = CrossoverServiceFactory.getApi(IAutoexecProfileCrossoverService.class); + List profileList = autoexecProfileCrossoverService.getProfileVoListByIdList(profileIdList); + if (CollectionUtils.isNotEmpty(profileList)) { + List deployProfileList = getDeployProfileList(profileList); + List overrideProfileList = appConfig.getOverrideProfileList(); mergeDeployPipelineConfigProfileList(deployProfileList, overrideProfileList); - } else if (Objects.equals(targetLevel, "环境")) { - if (moduleOverrideConfig != null) { - overrideProfileList = moduleOverrideConfig.getOverrideProfileList(); - if (CollectionUtils.isNotEmpty(overrideProfileList)) { - mergeDeployPipelineConfigProfileList(deployProfileList, overrideProfileList); + if (Objects.equals(targetLevel, "应用")) { + + } else if (Objects.equals(targetLevel, "模块")) { + overrideProfileList = null; + if (moduleOverrideConfig != null) { + overrideProfileList = moduleOverrideConfig.getOverrideProfileList(); } + mergeDeployPipelineConfigProfileList(deployProfileList, overrideProfileList); + } else if (Objects.equals(targetLevel, "环境")) { + if (moduleOverrideConfig != null) { + overrideProfileList = moduleOverrideConfig.getOverrideProfileList(); + if (CollectionUtils.isNotEmpty(overrideProfileList)) { + mergeDeployPipelineConfigProfileList(deployProfileList, overrideProfileList); + } + } + overrideProfileList = null; + if (envOverrideConfig != null) { + overrideProfileList = envOverrideConfig.getOverrideProfileList(); + } + mergeDeployPipelineConfigProfileList(deployProfileList, overrideProfileList); } - overrideProfileList = null; - if (envOverrideConfig != null) { - overrideProfileList = envOverrideConfig.getOverrideProfileList(); - } - mergeDeployPipelineConfigProfileList(deployProfileList, overrideProfileList); + appConfig.setOverrideProfileList(deployProfileList); } - appConfig.setOverrideProfileList(deployProfileList); } } return appConfig; -- Gitee