From 71d61ce9bdc4f490df5e7421a42e8aee28d10e2e Mon Sep 17 00:00:00 2001 From: royalhuang Date: Wed, 15 Sep 2021 18:34:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E7=86=94=E6=96=AD=E5=90=8E=E4=B8=8B=E8=BD=BD=E5=85=A8=E9=87=8F?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E7=9A=84OpenAPI=20#5145?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/service/ServiceLogFileResource.kt | 6 +- .../devops/log/api/ServiceLogResource.kt | 15 +++++ .../log/resources/AppLogResourceImpl.kt | 59 ++++--------------- .../log/resources/ServiceLogResourceImpl.kt | 10 ++++ .../log/resources/UserLogResourceImpl.kt | 53 ++++------------- .../log/service/BuildLogQueryService.kt | 50 +++++++++++++++- .../apigw/v3/ApigwArtifactoryResourceV3.kt | 24 ++++++++ .../api/apigw/v3/ApigwLogResourceV3.kt | 17 ++++++ .../v3/ApigwArtifactoryResourceV3Impl.kt | 19 ++++++ .../apigw/v3/ApigwLogResourceV3Impl.kt | 10 ++++ .../common/impl/StoreLogServiceImpl.kt | 3 + 11 files changed, 173 insertions(+), 93 deletions(-) diff --git a/src/backend/ci/core/artifactory/api-artifactory/src/main/kotlin/com/tencent/devops/artifactory/api/service/ServiceLogFileResource.kt b/src/backend/ci/core/artifactory/api-artifactory/src/main/kotlin/com/tencent/devops/artifactory/api/service/ServiceLogFileResource.kt index 5181b09da01..b13b674f1e1 100644 --- a/src/backend/ci/core/artifactory/api-artifactory/src/main/kotlin/com/tencent/devops/artifactory/api/service/ServiceLogFileResource.kt +++ b/src/backend/ci/core/artifactory/api-artifactory/src/main/kotlin/com/tencent/devops/artifactory/api/service/ServiceLogFileResource.kt @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.devops.artifactory.api.user +package com.tencent.devops.artifactory.api.service import com.tencent.devops.artifactory.pojo.Url import com.tencent.devops.common.api.auth.AUTH_HEADER_USER_ID @@ -45,11 +45,11 @@ import javax.ws.rs.core.MediaType @Path("/user/artifactories/log") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) -interface UserLogFileResource { +interface ServiceLogFileResource { @ApiOperation("下载日志") @GET - @Path("plugin/{projectId}/{pipelineId}/{buildId}/{elementId}/{executeCount}") + @Path("/{projectId}/{pipelineId}/{buildId}/{elementId}/{executeCount}") fun getPluginLogUrl( @ApiParam("userId", required = true) @HeaderParam(AUTH_HEADER_USER_ID) diff --git a/src/backend/ci/core/log/api-log/src/main/kotlin/com/tencent/devops/log/api/ServiceLogResource.kt b/src/backend/ci/core/log/api-log/src/main/kotlin/com/tencent/devops/log/api/ServiceLogResource.kt index a7679b6af38..82694301876 100644 --- a/src/backend/ci/core/log/api-log/src/main/kotlin/com/tencent/devops/log/api/ServiceLogResource.kt +++ b/src/backend/ci/core/log/api-log/src/main/kotlin/com/tencent/devops/log/api/ServiceLogResource.kt @@ -60,6 +60,9 @@ interface ServiceLogResource { @GET @Path("/{projectId}/{pipelineId}/{buildId}/") fun getInitLogs( + @ApiParam(value = "用户ID", required = true, defaultValue = AUTH_HEADER_USER_ID_DEFAULT_VALUE) + @HeaderParam(AUTH_HEADER_USER_ID) + userId: String, @ApiParam("项目ID", required = true) @PathParam("projectId") projectId: String, @@ -87,6 +90,9 @@ interface ServiceLogResource { @GET @Path("/{projectId}/{pipelineId}/{buildId}/more") fun getMoreLogs( + @ApiParam(value = "用户ID", required = true, defaultValue = AUTH_HEADER_USER_ID_DEFAULT_VALUE) + @HeaderParam(AUTH_HEADER_USER_ID) + userId: String, @ApiParam("项目ID", required = true) @PathParam("projectId") projectId: String, @@ -126,6 +132,9 @@ interface ServiceLogResource { @GET @Path("/{projectId}/{pipelineId}/{buildId}/after") fun getAfterLogs( + @ApiParam(value = "用户ID", required = true, defaultValue = AUTH_HEADER_USER_ID_DEFAULT_VALUE) + @HeaderParam(AUTH_HEADER_USER_ID) + userId: String, @ApiParam("项目ID", required = true) @PathParam("projectId") projectId: String, @@ -157,6 +166,9 @@ interface ServiceLogResource { @Path("/{projectId}/{pipelineId}/{buildId}/download") @Produces(MediaType.APPLICATION_OCTET_STREAM) fun downloadLogs( + @ApiParam(value = "用户ID", required = true, defaultValue = AUTH_HEADER_USER_ID_DEFAULT_VALUE) + @HeaderParam(AUTH_HEADER_USER_ID) + userId: String, @ApiParam("项目ID", required = true) @PathParam("projectId") projectId: String, @@ -181,6 +193,9 @@ interface ServiceLogResource { @GET @Path("/{projectId}/{pipelineId}/{buildId}/mode") fun getLogMode( + @ApiParam(value = "用户ID", required = true, defaultValue = AUTH_HEADER_USER_ID_DEFAULT_VALUE) + @HeaderParam(AUTH_HEADER_USER_ID) + userId: String, @ApiParam("项目ID", required = true) @PathParam("projectId") projectId: String, diff --git a/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/resources/AppLogResourceImpl.kt b/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/resources/AppLogResourceImpl.kt index f990fa6b99e..378543724b4 100644 --- a/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/resources/AppLogResourceImpl.kt +++ b/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/resources/AppLogResourceImpl.kt @@ -27,18 +27,13 @@ package com.tencent.devops.log.resources -import com.tencent.devops.common.api.exception.ParamBlankException -import com.tencent.devops.common.api.exception.PermissionForbiddenException import com.tencent.devops.common.api.pojo.Result -import com.tencent.devops.common.auth.api.AuthPermission -import com.tencent.devops.common.auth.code.PipelineAuthServiceCode import com.tencent.devops.common.log.pojo.EndPageQueryLogs import com.tencent.devops.common.log.pojo.PageQueryLogs import com.tencent.devops.common.log.pojo.QueryLogs import com.tencent.devops.common.web.RestResource import com.tencent.devops.log.api.AppLogResource import com.tencent.devops.log.service.BuildLogQueryService -import com.tencent.devops.log.service.LogPermissionService import org.springframework.beans.factory.annotation.Autowired import javax.ws.rs.core.Response @@ -48,9 +43,7 @@ import javax.ws.rs.core.Response */ @RestResource class AppLogResourceImpl @Autowired constructor( - private val buildLogQuery: BuildLogQueryService, - private val authPermissionApi: LogPermissionService, - private val pipelineAuthServiceCode: PipelineAuthServiceCode + private val buildLogQueryService: BuildLogQueryService ) : AppLogResource { companion object { @@ -70,8 +63,7 @@ class AppLogResourceImpl @Autowired constructor( page: Int?, pageSize: Int? ): Result { - validateAuth(userId, projectId, pipelineId, buildId) - return buildLogQuery.getInitLogsPage( + return buildLogQueryService.getInitLogsPage( userId = userId, projectId = projectId, pipelineId = pipelineId, @@ -101,8 +93,8 @@ class AppLogResourceImpl @Autowired constructor( jobId: String?, executeCount: Int? ): Result { - validateAuth(userId, projectId, pipelineId, buildId) - return buildLogQuery.getMoreLogs( + return buildLogQueryService.getMoreLogs( + userId = userId, projectId = projectId, pipelineId = pipelineId, buildId = buildId, @@ -130,8 +122,8 @@ class AppLogResourceImpl @Autowired constructor( jobId: String?, executeCount: Int? ): Result { - validateAuth(userId, projectId, pipelineId, buildId) - return buildLogQuery.getAfterLogs( + return buildLogQueryService.getAfterLogs( + userId = userId, projectId = projectId, pipelineId = pipelineId, buildId = buildId, @@ -157,8 +149,8 @@ class AppLogResourceImpl @Autowired constructor( jobId: String?, executeCount: Int? ): Result { - validateAuth(userId, projectId, pipelineId, buildId) - return buildLogQuery.getBeforeLogs( + return buildLogQueryService.getBeforeLogs( + userId = userId, projectId = projectId, pipelineId = pipelineId, buildId = buildId, @@ -182,8 +174,8 @@ class AppLogResourceImpl @Autowired constructor( jobId: String?, executeCount: Int? ): Response { - validateAuth(userId, projectId, pipelineId, buildId) - return buildLogQuery.downloadLogs( + return buildLogQueryService.downloadLogs( + userId = userId, projectId = projectId, pipelineId = pipelineId, buildId = buildId, @@ -207,8 +199,7 @@ class AppLogResourceImpl @Autowired constructor( jobId: String?, executeCount: Int? ): Result { - validateAuth(userId, projectId, pipelineId, buildId) - return buildLogQuery.getEndLogsPage( + return buildLogQueryService.getEndLogsPage( userId = userId, projectId = projectId, pipelineId = pipelineId, @@ -234,8 +225,7 @@ class AppLogResourceImpl @Autowired constructor( jobId: String?, executeCount: Int? ): Result { - validateAuth(userId, projectId, pipelineId, buildId) - return buildLogQuery.getBottomLogs( + return buildLogQueryService.getBottomLogs( userId = userId, projectId = projectId, pipelineId = pipelineId, @@ -248,29 +238,4 @@ class AppLogResourceImpl @Autowired constructor( executeCount = executeCount ) } - - private fun validateAuth(userId: String, projectId: String, pipelineId: String, buildId: String) { - if (userId.isBlank()) { - throw ParamBlankException("Invalid userId") - } - if (projectId.isBlank()) { - throw ParamBlankException("Invalid projectId") - } - if (pipelineId.isBlank()) { - throw ParamBlankException("Invalid pipelineId") - } - if (buildId.isBlank()) { - throw ParamBlankException("Invalid buildId") - } - - if (!authPermissionApi.verifyUserLogPermission( - userId = userId, - pipelineId = pipelineId, - projectCode = projectId, - permission = AuthPermission.VIEW - ) - ) { - throw PermissionForbiddenException("用户($userId)无权限在工程($projectId)下查看流水线") - } - } } diff --git a/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/resources/ServiceLogResourceImpl.kt b/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/resources/ServiceLogResourceImpl.kt index b12674cd1f0..cfbb438cfb2 100644 --- a/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/resources/ServiceLogResourceImpl.kt +++ b/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/resources/ServiceLogResourceImpl.kt @@ -46,6 +46,7 @@ class ServiceLogResourceImpl @Autowired constructor( ) : ServiceLogResource { override fun getInitLogs( + userId: String, projectId: String, pipelineId: String, buildId: String, @@ -55,6 +56,7 @@ class ServiceLogResourceImpl @Autowired constructor( executeCount: Int? ): Result { return buildLogQueryService.getInitLogs( + userId = userId, projectId = projectId, pipelineId = pipelineId, buildId = buildId, @@ -66,6 +68,7 @@ class ServiceLogResourceImpl @Autowired constructor( } override fun getMoreLogs( + userId: String, projectId: String, pipelineId: String, buildId: String, @@ -79,6 +82,7 @@ class ServiceLogResourceImpl @Autowired constructor( executeCount: Int? ): Result { return buildLogQueryService.getMoreLogs( + userId = userId, projectId = projectId, pipelineId = pipelineId, buildId = buildId, @@ -94,6 +98,7 @@ class ServiceLogResourceImpl @Autowired constructor( } override fun getAfterLogs( + userId: String, projectId: String, pipelineId: String, buildId: String, @@ -104,6 +109,7 @@ class ServiceLogResourceImpl @Autowired constructor( executeCount: Int? ): Result { return buildLogQueryService.getAfterLogs( + userId = userId, projectId = projectId, pipelineId = pipelineId, buildId = buildId, @@ -116,6 +122,7 @@ class ServiceLogResourceImpl @Autowired constructor( } override fun downloadLogs( + userId: String, projectId: String, pipelineId: String, buildId: String, @@ -124,6 +131,7 @@ class ServiceLogResourceImpl @Autowired constructor( executeCount: Int? ): Response { return buildLogQueryService.downloadLogs( + userId = userId, projectId = projectId, pipelineId = pipelineId, buildId = buildId, @@ -135,6 +143,7 @@ class ServiceLogResourceImpl @Autowired constructor( } override fun getLogMode( + userId: String, projectId: String, pipelineId: String, buildId: String, @@ -142,6 +151,7 @@ class ServiceLogResourceImpl @Autowired constructor( executeCount: Int?, ): Result { return buildLogQueryService.getLogMode( + userId = userId, projectId = projectId, pipelineId = pipelineId, buildId = buildId, diff --git a/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/resources/UserLogResourceImpl.kt b/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/resources/UserLogResourceImpl.kt index d37afc07523..3638aa0e941 100644 --- a/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/resources/UserLogResourceImpl.kt +++ b/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/resources/UserLogResourceImpl.kt @@ -46,8 +46,7 @@ import javax.ws.rs.core.Response */ @RestResource class UserLogResourceImpl @Autowired constructor( - private val buildLogQuery: BuildLogQueryService, - private val logPermissionService: LogPermissionService + private val buildLogQueryService: BuildLogQueryService ) : UserLogResource { override fun getInitLogs( @@ -61,8 +60,8 @@ class UserLogResourceImpl @Autowired constructor( jobId: String?, executeCount: Int? ): Result { - validateAuth(userId, projectId, pipelineId, buildId, AuthPermission.VIEW) - return buildLogQuery.getInitLogs( + return buildLogQueryService.getInitLogs( + userId = userId, projectId = projectId, pipelineId = pipelineId, buildId = buildId, @@ -89,8 +88,8 @@ class UserLogResourceImpl @Autowired constructor( jobId: String?, executeCount: Int? ): Result { - validateAuth(userId, projectId, pipelineId, buildId, AuthPermission.VIEW) - return buildLogQuery.getMoreLogs( + return buildLogQueryService.getMoreLogs( + userId = userId, projectId = projectId, pipelineId = pipelineId, buildId = buildId, @@ -118,8 +117,8 @@ class UserLogResourceImpl @Autowired constructor( jobId: String?, executeCount: Int? ): Result { - validateAuth(userId, projectId, pipelineId, buildId, AuthPermission.VIEW) - return buildLogQuery.getAfterLogs( + return buildLogQueryService.getAfterLogs( + userId = userId, projectId = projectId, pipelineId = pipelineId, buildId = buildId, @@ -143,8 +142,8 @@ class UserLogResourceImpl @Autowired constructor( executeCount: Int?, fileName: String? ): Response { - validateAuth(userId, projectId, pipelineId, buildId, AuthPermission.DOWNLOAD) - return buildLogQuery.downloadLogs( + return buildLogQueryService.downloadLogs( + userId = userId, projectId = projectId, pipelineId = pipelineId, buildId = buildId, @@ -164,8 +163,8 @@ class UserLogResourceImpl @Autowired constructor( tag: String, executeCount: Int? ): Result { - validateAuth(userId, projectId, pipelineId, buildId, AuthPermission.VIEW) - return buildLogQuery.getLogMode( + return buildLogQueryService.getLogMode( + userId = userId, projectId = projectId, pipelineId = pipelineId, buildId = buildId, @@ -173,34 +172,4 @@ class UserLogResourceImpl @Autowired constructor( executeCount = executeCount ) } - - private fun validateAuth( - userId: String, - projectId: String, - pipelineId: String, - buildId: String, - permission: AuthPermission - ) { - if (userId.isBlank()) { - throw ParamBlankException("Invalid userId") - } - if (projectId.isBlank()) { - throw ParamBlankException("Invalid projectId") - } - if (pipelineId.isBlank()) { - throw ParamBlankException("Invalid pipelineId") - } - if (buildId.isBlank()) { - throw ParamBlankException("Invalid buildId") - } - if (!logPermissionService.verifyUserLogPermission( - userId = userId, - pipelineId = pipelineId, - projectCode = projectId, - permission = permission - ) - ) { - throw PermissionForbiddenException("用户($userId)无权限在工程($projectId)下${permission.alias}流水线") - } - } } diff --git a/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/service/BuildLogQueryService.kt b/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/service/BuildLogQueryService.kt index b90ff8afffe..1f0ae8b15e9 100644 --- a/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/service/BuildLogQueryService.kt +++ b/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/service/BuildLogQueryService.kt @@ -27,7 +27,10 @@ package com.tencent.devops.log.service +import com.tencent.devops.common.api.exception.ParamBlankException +import com.tencent.devops.common.api.exception.PermissionForbiddenException import com.tencent.devops.common.api.pojo.Result +import com.tencent.devops.common.auth.api.AuthPermission import com.tencent.devops.common.log.pojo.EndPageQueryLogs import com.tencent.devops.common.log.pojo.PageQueryLogs import com.tencent.devops.common.log.pojo.QueryLogStatus @@ -39,10 +42,12 @@ import javax.ws.rs.core.Response @Service class BuildLogQueryService @Autowired constructor( private val logService: LogService, - private val logStatusService: LogStatusService + private val logStatusService: LogStatusService, + private val logPermissionService: LogPermissionService ) { fun getInitLogs( + userId: String, projectId: String, pipelineId: String, buildId: String, @@ -52,6 +57,7 @@ class BuildLogQueryService @Autowired constructor( executeCount: Int?, subTag: String? = null ): Result { + validateAuth(userId, projectId, pipelineId, buildId, AuthPermission.VIEW) return Result( logService.queryInitLogs( buildId = buildId, @@ -77,6 +83,7 @@ class BuildLogQueryService @Autowired constructor( pageSize: Int?, subTag: String? = null ): Result { + validateAuth(userId, projectId, pipelineId, buildId, AuthPermission.VIEW) return Result( logService.queryInitLogsPage( buildId = buildId, @@ -92,6 +99,7 @@ class BuildLogQueryService @Autowired constructor( } fun getMoreLogs( + userId: String, projectId: String, pipelineId: String, buildId: String, @@ -105,6 +113,7 @@ class BuildLogQueryService @Autowired constructor( executeCount: Int?, subTag: String? = null ): Result { + validateAuth(userId, projectId, pipelineId, buildId, AuthPermission.VIEW) return Result( logService.queryLogsBetweenLines( buildId = buildId, @@ -122,6 +131,7 @@ class BuildLogQueryService @Autowired constructor( } fun getAfterLogs( + userId: String, projectId: String, pipelineId: String, buildId: String, @@ -132,6 +142,7 @@ class BuildLogQueryService @Autowired constructor( executeCount: Int?, subTag: String? = null ): Result { + validateAuth(userId, projectId, pipelineId, buildId, AuthPermission.VIEW) return Result( logService.queryLogsAfterLine( buildId = buildId, @@ -146,6 +157,7 @@ class BuildLogQueryService @Autowired constructor( } fun getBeforeLogs( + userId: String, projectId: String, pipelineId: String, buildId: String, @@ -157,6 +169,7 @@ class BuildLogQueryService @Autowired constructor( executeCount: Int?, subTag: String? = null ): Result { + validateAuth(userId, projectId, pipelineId, buildId, AuthPermission.VIEW) return Result( logService.queryLogsBeforeLine( buildId = buildId, @@ -172,12 +185,14 @@ class BuildLogQueryService @Autowired constructor( } fun getLogMode( + userId: String, projectId: String, pipelineId: String, buildId: String, tag: String, executeCount: Int? ): Result { + validateAuth(userId, projectId, pipelineId, buildId, AuthPermission.VIEW) return Result( logStatusService.getStorageMode( buildId = buildId, @@ -188,6 +203,7 @@ class BuildLogQueryService @Autowired constructor( } fun downloadLogs( + userId: String, projectId: String, pipelineId: String, buildId: String, @@ -197,6 +213,7 @@ class BuildLogQueryService @Autowired constructor( fileName: String?, subTag: String? = null ): Response { + validateAuth(userId, projectId, pipelineId, buildId, AuthPermission.DOWNLOAD) return logService.downloadLogs( pipelineId = pipelineId, buildId = buildId, @@ -244,6 +261,7 @@ class BuildLogQueryService @Autowired constructor( executeCount: Int?, subTag: String? = null ): Result { + validateAuth(userId, projectId, pipelineId, buildId, AuthPermission.VIEW) return Result(logService.getBottomLogs( pipelineId = pipelineId, buildId = buildId, @@ -255,4 +273,34 @@ class BuildLogQueryService @Autowired constructor( size = size )) } + + private fun validateAuth( + userId: String, + projectId: String, + pipelineId: String, + buildId: String, + permission: AuthPermission + ) { + if (userId.isBlank()) { + throw ParamBlankException("Invalid userId") + } + if (projectId.isBlank()) { + throw ParamBlankException("Invalid projectId") + } + if (pipelineId.isBlank()) { + throw ParamBlankException("Invalid pipelineId") + } + if (buildId.isBlank()) { + throw ParamBlankException("Invalid buildId") + } + if (!logPermissionService.verifyUserLogPermission( + userId = userId, + pipelineId = pipelineId, + projectCode = projectId, + permission = permission + ) + ) { + throw PermissionForbiddenException("用户($userId)无权限在工程($projectId)下${permission.alias}流水线") + } + } } diff --git a/src/backend/ci/core/openapi/api-openapi/src/main/kotlin/com/tencent/devops/openapi/api/apigw/v3/ApigwArtifactoryResourceV3.kt b/src/backend/ci/core/openapi/api-openapi/src/main/kotlin/com/tencent/devops/openapi/api/apigw/v3/ApigwArtifactoryResourceV3.kt index deb5a7f0d54..edec27a89f5 100644 --- a/src/backend/ci/core/openapi/api-openapi/src/main/kotlin/com/tencent/devops/openapi/api/apigw/v3/ApigwArtifactoryResourceV3.kt +++ b/src/backend/ci/core/openapi/api-openapi/src/main/kotlin/com/tencent/devops/openapi/api/apigw/v3/ApigwArtifactoryResourceV3.kt @@ -108,4 +108,28 @@ interface ApigwArtifactoryResourceV3 { @QueryParam("pageSize") pageSize: Int? ): Result> + + @ApiOperation("下载熔断归档的全量日志") + @GET + @Path("/log/{pipelineId}/{buildId}/{elementId}/{executeCount}") + fun getPluginLogUrl( + @ApiParam("userId", required = true) + @HeaderParam(AUTH_HEADER_USER_ID) + userId: String, + @ApiParam("项目 ID", required = true) + @PathParam("projectId") + projectId: String, + @ApiParam("流水线 ID", required = true) + @PathParam("pipelineId") + pipelineId: String, + @ApiParam("构建 ID", required = true) + @PathParam("buildId") + buildId: String, + @ApiParam("插件 elementId", required = true) + @PathParam("elementId") + elementId: String, + @ApiParam("执行序号", required = true) + @PathParam("executeCount") + executeCount: String + ): Result } diff --git a/src/backend/ci/core/openapi/api-openapi/src/main/kotlin/com/tencent/devops/openapi/api/apigw/v3/ApigwLogResourceV3.kt b/src/backend/ci/core/openapi/api-openapi/src/main/kotlin/com/tencent/devops/openapi/api/apigw/v3/ApigwLogResourceV3.kt index 69c0a71002c..3307ac9a5e5 100644 --- a/src/backend/ci/core/openapi/api-openapi/src/main/kotlin/com/tencent/devops/openapi/api/apigw/v3/ApigwLogResourceV3.kt +++ b/src/backend/ci/core/openapi/api-openapi/src/main/kotlin/com/tencent/devops/openapi/api/apigw/v3/ApigwLogResourceV3.kt @@ -29,6 +29,8 @@ package com.tencent.devops.openapi.api.apigw.v3 import com.tencent.devops.common.api.auth.AUTH_HEADER_DEVOPS_APP_CODE import com.tencent.devops.common.api.auth.AUTH_HEADER_DEVOPS_APP_CODE_DEFAULT_VALUE +import com.tencent.devops.common.api.auth.AUTH_HEADER_USER_ID +import com.tencent.devops.common.api.auth.AUTH_HEADER_USER_ID_DEFAULT_VALUE import com.tencent.devops.common.api.pojo.Result import com.tencent.devops.common.log.pojo.QueryLogStatus import com.tencent.devops.common.log.pojo.QueryLogs @@ -61,6 +63,9 @@ interface ApigwLogResourceV3 { @ApiParam(value = "apigw Type", required = true) @PathParam("apigwType") apigwType: String?, + @ApiParam("用户ID", required = true, defaultValue = AUTH_HEADER_USER_ID_DEFAULT_VALUE) + @HeaderParam(AUTH_HEADER_USER_ID) + userId: String, @ApiParam("项目ID", required = true) @PathParam("projectId") projectId: String, @@ -94,6 +99,9 @@ interface ApigwLogResourceV3 { @ApiParam(value = "apigw Type", required = true) @PathParam("apigwType") apigwType: String?, + @ApiParam("用户ID", required = true, defaultValue = AUTH_HEADER_USER_ID_DEFAULT_VALUE) + @HeaderParam(AUTH_HEADER_USER_ID) + userId: String, @ApiParam("项目ID", required = true) @PathParam("projectId") projectId: String, @@ -139,6 +147,9 @@ interface ApigwLogResourceV3 { @ApiParam(value = "apigw Type", required = true) @PathParam("apigwType") apigwType: String?, + @ApiParam("用户ID", required = true, defaultValue = AUTH_HEADER_USER_ID_DEFAULT_VALUE) + @HeaderParam(AUTH_HEADER_USER_ID) + userId: String, @ApiParam("项目ID", required = true) @PathParam("projectId") projectId: String, @@ -176,6 +187,9 @@ interface ApigwLogResourceV3 { @ApiParam(value = "apigw Type", required = true) @PathParam("apigwType") apigwType: String?, + @ApiParam("用户ID", required = true, defaultValue = AUTH_HEADER_USER_ID_DEFAULT_VALUE) + @HeaderParam(AUTH_HEADER_USER_ID) + userId: String, @ApiParam("项目ID", required = true) @PathParam("projectId") projectId: String, @@ -206,6 +220,9 @@ interface ApigwLogResourceV3 { @ApiParam(value = "apigw Type", required = true) @PathParam("apigwType") apigwType: String?, + @ApiParam("用户ID", required = true, defaultValue = AUTH_HEADER_USER_ID_DEFAULT_VALUE) + @HeaderParam(AUTH_HEADER_USER_ID) + userId: String, @ApiParam("项目ID", required = true) @PathParam("projectId") projectId: String, diff --git a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v3/ApigwArtifactoryResourceV3Impl.kt b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v3/ApigwArtifactoryResourceV3Impl.kt index 16ae2ba2d49..89c2e8e4c34 100644 --- a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v3/ApigwArtifactoryResourceV3Impl.kt +++ b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v3/ApigwArtifactoryResourceV3Impl.kt @@ -28,6 +28,7 @@ package com.tencent.devops.openapi.resources.apigw.v3 import com.tencent.devops.artifactory.api.service.ServiceArtifactoryResource +import com.tencent.devops.artifactory.api.service.ServiceLogFileResource import com.tencent.devops.artifactory.pojo.FileInfo import com.tencent.devops.artifactory.pojo.SearchProps import com.tencent.devops.artifactory.pojo.Url @@ -86,4 +87,22 @@ class ApigwArtifactoryResourceV3Impl @Autowired constructor( searchProps = searchProps ) } + + override fun getPluginLogUrl( + userId: String, + projectId: String, + pipelineId: String, + buildId: String, + elementId: String, + executeCount: String, + ): Result { + return client.get(ServiceLogFileResource::class).getPluginLogUrl( + userId = userId, + projectId = projectId, + pipelineId = pipelineId, + buildId = buildId, + elementId = elementId, + executeCount = executeCount + ) + } } diff --git a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v3/ApigwLogResourceV3Impl.kt b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v3/ApigwLogResourceV3Impl.kt index c1cea94764a..170990755a7 100644 --- a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v3/ApigwLogResourceV3Impl.kt +++ b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v3/ApigwLogResourceV3Impl.kt @@ -45,6 +45,7 @@ class ApigwLogResourceV3Impl @Autowired constructor( override fun getInitLogs( appCode: String?, apigwType: String?, + userId: String, projectId: String, pipelineId: String, buildId: String, @@ -58,6 +59,7 @@ class ApigwLogResourceV3Impl @Autowired constructor( "elementId[$elementId] jobId[$jobId] executeCount[$executeCount] debug[$debug] jobId[$jobId]" ) return client.get(ServiceLogResource::class).getInitLogs( + userId = userId, projectId = projectId, pipelineId = pipelineId, buildId = buildId, @@ -71,6 +73,7 @@ class ApigwLogResourceV3Impl @Autowired constructor( override fun getMoreLogs( appCode: String?, apigwType: String?, + userId: String, projectId: String, pipelineId: String, buildId: String, @@ -88,6 +91,7 @@ class ApigwLogResourceV3Impl @Autowired constructor( "executeCount[$executeCount]fromStart[$fromStart]start[$start]end[$end]tag[$tag]jobId[$jobId]" ) return client.get(ServiceLogResource::class).getMoreLogs( + userId = userId, projectId = projectId, pipelineId = pipelineId, buildId = buildId, @@ -105,6 +109,7 @@ class ApigwLogResourceV3Impl @Autowired constructor( override fun getAfterLogs( appCode: String?, apigwType: String?, + userId: String, projectId: String, pipelineId: String, buildId: String, @@ -120,6 +125,7 @@ class ApigwLogResourceV3Impl @Autowired constructor( "start[$start]tag[$tag]jobId[$jobId]" ) return client.get(ServiceLogResource::class).getAfterLogs( + userId = userId, projectId = projectId, pipelineId = pipelineId, buildId = buildId, @@ -134,6 +140,7 @@ class ApigwLogResourceV3Impl @Autowired constructor( override fun downloadLogs( appCode: String?, apigwType: String?, + userId: String, projectId: String, pipelineId: String, buildId: String, @@ -146,6 +153,7 @@ class ApigwLogResourceV3Impl @Autowired constructor( "jobId[$jobId] executeCount[$executeCount] tag[$tag] jobId[$jobId]" ) return client.get(ServiceLogResource::class).downloadLogs( + userId = userId, projectId = projectId, pipelineId = pipelineId, buildId = buildId, @@ -158,6 +166,7 @@ class ApigwLogResourceV3Impl @Autowired constructor( override fun getLogMode( appCode: String?, apigwType: String?, + userId: String, projectId: String, pipelineId: String, buildId: String, @@ -169,6 +178,7 @@ class ApigwLogResourceV3Impl @Autowired constructor( "executeCount[$executeCount] tag[$tag]" ) return client.get(ServiceLogResource::class).getLogMode( + userId = userId, projectId = projectId, pipelineId = pipelineId, buildId = buildId, diff --git a/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/service/common/impl/StoreLogServiceImpl.kt b/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/service/common/impl/StoreLogServiceImpl.kt index 054127a4556..fd82f54bdca 100644 --- a/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/service/common/impl/StoreLogServiceImpl.kt +++ b/src/backend/ci/core/store/biz-store/src/main/kotlin/com/tencent/devops/store/service/common/impl/StoreLogServiceImpl.kt @@ -69,6 +69,7 @@ class StoreLogServiceImpl @Autowired constructor( } val queryLogsResult = client.get(ServiceLogResource::class) .getInitLogs( + userId = userId, projectId = projectCode, pipelineId = pipelineId, buildId = buildId, @@ -100,6 +101,7 @@ class StoreLogServiceImpl @Autowired constructor( } val queryLogsResult = client.get(ServiceLogResource::class) .getAfterLogs( + userId = userId, projectId = projectCode, pipelineId = pipelineId, buildId = buildId, @@ -135,6 +137,7 @@ class StoreLogServiceImpl @Autowired constructor( } val queryLogsResult = client.get(ServiceLogResource::class) .getMoreLogs( + userId = userId, projectId = projectCode, pipelineId = pipelineId, buildId = buildId,