Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pref:研发商店组件内置打包流水线都归属到统一的平台项目下 #10475 #11046

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
2e57d81
pref:研发商店组件内置打包流水线都归属到统一的平台项目下 #10475
carlyin0801 Jun 5, 2024
a6dbd63
pref:研发商店组件内置打包流水线都归属到统一的平台项目下 #10475
carlyin0801 Jun 6, 2024
b8b4ea5
pref:研发商店组件内置打包流水线都归属到统一的平台项目下 #10475
carlyin0801 Jun 6, 2024
3d7cdbe
pref:研发商店组件内置打包流水线都归属到统一的平台项目下 #10475
carlyin0801 Jun 12, 2024
62971a1
pref:研发商店组件内置打包流水线都归属到统一的平台项目下 TencentBlueKing#10475
carlyin0801 Sep 9, 2024
f3458d3
pref:研发商店组件内置打包流水线都归属到统一的平台项目下 TencentBlueKing#10475
carlyin0801 Sep 9, 2024
89149e0
pref:研发商店组件内置打包流水线都归属到统一的平台项目下 #10475
yjieliang Sep 13, 2024
d9b78a0
pref:研发商店组件内置打包流水线都归属到统一的平台项目下 #10475
yjieliang Sep 13, 2024
56720bb
pref:研发商店组件内置打包流水线都归属到统一的平台项目下 #10475
yjieliang Sep 14, 2024
d87f10e
pref:研发商店组件内置打包流水线都归属到统一的平台项目下 #10475
yjieliang Sep 14, 2024
bc2efcd
pref:研发商店组件内置打包流水线都归属到统一的平台项目下 #10475
yjieliang Sep 14, 2024
13bd39f
pref:研发商店组件内置打包流水线都归属到统一的平台项目下 #10475
yjieliang Sep 14, 2024
1b832ea
pref:研发商店组件内置打包流水线都归属到统一的平台项目下 #10475
yjieliang Sep 14, 2024
42c69a4
pref:研发商店组件内置打包流水线都归属到统一的平台项目下 #10475
yjieliang Sep 14, 2024
bdb12af
pref:研发商店组件内置打包流水线都归属到统一的平台项目下 #10475
yjieliang Sep 14, 2024
f88fe68
pref:研发商店组件内置打包流水线都归属到统一的平台项目下 #10475
yjieliang Sep 14, 2024
016924c
pref:研发商店组件内置打包流水线都归属到统一的平台项目下 #10475
yjieliang Sep 14, 2024
8a3dfae
pref:研发商店组件内置打包流水线都归属到统一的平台项目下 #10475
yjieliang Sep 18, 2024
9e14b01
pref:研发商店组件内置打包流水线都归属到统一的平台项目下 #10475
yjieliang Sep 18, 2024
d6afd2d
pref:研发商店组件内置打包流水线都归属到统一的平台项目下 #10475
yjieliang Sep 23, 2024
6e900de
pref:研发商店组件内置打包流水线都归属到统一的平台项目下 #10475
yjieliang Sep 25, 2024
c034e74
pref:研发商店组件内置打包流水线都归属到统一的平台项目下 #10475
yjieliang Sep 13, 2024
dac56b4
Merge remote-tracking branch 'carlyin-bkci/issue_10475_innerPipeline_…
yjieliang Oct 9, 2024
599bde4
Merge branch 'master' into issue_10475_innerPipeline_fix_yj
yjieliang Oct 9, 2024
10533a6
pref:研发商店组件内置打包流水线都归属到统一的平台项目下 #10475
yjieliang Oct 9, 2024
9304a67
pref:研发商店组件内置打包流水线都归属到统一的平台项目下 #10475
yjieliang Oct 18, 2024
20c1698
pref:研发商店组件内置打包流水线都归属到统一的平台项目下 #10475
yjieliang Oct 18, 2024
828fa76
Merge branch 'master' into issue_10475_innerPipeline_fix_yj
yjieliang Oct 21, 2024
a053e58
pref:研发商店组件内置打包流水线都归属到统一的平台项目下 #10475
yjieliang Oct 21, 2024
06cc423
pref:研发商店组件内置打包流水线都归属到统一的平台项目下 #10475
yjieliang Nov 19, 2024
15922b8
pref:研发商店组件内置打包流水线都归属到统一的平台项目下 #10475
yjieliang Nov 28, 2024
0a2da95
Merge branch 'master' into issue_10475_innerPipeline_fix_yj
yjieliang Nov 28, 2024
0ea6fb3
pref:研发商店组件内置打包流水线都归属到统一的平台项目下 #10475
yjieliang Nov 28, 2024
07a3467
pref:研发商店组件内置打包流水线都归属到统一的平台项目下 #10475
yjieliang Nov 28, 2024
c73cd72
pref:研发商店组件内置打包流水线都归属到统一的平台项目下 #10475
yjieliang Dec 6, 2024
014432d
pref:研发商店组件内置打包流水线都归属到统一的平台项目下 #10475
yjieliang Dec 9, 2024
ce81105
pref:研发商店组件内置打包流水线都归属到统一的平台项目下 #10475
yjieliang Dec 9, 2024
1b250a2
pref:研发商店组件内置打包流水线都归属到统一的平台项目下 #10475
yjieliang Dec 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,11 @@ class PipelineAtomService @Autowired constructor(

private fun validateUserAtomPermission(atomCode: String, userId: String) {
val validateResult =
client.get(ServiceStoreResource::class).isStoreMember(atomCode, StoreTypeEnum.ATOM, userId)
client.get(ServiceStoreResource::class).validatePipelineUserAtomPermission(
storeCode = atomCode,
storeType = StoreTypeEnum.ATOM,
userId = userId
)
if (validateResult.isNotOk()) {
throw ErrorCodeException(
errorCode = validateResult.status.toString(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* 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.store.api.common

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.store.pojo.common.enums.StoreTypeEnum
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.Parameter
import io.swagger.v3.oas.annotations.tags.Tag
import javax.ws.rs.Consumes
import javax.ws.rs.DELETE
import javax.ws.rs.HeaderParam
import javax.ws.rs.Path
import javax.ws.rs.Produces
import javax.ws.rs.QueryParam
import javax.ws.rs.core.MediaType

@Tag(name = "OP_STORE", description = "OP-商店")
@Path("/op/store")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
interface OpStoreResource {

@Operation(summary = "删除组件内置流水线")
@DELETE
@Path("/inner/pipeline/delete")
fun deleteStoreInnerPipeline(
@Parameter(description = "用户ID", required = true, example = AUTH_HEADER_USER_ID_DEFAULT_VALUE)
@HeaderParam(AUTH_HEADER_USER_ID)
userId: String,
@Parameter(description = "组件类型", required = false)
@QueryParam("storeType")
storeType: StoreTypeEnum? = null,
@Parameter(description = "组件标识", required = false)
@QueryParam("storeCode")
storeCode: String? = null,
@Parameter(description = "需排除的项目", required = false)
@QueryParam("excludeProjectCode")
excludeProjectCode: String? = null
): Result<Boolean>
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,21 @@ interface ServiceStoreResource {
userId: String
): Result<Boolean>

@Operation(summary = "校验流水线用户访问插件信息权限")
@GET
@Path("/codes/{storeCode}/pipeline/user/validate")
fun validatePipelineUserAtomPermission(
@Parameter(description = "标识", required = true)
@PathParam("storeCode")
storeCode: String,
@Parameter(description = "类型", required = true)
@QueryParam("storeType")
storeType: StoreTypeEnum,
@Parameter(description = "用户ID", required = true)
@QueryParam("userId")
userId: String
): Result<Boolean>

@Operation(summary = "判断错误码是否合规")
@POST
@Path("/codes/{storeCode}/errorCode/compliance")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import com.tencent.devops.store.pojo.common.KEY_CREATOR
import com.tencent.devops.store.pojo.common.KEY_LANGUAGE
import com.tencent.devops.store.pojo.common.KEY_PROJECT_CODE
import com.tencent.devops.store.pojo.common.KEY_STORE_CODE
import com.tencent.devops.store.pojo.common.STORE_CODE
import com.tencent.devops.store.pojo.common.StoreBaseInfo
import com.tencent.devops.store.pojo.common.enums.StoreProjectTypeEnum
import com.tencent.devops.store.pojo.common.enums.StoreTypeEnum
Expand Down Expand Up @@ -193,4 +194,10 @@ class AtomCommonDao : AbstractStoreCommonDao() {
.fetchAny()?.into(String::class.java)
}
}

override fun getStoreCodeById(dslContext: DSLContext, storeId: String): String? {
return with(TAtom.T_ATOM) {
dslContext.select(ATOM_CODE).from(this).where(ID.eq(storeId)).fetchOne(0, String::class.java)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ class MarketAtomEnvInfoDao {
atomCode: String,
version: String,
atomDefaultFlag: Boolean,
atomStatusList: List<Byte>?
atomStatusList: List<Byte>?,
queryProjectFlag: Boolean = true
): Record? {
val tAtom = TAtom.T_ATOM
val tStoreProjectRel = TStoreProjectRel.T_STORE_PROJECT_REL
Expand All @@ -115,17 +116,21 @@ class MarketAtomEnvInfoDao {
atomStatusList = atomStatusList
)).orderBy(tAtom.CREATE_TIME.desc()).limit(1).fetchOne()
} else {
getAtomBaseInfoStep(dslContext, tAtom)
.join(tStoreProjectRel)
.on(tAtom.ATOM_CODE.eq(tStoreProjectRel.STORE_CODE))
.where(queryNormalAtomCondition(
val baseStep = getAtomBaseInfoStep(dslContext, tAtom)
if (queryProjectFlag) {
baseStep.join(tStoreProjectRel).on(tAtom.ATOM_CODE.eq(tStoreProjectRel.STORE_CODE))
}
baseStep.where(
queryNormalAtomCondition(
tAtom = tAtom,
tStoreProjectRel = tStoreProjectRel,
projectCode = projectCode,
atomCode = atomCode,
version = version,
atomStatusList = atomStatusList
)).orderBy(tAtom.CREATE_TIME.desc()).limit(1).fetchOne()
atomStatusList = atomStatusList,
queryProjectFlag = queryProjectFlag
)
).orderBy(tAtom.CREATE_TIME.desc()).limit(1).fetchOne()
}
}

Expand Down Expand Up @@ -164,7 +169,7 @@ class MarketAtomEnvInfoDao {
val conditions = mutableListOf<Condition>()
conditions.add(tAtom.ATOM_CODE.eq(atomCode))
conditions.add(tAtom.VERSION.like(VersionUtils.generateQueryVersion(version)))
if (atomStatusList != null && atomStatusList.isNotEmpty()) {
if (!atomStatusList.isNullOrEmpty()) {
conditions.add(tAtom.ATOM_STATUS.`in`(atomStatusList))
}
return conditions
Expand All @@ -187,12 +192,15 @@ class MarketAtomEnvInfoDao {
projectCode: String,
atomCode: String,
version: String,
atomStatusList: List<Byte>?
atomStatusList: List<Byte>?,
queryProjectFlag: Boolean = true
): MutableList<Condition> {
val conditions = getBaseQueryCondition(tAtom, atomCode, version, atomStatusList)
conditions.add(tAtom.DEFAULT_FLAG.eq(false)) // 查普通插件
conditions.add(tStoreProjectRel.PROJECT_CODE.eq(projectCode))
conditions.add(tStoreProjectRel.STORE_TYPE.eq(StoreTypeEnum.ATOM.type.toByte()))
if (queryProjectFlag) {
conditions.add(tStoreProjectRel.PROJECT_CODE.eq(projectCode))
conditions.add(tStoreProjectRel.STORE_TYPE.eq(StoreTypeEnum.ATOM.type.toByte()))
}
return conditions
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ import com.tencent.devops.common.redis.RedisLock
import com.tencent.devops.common.redis.RedisOperation
import com.tencent.devops.common.web.utils.I18nUtil
import com.tencent.devops.store.atom.dao.MarketAtomDao
import com.tencent.devops.store.pojo.atom.enums.AtomStatusEnum
import com.tencent.devops.store.pojo.common.ATOM_POST_VERSION_TEST_FLAG_KEY_PREFIX
import com.tencent.devops.store.pojo.common.STORE_LATEST_TEST_FLAG_KEY_PREFIX
import com.tencent.devops.store.pojo.common.publication.StoreBuildResultRequest
import com.tencent.devops.store.atom.service.AtomReleaseService
import com.tencent.devops.store.atom.service.MarketAtomService
import com.tencent.devops.store.common.service.AbstractStoreHandleBuildResultService
import com.tencent.devops.store.common.utils.VersionUtils
import com.tencent.devops.store.pojo.atom.enums.AtomStatusEnum
import com.tencent.devops.store.pojo.common.ATOM_POST_VERSION_TEST_FLAG_KEY_PREFIX
import com.tencent.devops.store.pojo.common.STORE_LATEST_TEST_FLAG_KEY_PREFIX
import com.tencent.devops.store.pojo.common.publication.StoreBuildResultRequest
import org.jooq.DSLContext
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import com.tencent.devops.store.atom.factory.AtomBusHandleFactory
import com.tencent.devops.store.atom.service.AtomService
import com.tencent.devops.store.atom.service.MarketAtomCommonService
import com.tencent.devops.store.atom.service.MarketAtomEnvService
import com.tencent.devops.store.common.configuration.StoreInnerPipelineConfig
import com.tencent.devops.store.common.dao.ClassifyDao
import com.tencent.devops.store.common.dao.StoreProjectRelDao
import com.tencent.devops.store.common.service.StoreI18nMessageService
Expand All @@ -63,8 +64,8 @@ import com.tencent.devops.store.pojo.common.ATOM_POST_ENTRY_PARAM
import com.tencent.devops.store.pojo.common.ATOM_POST_FLAG
import com.tencent.devops.store.pojo.common.ATOM_POST_NORMAL_PROJECT_FLAG_KEY_PREFIX
import com.tencent.devops.store.pojo.common.ATOM_POST_VERSION_TEST_FLAG_KEY_PREFIX
import com.tencent.devops.store.pojo.common.version.StoreVersion
import com.tencent.devops.store.pojo.common.enums.StoreTypeEnum
import com.tencent.devops.store.pojo.common.version.StoreVersion
import java.time.LocalDateTime
import org.jooq.DSLContext
import org.slf4j.LoggerFactory
Expand All @@ -88,7 +89,8 @@ class MarketAtomEnvServiceImpl @Autowired constructor(
private val atomService: AtomService,
private val marketAtomCommonService: MarketAtomCommonService,
private val storeI18nMessageService: StoreI18nMessageService,
private val redisOperation: RedisOperation
private val redisOperation: RedisOperation,
private val storeInnerPipelineConfig: StoreInnerPipelineConfig
) : MarketAtomEnvService {

private val logger = LoggerFactory.getLogger(MarketAtomEnvServiceImpl::class.java)
Expand Down Expand Up @@ -263,12 +265,15 @@ class MarketAtomEnvServiceImpl @Autowired constructor(
AtomStatusEnum.UNDERCARRIAGING.status.toByte(),
AtomStatusEnum.UNDERCARRIAGED.status.toByte()
)
val buildingFlag =
projectCode == storeInnerPipelineConfig.innerPipelineProject && atomStatus == AtomStatusEnum.BUILDING.status.toByte()
val atomStatusList = getAtomStatusList(
atomStatus = atomStatus,
version = version,
normalStatusList = normalStatusList,
atomCode = atomCode,
projectCode = projectCode
projectCode = projectCode,
queryTestFlag = buildingFlag
)
val atomDefaultFlag = marketAtomCommonService.isPublicAtom(atomCode)
val atomBaseInfoRecord = marketAtomEnvInfoDao.getProjectAtomBaseInfo(
Expand All @@ -277,7 +282,8 @@ class MarketAtomEnvServiceImpl @Autowired constructor(
atomCode = atomCode,
version = version,
atomDefaultFlag = atomDefaultFlag,
atomStatusList = atomStatusList
atomStatusList = atomStatusList,
queryProjectFlag = !buildingFlag
) ?: throw ErrorCodeException(
errorCode = CommonMessageCode.PARAMETER_IS_INVALID,
params = arrayOf("[project($projectCode)-plugin($atomCode)]")
Expand Down Expand Up @@ -414,7 +420,8 @@ class MarketAtomEnvServiceImpl @Autowired constructor(
version: String,
normalStatusList: List<Byte>,
atomCode: String,
projectCode: String
projectCode: String,
queryTestFlag: Boolean
): List<Byte> {
return if (atomStatus != null) {
mutableListOf(atomStatus)
Expand All @@ -428,7 +435,13 @@ class MarketAtomEnvServiceImpl @Autowired constructor(
this.add(AtomStatusEnum.RELEASED.status.toByte())
}
}
val flag = storeProjectRelDao.isTestProjectCode(dslContext, atomCode, StoreTypeEnum.ATOM, projectCode)
val flag = queryTestFlag ||
storeProjectRelDao.isTestProjectCode(
dslContext = dslContext,
storeCode = atomCode,
storeType = StoreTypeEnum.ATOM,
projectCode = projectCode
)
if (flag) {
// 初始化项目或者调试项目有权查处于测试中、审核中的插件
this.addAll(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,10 @@ class StoreInnerPipelineConfig {

@Value("\${store.innerPipeline.user:}")
val innerPipelineUser: String = ""

@Value("\${store.innerPipeline.gray.project:}")
val innerPipelineGrayProject: String = ""

@Value("\${store.innerPipeline.gray.user:}")
val innerPipelineGrayUser: String = ""
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,9 @@ abstract class AbstractStoreCommonDao {
): StoreBaseInfo?

abstract fun getStoreRepoHashIdByCode(dslContext: DSLContext, storeCode: String): String?

abstract fun getStoreCodeById(
dslContext: DSLContext,
storeId: String
): String?
}
Loading