Skip to content

Commit

Permalink
feat: 添加配置是否返回真实项目启用状态#2783
Browse files Browse the repository at this point in the history
  • Loading branch information
zacYL committed Nov 26, 2024
1 parent 7b68f9a commit 41eac0f
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,9 @@ data class RepositoryProperties(
* 当目录节点上的num字段小于该值时,去db中实时count目录大小
* 注意: 此配置的值要比listCountLimit大
*/
var subNodeLimit: Long = 100000000L
var subNodeLimit: Long = 100000000L,
/**
* 是否返回真实项目启用禁用状态
*/
var returnEnabled: Boolean = true
)
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ package com.tencent.bkrepo.common.metadata.service.project.impl
import com.tencent.bkrepo.auth.api.ServiceBkiamV3ResourceClient
import com.tencent.bkrepo.auth.api.ServicePermissionClient
import com.tencent.bkrepo.common.metadata.condition.SyncCondition
import com.tencent.bkrepo.common.metadata.config.RepositoryProperties
import com.tencent.bkrepo.common.service.cluster.condition.CommitEdgeCenterCondition
import com.tencent.bkrepo.common.metadata.dao.project.ProjectDao
import com.tencent.bkrepo.common.metadata.dao.project.ProjectMetricsDao
Expand All @@ -45,10 +46,12 @@ class CenterProjectServiceImpl(
projectMetricsDao: ProjectMetricsDao,
serviceBkiamV3ResourceClient: ServiceBkiamV3ResourceClient,
storageCredentialService: StorageCredentialService,
) : ProjectServiceImpl(
repositoryProperties: RepositoryProperties,
) : ProjectServiceImpl(
projectDao,
servicePermissionClient,
projectMetricsDao,
serviceBkiamV3ResourceClient,
storageCredentialService
storageCredentialService,
repositoryProperties
)
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import com.tencent.bkrepo.auth.api.ServiceBkiamV3ResourceClient
import com.tencent.bkrepo.auth.api.ServicePermissionClient
import com.tencent.bkrepo.common.artifact.message.ArtifactMessageCode
import com.tencent.bkrepo.common.metadata.condition.SyncCondition
import com.tencent.bkrepo.common.metadata.config.RepositoryProperties
import com.tencent.bkrepo.common.metadata.util.ClusterUtils.reportMetadataToCenter
import com.tencent.bkrepo.common.service.cluster.condition.CommitEdgeEdgeCondition
import com.tencent.bkrepo.common.service.cluster.properties.ClusterProperties
Expand All @@ -54,12 +55,14 @@ class EdgeProjectServiceImpl(
clusterProperties: ClusterProperties,
projectMetricsDao: ProjectMetricsDao,
storageCredentialService: StorageCredentialService,
) : ProjectServiceImpl(
repositoryProperties: RepositoryProperties,
) : ProjectServiceImpl(
projectDao,
servicePermissionClient,
projectMetricsDao,
serviceBkiamV3ResourceClient,
storageCredentialService
storageCredentialService,
repositoryProperties
) {

private val centerProjectClient: ClusterProjectClient by lazy {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import com.tencent.bkrepo.common.api.message.CommonMessageCode
import com.tencent.bkrepo.common.api.pojo.Page
import com.tencent.bkrepo.common.artifact.message.ArtifactMessageCode
import com.tencent.bkrepo.common.metadata.condition.SyncCondition
import com.tencent.bkrepo.common.metadata.config.RepositoryProperties
import com.tencent.bkrepo.common.metadata.dao.project.ProjectDao
import com.tencent.bkrepo.common.metadata.dao.project.ProjectMetricsDao
import com.tencent.bkrepo.common.metadata.listener.ResourcePermissionListener
Expand Down Expand Up @@ -84,6 +85,7 @@ class ProjectServiceImpl(
private val projectMetricsDao: ProjectMetricsDao,
private val serviceBkiamV3ResourceClient: ServiceBkiamV3ResourceClient,
private val storageCredentialService: StorageCredentialService,
private val repositoryProperties: RepositoryProperties,
) : ProjectService {

@Autowired
Expand Down Expand Up @@ -134,6 +136,7 @@ class ProjectServiceImpl(
}

override fun isProjectEnabled(name: String): Boolean {
if (!repositoryProperties.returnEnabled) return true
val projectInfo = projectDao.findByName(name)
?: throw ErrorCodeException(ArtifactMessageCode.PROJECT_NOT_FOUND, name)
return ProjectServiceHelper.isProjectEnabled(projectInfo)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import com.tencent.bkrepo.common.api.pojo.Page
import com.tencent.bkrepo.common.artifact.message.ArtifactMessageCode
import com.tencent.bkrepo.common.metadata.client.RAuthClient
import com.tencent.bkrepo.common.metadata.condition.ReactiveCondition
import com.tencent.bkrepo.common.metadata.config.RepositoryProperties
import com.tencent.bkrepo.common.metadata.dao.project.RProjectDao
import com.tencent.bkrepo.common.metadata.dao.project.RProjectMetricsDao
import com.tencent.bkrepo.common.metadata.listener.RResourcePermissionListener
Expand Down Expand Up @@ -82,6 +83,7 @@ class RProjectServiceImpl(
private val projectMetricsDao: RProjectMetricsDao,
private val storageCredentialService: RStorageCredentialService,
private val rAuthClient: RAuthClient,
private val repositoryProperties: RepositoryProperties,
) : RProjectService {

@Autowired
Expand Down Expand Up @@ -133,6 +135,7 @@ class RProjectServiceImpl(
}

override suspend fun isProjectEnabled(name: String): Boolean {
if (!repositoryProperties.returnEnabled) return true
val projectInfo = projectDao.findByName(name)
?: throw ErrorCodeException(ArtifactMessageCode.PROJECT_NOT_FOUND, name)
return ProjectServiceHelper.isProjectEnabled(projectInfo)
Expand Down

0 comments on commit 41eac0f

Please sign in to comment.