Skip to content

Commit

Permalink
feat: 构建并推送镜像支持插件接入 TencentBlueKing#5032
Browse files Browse the repository at this point in the history
Signed-off-by: sawyersong <sawyersong@tencent.com>
  • Loading branch information
sawyersong2 committed Sep 1, 2021
2 parents bb595ef + 77c411d commit c1e0812
Show file tree
Hide file tree
Showing 60 changed files with 1,942 additions and 438 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ data class DockerDispatchType(
// 商店镜像版本
override var imageVersion: String? = "",
// 商店镜像名称
override var imageName: String? = ""
override var imageName: String? = "",
// docker资源配置ID
var performanceConfigId: Int = 0
) : StoreDispatchType(dockerBuildVersion = if (dockerBuildVersion.isNullOrBlank()) {
imageCode
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
*/

dependencies {
api(project(":core:dispatch:api-dispatch"))
api(project(":core:common:common-api"))
api(project(":core:common:common-web"))
api(project(":core:store:api-store-image"))
}

plugins {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ package com.tencent.devops.dispatch.docker.api.builds

import com.tencent.devops.common.api.pojo.Result
import com.tencent.devops.common.web.mq.alert.AlertLevel
import com.tencent.devops.dispatch.docker.pojo.DockerHostInfo
import com.tencent.devops.dispatch.docker.pojo.DockerIpInfoVO
import com.tencent.devops.dispatch.docker.pojo.resource.DockerResourceOptionsVO
import com.tencent.devops.store.pojo.image.response.ImageRepoInfo
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
Expand All @@ -49,108 +49,6 @@ import javax.ws.rs.core.MediaType
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)@Suppress("ALL")
interface BuildDockerHostResource {

/* @ApiOperation("轮询开始任务")
@POST
@Path("/startBuild")
fun startBuild(
@ApiParam("dockerHost标识", required = true)
@QueryParam("hostTag")
hostTag: String
): Result<DockerHostBuildInfo>?
@ApiOperation("轮询结束任务")
@POST
@Path("/endBuild")
fun endBuild(
@ApiParam("dockerHost标识", required = true)
@QueryParam("hostTag")
hostTag: String
): Result<DockerHostBuildInfo>?
@ApiOperation("上报containerId")
@POST
@Path("/containerId")
fun reportContainerId(
@ApiParam("buildId", required = true)
@QueryParam("buildId")
buildId: String,
@ApiParam("vmSeqId", required = true)
@QueryParam("vmSeqId")
vmSeqId: Int,
@ApiParam("containerId", required = true)
@QueryParam("containerId")
containerId: String,
@ApiParam("hostTag", required = true)
@QueryParam("hostTag")
hostTag: String? = null
): Result<Boolean>?
@ApiOperation("回滚任务到队列里面")
@POST
@Path("/rollbackBuild")
fun rollbackBuild(
@ApiParam("buildId", required = true)
@QueryParam("buildId")
buildId: String,
@ApiParam("vmSeqId", required = true)
@QueryParam("vmSeqId")
vmSeqId: Int,
@ApiParam("shutdown", required = true)
@QueryParam("shutdown")
shutdown: Boolean?
): Result<Boolean>?
@ApiOperation("轮询debug开始任务")
@POST
@Path("/startDebug")
fun startDebug(
@ApiParam("dockerHost标识", required = true)
@QueryParam("hostTag")
hostTag: String
): Result<ContainerInfo>?
@ApiOperation("轮询debug结束任务")
@POST
@Path("/endDebug")
fun endDebug(
@ApiParam("dockerHost标识", required = true)
@QueryParam("hostTag")
hostTag: String
): Result<ContainerInfo>?
@ApiOperation("上报containerId")
@POST
@Path("/reportDebugContainerId")
fun reportDebugContainerId(
@ApiParam("pipelineId", required = true)
@QueryParam("pipelineId")
pipelineId: String,
@ApiParam("vmSeqId", required = true)
@QueryParam("vmSeqId")
vmSeqId: String,
@ApiParam("containerId", required = true)
@QueryParam("containerId")
containerId: String
): Result<Boolean>?
@ApiOperation("回滚debug任务到队列里面")
@POST
@Path("/rollbackDebug")
fun rollbackDebug(
@ApiParam("pipelineId", required = true)
@QueryParam("pipelineId")
pipelineId: String,
@ApiParam("vmSeqId", required = true)
@QueryParam("vmSeqId")
vmSeqId: String,
@ApiParam("shutdown", required = true)
@QueryParam("shutdown")
shutdown: Boolean? = false,
@ApiParam("message", required = true)
message: String?
): Result<Boolean>?*/

@ApiOperation("系统监控告警")
@POST
@Path("/alert")
Expand All @@ -166,14 +64,17 @@ interface BuildDockerHostResource {
message: String
): Result<Boolean>?

@ApiOperation("获取主机信息")
@GET
@Path("/host")
fun getHost(
@ApiParam("dockerHost标识", required = true)
@QueryParam("hostTag")
hostTag: String
): Result<DockerHostInfo>?
@Path("/resource-config/pipelines/{pipelineId}/vmSeqs/{vmSeqId}")
@ApiOperation("获取蓝盾项目的docker性能配置")
fun getResourceConfig(
@ApiParam("蓝盾项目ID", required = true)
@PathParam("pipelineId")
pipelineId: String,
@ApiParam("蓝盾项目ID", required = true)
@PathParam("vmSeqId")
vmSeqId: String
): Result<DockerResourceOptionsVO>

@ApiOperation("上报日志信息")
@POST
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
* 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.dispatch.docker.api.op

import com.tencent.devops.common.api.auth.AUTH_HEADER_DEVOPS_USER_ID
import com.tencent.devops.common.api.auth.AUTH_HEADER_DEVOPS_USER_ID_DEFAULT_VALUE
import com.tencent.devops.common.api.pojo.Result
import com.tencent.devops.dispatch.docker.pojo.resource.DockerResourceOptionsVO
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import io.swagger.annotations.ApiParam
import javax.ws.rs.Consumes
import javax.ws.rs.DELETE
import javax.ws.rs.GET
import javax.ws.rs.HeaderParam
import javax.ws.rs.POST
import javax.ws.rs.PUT
import javax.ws.rs.Path
import javax.ws.rs.PathParam
import javax.ws.rs.Produces
import javax.ws.rs.core.MediaType

@Api(tags = ["OP_DISPATCH_RESOURCE"], description = "OP-构建机性能配置接口")
@Path("/op/dispatch-docker")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
interface OPDockerResourceOptionsResource {

@GET
@Path("/resource-options/list")
@ApiOperation("获取docker性能基础配置列表")
fun listResourceOptions(
@ApiParam("用户ID", required = true, defaultValue = AUTH_HEADER_DEVOPS_USER_ID_DEFAULT_VALUE)
@HeaderParam(AUTH_HEADER_DEVOPS_USER_ID)
userId: String
): Result<List<DockerResourceOptionsVO>>

@POST
@Path("/resource-options/add")
@ApiOperation("新增性能基础配置")
fun createResourceOptions(
@ApiParam("用户ID", required = true, defaultValue = AUTH_HEADER_DEVOPS_USER_ID_DEFAULT_VALUE)
@HeaderParam(AUTH_HEADER_DEVOPS_USER_ID)
userId: String,
@ApiParam("性能配置", required = true)
dockerResourceOptionsVO: DockerResourceOptionsVO
): Result<Boolean>

@PUT
@Path("/resource-options/optionId/{id}/update")
@ApiOperation("更新性能基础配置")
fun updateResourceOptions(
@ApiParam("用户ID", required = true, defaultValue = AUTH_HEADER_DEVOPS_USER_ID_DEFAULT_VALUE)
@HeaderParam(AUTH_HEADER_DEVOPS_USER_ID)
userId: String,
@ApiParam("配置ID", required = true)
@PathParam("id")
id: Long,
@ApiParam("性能配置", required = true)
dockerResourceOptionsVO: DockerResourceOptionsVO
): Result<Boolean>

@DELETE
@Path("/resource-options/optionId/{id}/delete")
@ApiOperation("删除docker性能基础配置")
fun deleteResourceOptions(
@ApiParam("用户ID", required = true, defaultValue = AUTH_HEADER_DEVOPS_USER_ID_DEFAULT_VALUE)
@HeaderParam(AUTH_HEADER_DEVOPS_USER_ID)
userId: String,
@ApiParam("ID", required = true)
@PathParam("id")
projectId: Long
): Result<Boolean>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* 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.dispatch.docker.api.op

import com.tencent.devops.common.api.auth.AUTH_HEADER_DEVOPS_USER_ID
import com.tencent.devops.common.api.auth.AUTH_HEADER_DEVOPS_USER_ID_DEFAULT_VALUE
import com.tencent.devops.common.api.pojo.Result
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import io.swagger.annotations.ApiParam
import javax.ws.rs.Consumes
import javax.ws.rs.DELETE
import javax.ws.rs.GET
import javax.ws.rs.HeaderParam
import javax.ws.rs.POST
import javax.ws.rs.Path
import javax.ws.rs.PathParam
import javax.ws.rs.Produces
import javax.ws.rs.core.MediaType

@Api(tags = ["OP_DISPATCH_RESOURCE"], description = "OP-构建机性能配置接口")
@Path("/op/dispatch-docker")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
interface OPDockerResourceWhiteListResource {

@GET
@Path("/resource-whitelist/list")
@ApiOperation("获取资源配置白名单列表")
fun getResourceWhitelist(
@ApiParam("用户ID", required = true, defaultValue = AUTH_HEADER_DEVOPS_USER_ID_DEFAULT_VALUE)
@HeaderParam(AUTH_HEADER_DEVOPS_USER_ID)
userId: String
): Result<List<String>>

@POST
@Path("/resource-whitelist/projects/{projectId}/add")
@ApiOperation("新增资源配置白名单")
fun addResourceWhitelist(
@ApiParam("用户ID", required = true, defaultValue = AUTH_HEADER_DEVOPS_USER_ID_DEFAULT_VALUE)
@HeaderParam(AUTH_HEADER_DEVOPS_USER_ID)
userId: String,
@ApiParam("服务ID", required = true)
@PathParam("projectId")
projectId: String
): Result<Boolean>

@DELETE
@Path("/resource-whitelist/projects/{projectId}/delete")
@ApiOperation("删除资源配置白名单")
fun deleteResourceWhitelist(
@ApiParam("用户ID", required = true, defaultValue = AUTH_HEADER_DEVOPS_USER_ID_DEFAULT_VALUE)
@HeaderParam(AUTH_HEADER_DEVOPS_USER_ID)
userId: String,
@ApiParam("服务ID", required = true)
@PathParam("projectId")
projectId: String
): Result<Boolean>
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ package com.tencent.devops.dispatch.docker.api.user
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.dispatch.pojo.ContainerInfo
import com.tencent.devops.dispatch.pojo.DebugStartParam
import com.tencent.devops.dispatch.docker.pojo.ContainerInfo
import com.tencent.devops.dispatch.docker.pojo.DebugStartParam
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import io.swagger.annotations.ApiParam
Expand Down
Loading

0 comments on commit c1e0812

Please sign in to comment.