From 3a8f6448868a0e27fb381d9ce9bad76e1732ddab Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Thu, 2 Jan 2025 14:28:57 +0800 Subject: [PATCH 01/12] =?UTF-8?q?feat:=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E7=BA=A7=E5=9B=9E=E8=B0=83=E4=B8=8E=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E7=BC=96=E6=8E=92=E8=A7=A3=E8=80=A6=20#11283?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pipeline/event/ProjectPipelineCallBack.kt | 4 +- .../api/service/ServiceCallBackResource.kt | 18 +++ .../service/ServiceCallBackResourceImpl.kt | 15 +++ .../devops/process/dao/PipelineCallbackDao.kt | 105 ++++++++++++++++++ .../process/engine/control/CallBackControl.kt | 21 +++- .../service/ProjectPipelineCallBackService.kt | 56 +++++++--- 6 files changed, 200 insertions(+), 19 deletions(-) create mode 100644 src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/dao/PipelineCallbackDao.kt diff --git a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/event/ProjectPipelineCallBack.kt b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/event/ProjectPipelineCallBack.kt index 2290891a8c05..53adcb5a5ab4 100644 --- a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/event/ProjectPipelineCallBack.kt +++ b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/event/ProjectPipelineCallBack.kt @@ -48,5 +48,7 @@ data class ProjectPipelineCallBack( @get:Schema(title = "回调是否启用", required = false) val failureTime: LocalDateTime? = null, @get:Schema(title = "凭证参数", required = false) - val secretParam: ISecretParam? = null + val secretParam: ISecretParam? = null, + @get:Schema(title = "回调名称", required = false) + val name: String? = null ) diff --git a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/service/ServiceCallBackResource.kt b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/service/ServiceCallBackResource.kt index c2aee27ef0c0..f71e6baec2da 100644 --- a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/service/ServiceCallBackResource.kt +++ b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/service/ServiceCallBackResource.kt @@ -197,4 +197,22 @@ interface ServiceCallBackResource { pipelineId: String, callbackInfo: PipelineCallbackEvent ): Result + + @Operation(summary = "流水线级别callback") + @GET + @Path("/projects/{projectId}/pipelines/{pipelineId}") + fun getPipelineCallBack( + @Parameter(description = "用户ID", required = true, example = AUTH_HEADER_USER_ID_DEFAULT_VALUE) + @HeaderParam(AUTH_HEADER_USER_ID) + userId: String, + @Parameter(description = "projectId", required = true) + @PathParam("projectId") + projectId: String, + @Parameter(description = "pipelineId", required = true) + @PathParam("pipelineId") + pipelineId: String, + @Parameter(description = "事件类型", required = false) + @QueryParam("event") + event: CallBackEvent? + ): Result> } diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/service/ServiceCallBackResourceImpl.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/service/ServiceCallBackResourceImpl.kt index e309984f44c3..cae70802bb62 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/service/ServiceCallBackResourceImpl.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/service/ServiceCallBackResourceImpl.kt @@ -170,4 +170,19 @@ class ServiceCallBackResourceImpl @Autowired constructor( ) return Result(true) } + + override fun getPipelineCallBack( + userId: String, + projectId: String, + pipelineId: String, + event: CallBackEvent? + ): Result> { + return Result( + projectPipelineCallBackService.getPipelineCallback( + projectId = projectId, + pipelineId = pipelineId, + event = event?.name + ) + ) + } } diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/dao/PipelineCallbackDao.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/dao/PipelineCallbackDao.kt new file mode 100644 index 000000000000..a402b8355ab6 --- /dev/null +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/dao/PipelineCallbackDao.kt @@ -0,0 +1,105 @@ +/* + * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. + * + * A copy of the MIT License is included in this file. + * + * + * Terms of the MIT License: + * --------------------------------------------------- + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.tencent.devops.process.dao + +import com.tencent.devops.model.process.tables.TPipelineCallback +import com.tencent.devops.model.process.tables.records.TPipelineCallbackRecord +import org.jooq.DSLContext +import org.jooq.Result +import org.springframework.stereotype.Repository +import java.time.LocalDateTime + +@Suppress("ALL") +@Repository +class PipelineCallbackDao { + + /** + * 可直接更新或插入 + */ + fun save( + dslContext: DSLContext, + projectId: String, + pipelineId: String, + name: String, + event: String, + userId: String, + url: String, + region: String, + secretToken: String?, + ) { + with(TPipelineCallback.T_PIPELINE_CALLBACK) { + val now = LocalDateTime.now() + dslContext.insertInto( + this, + PROJECT_ID, + PIPELINE_ID, + NAME, + EVENT_TYPE, + USER_ID, + URL, + REGION, + SECRET_TOKEN, + CREATE_TIME, + UPDATE_TIME + ).values( + projectId, + pipelineId, + name, + event, + userId, + url, + region, + secretToken, + now, + now, + ).onDuplicateKeyUpdate() + .set(UPDATE_TIME, now) + .set(URL, url) + .set(SECRET_TOKEN, secretToken) + .execute() + } + } + + fun list( + dslContext: DSLContext, + projectId: String, + pipelineId: String, + event: String? + ): Result { + with(TPipelineCallback.T_PIPELINE_CALLBACK) { + return dslContext.selectFrom(this) + .where(PROJECT_ID.eq(projectId)) + .let { + if (!event.isNullOrBlank()) { + it.and(EVENT_TYPE.eq(event)) + } else it + } + .fetch() + } + } +} diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/control/CallBackControl.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/control/CallBackControl.kt index 66f47f473452..e5f4813b35c9 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/control/CallBackControl.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/control/CallBackControl.kt @@ -226,9 +226,24 @@ class CallBackControl @Autowired constructor( events = callBackEvent.name ) ) - val pipelineCallback = pipelineRepositoryService.getPipelineResourceVersion(projectId, pipelineId) - ?.model - ?.getPipelineCallBack(projectId, callBackEvent) ?: emptyList() + // 流水线级别回调,旧数据存在model中,新数据存在数据库中 + val pipelineCallback = projectPipelineCallBackService.getPipelineCallback( + projectId = projectId, + pipelineId = pipelineId, + event = callBackEvent.name + ).let { + if (it.isEmpty()) { + pipelineRepositoryService.getPipelineResourceVersion( + projectId = projectId, + pipelineId = pipelineId + )?.model?.getPipelineCallBack( + projectId = projectId, + callbackEvent = callBackEvent + ) ?: emptyList() + } else { + it + } + } if (pipelineCallback.isNotEmpty()) { list.addAll(pipelineCallback) } diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/service/ProjectPipelineCallBackService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/service/ProjectPipelineCallBackService.kt index 31b339e231ac..6a483229f1de 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/service/ProjectPipelineCallBackService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/service/ProjectPipelineCallBackService.kt @@ -56,6 +56,7 @@ import com.tencent.devops.common.service.utils.HomeHostUtil import com.tencent.devops.notify.api.service.ServiceNotifyMessageTemplateResource import com.tencent.devops.notify.pojo.SendNotifyMessageTemplateRequest import com.tencent.devops.process.constant.ProcessMessageCode +import com.tencent.devops.process.dao.PipelineCallbackDao import com.tencent.devops.process.dao.ProjectPipelineCallbackDao import com.tencent.devops.process.dao.ProjectPipelineCallbackHistoryDao import com.tencent.devops.process.permission.PipelinePermissionService @@ -63,13 +64,13 @@ import com.tencent.devops.process.pojo.CallBackHeader import com.tencent.devops.process.pojo.CreateCallBackResult import com.tencent.devops.process.pojo.PipelineNotifyTemplateEnum import com.tencent.devops.process.pojo.ProjectPipelineCallBackHistory -import com.tencent.devops.process.pojo.setting.PipelineModelVersion import com.tencent.devops.project.api.service.ServiceAllocIdResource import com.tencent.devops.project.api.service.ServiceProjectResource import okhttp3.MediaType.Companion.toMediaTypeOrNull import okhttp3.Request import okhttp3.RequestBody import org.jooq.DSLContext +import org.jooq.impl.DSL import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Value @@ -89,7 +90,8 @@ class ProjectPipelineCallBackService @Autowired constructor( private val projectPipelineCallBackUrlGenerator: ProjectPipelineCallBackUrlGenerator, private val client: Client, private val pipelineRepositoryService: PipelineRepositoryService, - private val pipelinePermissionService: PipelinePermissionService + private val pipelinePermissionService: PipelinePermissionService, + private val pipelineCallbackDao: PipelineCallbackDao ) { @Value("\${project.callback.secretParam.aes-key:project_callback_aes_key}") @@ -560,19 +562,43 @@ class ProjectPipelineCallBackService @Autowired constructor( // 若key存在会覆盖原来的value,否则就是追加新key newEventMap[callbackInfo.callbackName] = callbackInfo } - model.events = newEventMap - val newModel = mutableListOf() - newModel.add( - PipelineModelVersion( - pipelineId = pipelineId, - projectId = projectId, - model = JsonUtil.toJson(model, formatted = false), - creator = model.pipelineCreator ?: userId - ) - ) - pipelineRepositoryService.batchUpdatePipelineModel( - userId = userId, - pipelineModelVersionList = newModel + dslContext.transaction { transactionContext -> + val transaction = DSL.using(transactionContext) + newEventMap.forEach { (name, info) -> + pipelineCallbackDao.save( + dslContext = transaction, + projectId = projectId, + pipelineId = pipelineId, + name = name, + event = info.callbackEvent.name, + url = info.callbackUrl, + secretToken = info.secretToken?.let { + AESUtil.encrypt(aesKey, it) + }, + region = info.region?.name ?: CallBackNetWorkRegionType.IDC.name, + userId = userId + ) + } + } + } + + fun getPipelineCallback( + projectId: String, + pipelineId: String, + event: String? + ) = pipelineCallbackDao.list( + dslContext = dslContext, + projectId = projectId, + pipelineId = pipelineId, + event = event + ).map { + ProjectPipelineCallBack( + projectId = it.projectId, + callBackUrl = it.url, + events = it.eventType, + secretToken = it.secretToken?.let { AESUtil.decrypt(aesKey, it) }, + enable = it.enable, + name = it.name ) } From 6098a294e42aa92a7d070e69ed829bd731625c00 Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Thu, 2 Jan 2025 16:21:35 +0800 Subject: [PATCH 02/12] =?UTF-8?q?feat:=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E7=BA=A7=E5=9B=9E=E8=B0=83=E4=B8=8E=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E7=BC=96=E6=8E=92=E8=A7=A3=E8=80=A6=20#11283?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../process/engine/service/ProjectPipelineCallBackService.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/service/ProjectPipelineCallBackService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/service/ProjectPipelineCallBackService.kt index 6a483229f1de..c0c1da7c36a6 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/service/ProjectPipelineCallBackService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/service/ProjectPipelineCallBackService.kt @@ -597,7 +597,6 @@ class ProjectPipelineCallBackService @Autowired constructor( callBackUrl = it.url, events = it.eventType, secretToken = it.secretToken?.let { AESUtil.decrypt(aesKey, it) }, - enable = it.enable, name = it.name ) } From 6184740e2bc1f04d863f5105c7e4b8389a414a99 Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Fri, 3 Jan 2025 11:22:40 +0800 Subject: [PATCH 03/12] =?UTF-8?q?feat:=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E7=BA=A7=E5=9B=9E=E8=B0=83=E4=B8=8E=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E7=BC=96=E6=8E=92=E8=A7=A3=E8=80=A6=20#11283?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devops/process/dao/PipelineCallbackDao.kt | 0 .../service/PipelineRepositoryService.kt | 27 ++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) rename src/backend/ci/core/process/{biz-process => biz-base}/src/main/kotlin/com/tencent/devops/process/dao/PipelineCallbackDao.kt (100%) diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/dao/PipelineCallbackDao.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/dao/PipelineCallbackDao.kt similarity index 100% rename from src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/dao/PipelineCallbackDao.kt rename to src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/dao/PipelineCallbackDao.kt diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt index 9dfb28a48e6b..3ba626453c64 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt @@ -33,6 +33,7 @@ import com.tencent.devops.common.api.constant.CommonMessageCode import com.tencent.devops.common.api.exception.DependNotFoundException import com.tencent.devops.common.api.exception.ErrorCodeException import com.tencent.devops.common.api.exception.InvalidParamException +import com.tencent.devops.common.api.util.AESUtil import com.tencent.devops.common.api.util.JsonUtil import com.tencent.devops.common.api.util.MessageUtil import com.tencent.devops.common.api.util.Watcher @@ -52,6 +53,9 @@ import com.tencent.devops.common.pipeline.enums.BranchVersionAction import com.tencent.devops.common.pipeline.enums.ChannelCode import com.tencent.devops.common.pipeline.enums.PipelineInstanceTypeEnum import com.tencent.devops.common.pipeline.enums.VersionStatus +import com.tencent.devops.common.pipeline.event.CallBackEvent +import com.tencent.devops.common.pipeline.event.CallBackNetWorkRegionType +import com.tencent.devops.common.pipeline.event.PipelineCallbackEvent import com.tencent.devops.common.pipeline.extend.ModelCheckPlugin import com.tencent.devops.common.pipeline.option.MatrixControlOption import com.tencent.devops.common.pipeline.pojo.BuildNo @@ -72,6 +76,7 @@ import com.tencent.devops.common.service.utils.LogUtils import com.tencent.devops.common.web.utils.I18nUtil import com.tencent.devops.process.constant.ProcessMessageCode import com.tencent.devops.process.constant.ProcessMessageCode.BK_FIRST_STAGE_ENV_NOT_EMPTY +import com.tencent.devops.process.dao.PipelineCallbackDao import com.tencent.devops.process.dao.PipelineSettingDao import com.tencent.devops.process.dao.PipelineSettingVersionDao import com.tencent.devops.process.dao.label.PipelineViewGroupDao @@ -124,6 +129,7 @@ import com.tencent.devops.project.api.service.ServiceAllocIdResource import org.jooq.DSLContext import org.jooq.impl.DSL import org.slf4j.LoggerFactory +import org.springframework.beans.factory.annotation.Value import org.springframework.stereotype.Service import java.time.LocalDateTime import java.util.concurrent.atomic.AtomicInteger @@ -166,7 +172,8 @@ class PipelineRepositoryService constructor( private val redisOperation: RedisOperation, private val pipelineYamlInfoDao: PipelineYamlInfoDao, private val pipelineGroupService: PipelineGroupService, - private val pipelineAsCodeService: PipelineAsCodeService + private val pipelineAsCodeService: PipelineAsCodeService, + private val pipelineCallbackDao: PipelineCallbackDao ) { companion object { @@ -217,6 +224,9 @@ class PipelineRepositoryService constructor( } } + @Value("\${project.callback.secretParam.aes-key:project_callback_aes_key}") + private val aesKey = "" + fun deployPipeline( model: Model, projectId: String, @@ -1353,6 +1363,21 @@ class PipelineRepositoryService constructor( } } } + // 填充流水线级别回调 + resource?.model?.events = pipelineCallbackDao.list( + dslContext = dslContext, + projectId = projectId, + pipelineId = pipelineId, + event = null + ).associate { + it.name to PipelineCallbackEvent( + callbackEvent = CallBackEvent.valueOf(it.eventType), + callbackUrl = it.url, + secretToken = it.secretToken?.let { AESUtil.decrypt(aesKey, it) }, + region = CallBackNetWorkRegionType.valueOf(it.region), + callbackName = it.name + ) + } return resource } From ee906b8666dce1da40755e4de610eadc0605b759 Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Fri, 3 Jan 2025 14:27:05 +0800 Subject: [PATCH 04/12] =?UTF-8?q?feat:=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E7=BA=A7=E5=9B=9E=E8=B0=83=E4=B8=8E=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E7=BC=96=E6=8E=92=E8=A7=A3=E8=80=A6=20#11283?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- support-files/sql/1001_ci_process_ddl_mysql.sql | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/support-files/sql/1001_ci_process_ddl_mysql.sql b/support-files/sql/1001_ci_process_ddl_mysql.sql index 32afeb6823db..39de6e48efec 100644 --- a/support-files/sql/1001_ci_process_ddl_mysql.sql +++ b/support-files/sql/1001_ci_process_ddl_mysql.sql @@ -1283,4 +1283,17 @@ CREATE TABLE IF NOT EXISTS `T_PIPELINE_WEBHOOK_VERSION` UNIQUE UNI_PROJECT_PIPELINE_TASK (`PROJECT_ID`, `PIPELINE_ID`, `VERSION`, `TASK_ID`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COMMENT = '流水线webhook版本'; +CREATE TABLE IF NOT EXISTS `T_PIPELINE_CALLBACK` ( + `PROJECT_ID` varchar(64) NOT NULL COMMENT '蓝盾项目ID', + `PIPELINE_ID` varchar(64) NOT NULL COMMENT '流水线ID', + `NAME` varchar(255) NOT NULL COMMENT '回调名称', + `EVENT_TYPE` varchar(64) NOT NULL COMMENT '事件类型', + `REGION` varchar(32) DEFAULT NULL COMMENT '网络域', + `URL` varchar(256) NOT NULL COMMENT '回调地址', + `SECRET_TOKEN` varchar(100) DEFAULT NULL COMMENT '鉴权参数', + `USER_ID` varchar(100) DEFAULT NULL COMMENT '创建人', + `CREATE_TIME` datetime DEFAULT NULL COMMENT '创建时间', + `UPDATE_TIME` datetime DEFAULT NULL COMMENT '更新时间', + PRIMARY KEY (`PROJECT_ID`,`PIPELINE_ID`,`NAME`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; SET FOREIGN_KEY_CHECKS = 1; From a551234a8810fd68e63d5a3142d9aaca759d2594 Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Fri, 3 Jan 2025 14:52:05 +0800 Subject: [PATCH 05/12] =?UTF-8?q?feat:=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E7=BA=A7=E5=9B=9E=E8=B0=83=E4=B8=8E=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E7=BC=96=E6=8E=92=E8=A7=A3=E8=80=A6=20#11283?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devops/process/engine/control/CallBackControlTest.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/backend/ci/core/process/biz-process/src/test/kotlin/com/tencent/devops/process/engine/control/CallBackControlTest.kt b/src/backend/ci/core/process/biz-process/src/test/kotlin/com/tencent/devops/process/engine/control/CallBackControlTest.kt index b64f6c1c90ba..b0006b0b09d0 100644 --- a/src/backend/ci/core/process/biz-process/src/test/kotlin/com/tencent/devops/process/engine/control/CallBackControlTest.kt +++ b/src/backend/ci/core/process/biz-process/src/test/kotlin/com/tencent/devops/process/engine/control/CallBackControlTest.kt @@ -164,6 +164,13 @@ class CallBackControlTest : TestBase() { events = events.toString() ) } returns (callbacks!!) + every { + projectPipelineCallBackService.getPipelineCallback( + projectId = projectId, + pipelineId = pipelineId, + event = events.toString() + ) + } returns (listOf()) } @Test From 9f12afdd1ecffecd2787d20667b8c8ef242f74ec Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Fri, 10 Jan 2025 14:36:32 +0800 Subject: [PATCH 06/12] =?UTF-8?q?feat:=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E7=BA=A7=E5=9B=9E=E8=B0=83=E4=B8=8E=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E7=BC=96=E6=8E=92=E8=A7=A3=E8=80=A6=20#11283?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pipeline/event/PipelineCallbackEvent.kt | 2 +- .../devops/process/dao/PipelineCallbackDao.kt | 67 ++++++++++--------- .../service/PipelineRepositoryService.kt | 8 +++ .../service/ProjectPipelineCallBackService.kt | 25 +++---- 4 files changed, 53 insertions(+), 49 deletions(-) diff --git a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/event/PipelineCallbackEvent.kt b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/event/PipelineCallbackEvent.kt index 89b7e05c3bce..d407bde8be31 100644 --- a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/event/PipelineCallbackEvent.kt +++ b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/event/PipelineCallbackEvent.kt @@ -30,7 +30,7 @@ package com.tencent.devops.common.pipeline.event data class PipelineCallbackEvent( val callbackEvent: CallBackEvent, var callbackUrl: String, - val secretToken: String?, + var secretToken: String?, val callbackName: String, val region: CallBackNetWorkRegionType? ) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/dao/PipelineCallbackDao.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/dao/PipelineCallbackDao.kt index a402b8355ab6..1b84865d0309 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/dao/PipelineCallbackDao.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/dao/PipelineCallbackDao.kt @@ -27,6 +27,8 @@ package com.tencent.devops.process.dao +import com.tencent.devops.common.pipeline.event.CallBackNetWorkRegionType +import com.tencent.devops.common.pipeline.event.PipelineCallbackEvent import com.tencent.devops.model.process.tables.TPipelineCallback import com.tencent.devops.model.process.tables.records.TPipelineCallbackRecord import org.jooq.DSLContext @@ -45,43 +47,42 @@ class PipelineCallbackDao { dslContext: DSLContext, projectId: String, pipelineId: String, - name: String, - event: String, userId: String, - url: String, - region: String, - secretToken: String?, + list: List ) { + if (list.isEmpty()) return with(TPipelineCallback.T_PIPELINE_CALLBACK) { val now = LocalDateTime.now() - dslContext.insertInto( - this, - PROJECT_ID, - PIPELINE_ID, - NAME, - EVENT_TYPE, - USER_ID, - URL, - REGION, - SECRET_TOKEN, - CREATE_TIME, - UPDATE_TIME - ).values( - projectId, - pipelineId, - name, - event, - userId, - url, - region, - secretToken, - now, - now, - ).onDuplicateKeyUpdate() - .set(UPDATE_TIME, now) - .set(URL, url) - .set(SECRET_TOKEN, secretToken) - .execute() + list.forEach { + dslContext.insertInto( + this, + PROJECT_ID, + PIPELINE_ID, + NAME, + EVENT_TYPE, + USER_ID, + URL, + SECRET_TOKEN, + REGION, + CREATE_TIME, + UPDATE_TIME + ).values( + projectId, + pipelineId, + it.callbackName, + it.callbackEvent.name, + userId, + it.callbackUrl, + it.secretToken, + (it.region ?: CallBackNetWorkRegionType.IDC).name, + now, + now + ).onDuplicateKeyUpdate() + .set(UPDATE_TIME, now) + .set(URL, it.callbackUrl) + .set(SECRET_TOKEN, it.secretToken) + .execute() + } } } diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt index 3ba626453c64..72e209f07342 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt @@ -1140,6 +1140,14 @@ class PipelineRepositoryService constructor( pipelineId = pipelineId ) pipelineModelTaskDao.batchSave(transactionContext, modelTasks) + // 保存回调事件 + pipelineCallbackDao.save( + dslContext = transactionContext, + projectId = projectId, + pipelineId = pipelineId, + userId = userId, + list = model.events?.map { it.value } ?: listOf() + ) } } diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/service/ProjectPipelineCallBackService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/service/ProjectPipelineCallBackService.kt index c0c1da7c36a6..4032d61782dc 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/service/ProjectPipelineCallBackService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/service/ProjectPipelineCallBackService.kt @@ -564,21 +564,16 @@ class ProjectPipelineCallBackService @Autowired constructor( } dslContext.transaction { transactionContext -> val transaction = DSL.using(transactionContext) - newEventMap.forEach { (name, info) -> - pipelineCallbackDao.save( - dslContext = transaction, - projectId = projectId, - pipelineId = pipelineId, - name = name, - event = info.callbackEvent.name, - url = info.callbackUrl, - secretToken = info.secretToken?.let { - AESUtil.encrypt(aesKey, it) - }, - region = info.region?.name ?: CallBackNetWorkRegionType.IDC.name, - userId = userId - ) - } + pipelineCallbackDao.save( + dslContext = transaction, + projectId = projectId, + pipelineId = pipelineId, + userId = userId, + list = newEventMap.map { (key, value) -> + val encodeToken = value.secretToken?.let { AESUtil.encrypt(aesKey, it) } + value.copy(secretToken = encodeToken) + } + ) } } From 2c0d667885044aae16a77bddbcfa760fe5176862 Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Fri, 10 Jan 2025 15:14:46 +0800 Subject: [PATCH 07/12] =?UTF-8?q?feat:=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E7=BA=A7=E5=9B=9E=E8=B0=83=E4=B8=8E=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E7=BC=96=E6=8E=92=E8=A7=A3=E8=80=A6=20#11283?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pipeline/event/PipelineCallbackEvent.kt | 2 +- .../devops/process/dao/PipelineCallbackDao.kt | 17 +++++++- .../service/PipelineRepositoryService.kt | 41 +++++++++++++++++-- 3 files changed, 55 insertions(+), 5 deletions(-) diff --git a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/event/PipelineCallbackEvent.kt b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/event/PipelineCallbackEvent.kt index d407bde8be31..89b7e05c3bce 100644 --- a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/event/PipelineCallbackEvent.kt +++ b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/event/PipelineCallbackEvent.kt @@ -30,7 +30,7 @@ package com.tencent.devops.common.pipeline.event data class PipelineCallbackEvent( val callbackEvent: CallBackEvent, var callbackUrl: String, - var secretToken: String?, + val secretToken: String?, val callbackName: String, val region: CallBackNetWorkRegionType? ) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/dao/PipelineCallbackDao.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/dao/PipelineCallbackDao.kt index 1b84865d0309..e19a28565cd6 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/dao/PipelineCallbackDao.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/dao/PipelineCallbackDao.kt @@ -90,7 +90,7 @@ class PipelineCallbackDao { dslContext: DSLContext, projectId: String, pipelineId: String, - event: String? + event: String? = null ): Result { with(TPipelineCallback.T_PIPELINE_CALLBACK) { return dslContext.selectFrom(this) @@ -103,4 +103,19 @@ class PipelineCallbackDao { .fetch() } } + + fun delete( + dslContext: DSLContext, + projectId: String, + pipelineId: String, + names: Set + ) { + with(TPipelineCallback.T_PIPELINE_CALLBACK) { + dslContext.deleteFrom(this) + .where(PROJECT_ID.eq(projectId)) + .and(PIPELINE_ID.eq(pipelineId)) + .and(NAME.eq(name)) + .execute() + } + } } diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt index 72e209f07342..c145eb3b2d56 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt @@ -1140,13 +1140,13 @@ class PipelineRepositoryService constructor( pipelineId = pipelineId ) pipelineModelTaskDao.batchSave(transactionContext, modelTasks) - // 保存回调事件 - pipelineCallbackDao.save( + // 保存流水线单体回调记录 + savePipelineCallback( dslContext = transactionContext, projectId = projectId, pipelineId = pipelineId, userId = userId, - list = model.events?.map { it.value } ?: listOf() + events = model.events ) } } @@ -2199,4 +2199,39 @@ class PipelineRepositoryService constructor( null }?.handoverFrom } + + /** + * 保存流水线单体回调记录 + */ + private fun savePipelineCallback( + events: Map?, + pipelineId: String, + projectId: String, + dslContext: DSLContext, + userId: String + ) { + if (events.isNullOrEmpty()) return + val existEventNames = pipelineCallbackDao.list( + dslContext = dslContext, + projectId = projectId, + pipelineId = pipelineId + ).map { it.name }.toSet() + val needDelNames = events.keys.subtract(existEventNames).toSet() + pipelineCallbackDao.delete( + dslContext = dslContext, + projectId = projectId, + pipelineId = pipelineId, + names = needDelNames + ) + // 保存回调事件 + pipelineCallbackDao.save( + dslContext = dslContext, + projectId = projectId, + pipelineId = pipelineId, + userId = userId, + list = events.map { (key, value) -> + value.copy(secretToken = value.secretToken?.let { AESUtil.encrypt(aesKey, it) }) + } + ) + } } From aab217d5538f95b15ef42900b5a0cc9a4980743d Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Fri, 10 Jan 2025 15:17:57 +0800 Subject: [PATCH 08/12] =?UTF-8?q?feat:=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E7=BA=A7=E5=9B=9E=E8=B0=83=E4=B8=8E=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E7=BC=96=E6=8E=92=E8=A7=A3=E8=80=A6=20#11283?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tencent/devops/process/dao/PipelineCallbackDao.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/dao/PipelineCallbackDao.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/dao/PipelineCallbackDao.kt index e19a28565cd6..ae50d6155441 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/dao/PipelineCallbackDao.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/dao/PipelineCallbackDao.kt @@ -114,7 +114,7 @@ class PipelineCallbackDao { dslContext.deleteFrom(this) .where(PROJECT_ID.eq(projectId)) .and(PIPELINE_ID.eq(pipelineId)) - .and(NAME.eq(name)) + .and(NAME.`in`(names)) .execute() } } From 8036913a9732416c0015ca2ee056065e05a3708f Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Fri, 10 Jan 2025 15:32:33 +0800 Subject: [PATCH 09/12] =?UTF-8?q?feat:=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E7=BA=A7=E5=9B=9E=E8=B0=83=E4=B8=8E=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E7=BC=96=E6=8E=92=E8=A7=A3=E8=80=A6=20#11283?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devops/process/engine/service/PipelineRepositoryService.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt index c145eb3b2d56..59fb451777e6 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt @@ -2216,7 +2216,7 @@ class PipelineRepositoryService constructor( projectId = projectId, pipelineId = pipelineId ).map { it.name }.toSet() - val needDelNames = events.keys.subtract(existEventNames).toSet() + val needDelNames = existEventNames.subtract(events.keys).toSet() pipelineCallbackDao.delete( dslContext = dslContext, projectId = projectId, From da44aaa688a7b27bd011d1ddde8da40bbaccf831 Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Fri, 10 Jan 2025 15:49:42 +0800 Subject: [PATCH 10/12] =?UTF-8?q?feat:=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E7=BA=A7=E5=9B=9E=E8=B0=83=E4=B8=8E=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E7=BC=96=E6=8E=92=E8=A7=A3=E8=80=A6=20#11283?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../engine/service/PipelineRepositoryService.kt | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt index 59fb451777e6..b2a2da2586a5 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt @@ -2216,13 +2216,15 @@ class PipelineRepositoryService constructor( projectId = projectId, pipelineId = pipelineId ).map { it.name }.toSet() - val needDelNames = existEventNames.subtract(events.keys).toSet() - pipelineCallbackDao.delete( - dslContext = dslContext, - projectId = projectId, - pipelineId = pipelineId, - names = needDelNames - ) + if (existEventNames.isNotEmpty()) { + val needDelNames = existEventNames.subtract(events.keys).toSet() + pipelineCallbackDao.delete( + dslContext = dslContext, + projectId = projectId, + pipelineId = pipelineId, + names = needDelNames + ) + } // 保存回调事件 pipelineCallbackDao.save( dslContext = dslContext, From 75326fc51a76d926ef781ef9ab047da9478bc62a Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Mon, 13 Jan 2025 10:47:41 +0800 Subject: [PATCH 11/12] =?UTF-8?q?feat:=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E7=BA=A7=E5=9B=9E=E8=B0=83=E4=B8=8E=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E7=BC=96=E6=8E=92=E8=A7=A3=E8=80=A6=20#11283?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../process/engine/service/PipelineRepositoryService.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt index b2a2da2586a5..25984198361f 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt @@ -844,6 +844,14 @@ class PipelineRepositoryService constructor( // 初始化流水线构建统计表 pipelineBuildSummaryDao.create(dslContext, projectId, pipelineId, buildNo) pipelineModelTaskDao.batchSave(transactionContext, modelTasks) + // 初始化流水线单体回调 + savePipelineCallback( + events = model.events, + pipelineId = pipelineId, + userId = userId, + projectId = projectId, + dslContext = transactionContext + ) } } finally { lock.unlock() From b71cac8d8d10daa7fbc60fed074e3a9706d7dd2d Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Wed, 15 Jan 2025 14:18:28 +0800 Subject: [PATCH 12/12] =?UTF-8?q?feat:=20=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E7=BA=A7=E5=9B=9E=E8=B0=83=E4=B8=8E=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E7=BC=96=E6=8E=92=E8=A7=A3=E8=80=A6=20#11283?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/PipelineRepositoryService.kt | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt index 25984198361f..50f27f1bbfbf 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt @@ -1379,20 +1379,24 @@ class PipelineRepositoryService constructor( } } } - // 填充流水线级别回调 - resource?.model?.events = pipelineCallbackDao.list( + pipelineCallbackDao.list( dslContext = dslContext, projectId = projectId, pipelineId = pipelineId, event = null - ).associate { - it.name to PipelineCallbackEvent( - callbackEvent = CallBackEvent.valueOf(it.eventType), - callbackUrl = it.url, - secretToken = it.secretToken?.let { AESUtil.decrypt(aesKey, it) }, - region = CallBackNetWorkRegionType.valueOf(it.region), - callbackName = it.name - ) + ).let { records -> + if (records.isNotEmpty) { + // 填充流水线级别回调 + resource?.model?.events = records.associate { + it.name to PipelineCallbackEvent( + callbackEvent = CallBackEvent.valueOf(it.eventType), + callbackUrl = it.url, + secretToken = it.secretToken?.let { AESUtil.decrypt(aesKey, it) }, + region = CallBackNetWorkRegionType.valueOf(it.region), + callbackName = it.name + ) + } + } } return resource }