diff --git a/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/config/RepositoryProperties.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/config/RepositoryProperties.kt index e6044f4521..b995fd4181 100644 --- a/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/config/RepositoryProperties.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/config/RepositoryProperties.kt @@ -57,5 +57,9 @@ data class RepositoryProperties( * 当目录节点上的num字段小于该值时,去db中实时count目录大小 * 注意: 此配置的值要比listCountLimit大 */ - var subNodeLimit: Long = 100000000L + var subNodeLimit: Long = 100000000L, + /** + * 是否返回真实项目启用禁用状态 + */ + var returnEnabled: Boolean = true ) diff --git a/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/project/impl/CenterProjectServiceImpl.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/project/impl/CenterProjectServiceImpl.kt index 0fba41993b..b69fdb8d1e 100644 --- a/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/project/impl/CenterProjectServiceImpl.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/project/impl/CenterProjectServiceImpl.kt @@ -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 @@ -45,10 +46,12 @@ class CenterProjectServiceImpl( projectMetricsDao: ProjectMetricsDao, serviceBkiamV3ResourceClient: ServiceBkiamV3ResourceClient, storageCredentialService: StorageCredentialService, -) : ProjectServiceImpl( + repositoryProperties: RepositoryProperties, + ) : ProjectServiceImpl( projectDao, servicePermissionClient, projectMetricsDao, serviceBkiamV3ResourceClient, - storageCredentialService + storageCredentialService, + repositoryProperties ) diff --git a/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/project/impl/EdgeProjectServiceImpl.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/project/impl/EdgeProjectServiceImpl.kt index 105cbfe21d..e467b2e28e 100644 --- a/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/project/impl/EdgeProjectServiceImpl.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/project/impl/EdgeProjectServiceImpl.kt @@ -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 @@ -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 { diff --git a/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/project/impl/ProjectServiceImpl.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/project/impl/ProjectServiceImpl.kt index 38c1ea1cbb..d7a6994332 100644 --- a/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/project/impl/ProjectServiceImpl.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/project/impl/ProjectServiceImpl.kt @@ -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 @@ -84,6 +85,7 @@ class ProjectServiceImpl( private val projectMetricsDao: ProjectMetricsDao, private val serviceBkiamV3ResourceClient: ServiceBkiamV3ResourceClient, private val storageCredentialService: StorageCredentialService, + private val repositoryProperties: RepositoryProperties, ) : ProjectService { @Autowired @@ -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) diff --git a/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/project/impl/RProjectServiceImpl.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/project/impl/RProjectServiceImpl.kt index 8ca465746a..6cad7f1c35 100644 --- a/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/project/impl/RProjectServiceImpl.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/project/impl/RProjectServiceImpl.kt @@ -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 @@ -82,6 +83,7 @@ class RProjectServiceImpl( private val projectMetricsDao: RProjectMetricsDao, private val storageCredentialService: RStorageCredentialService, private val rAuthClient: RAuthClient, + private val repositoryProperties: RepositoryProperties, ) : RProjectService { @Autowired @@ -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)