diff --git a/src/backend/analysis-executor/biz-analysis-executor/src/main/kotlin/com/tencent/bkrepo/analysis/executor/dependencycheck/DependencyScanExecutor.kt b/src/backend/analysis-executor/biz-analysis-executor/src/main/kotlin/com/tencent/bkrepo/analysis/executor/dependencycheck/DependencyScanExecutor.kt index d1af0fa0e5..47564cb8ae 100644 --- a/src/backend/analysis-executor/biz-analysis-executor/src/main/kotlin/com/tencent/bkrepo/analysis/executor/dependencycheck/DependencyScanExecutor.kt +++ b/src/backend/analysis-executor/biz-analysis-executor/src/main/kotlin/com/tencent/bkrepo/analysis/executor/dependencycheck/DependencyScanExecutor.kt @@ -36,7 +36,7 @@ import com.tencent.bkrepo.common.analysis.pojo.scanner.dependencycheck.result.De import com.tencent.bkrepo.common.analysis.pojo.scanner.dependencycheck.result.DependencyScanExecutorResult import com.tencent.bkrepo.common.analysis.pojo.scanner.dependencycheck.scanner.DependencyScanner import com.tencent.bkrepo.common.analysis.pojo.scanner.utils.normalizedLevel -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.analysis.executor.ScanExecutor import com.tencent.bkrepo.analysis.executor.pojo.ScanExecutorTask import org.slf4j.LoggerFactory diff --git a/src/backend/archive/biz-archive/src/main/kotlin/com/tencent/bkrepo/archive/utils/ArchiveUtils.kt b/src/backend/archive/biz-archive/src/main/kotlin/com/tencent/bkrepo/archive/utils/ArchiveUtils.kt index 57305e5cb1..f797e7bd8b 100644 --- a/src/backend/archive/biz-archive/src/main/kotlin/com/tencent/bkrepo/archive/utils/ArchiveUtils.kt +++ b/src/backend/archive/biz-archive/src/main/kotlin/com/tencent/bkrepo/archive/utils/ArchiveUtils.kt @@ -4,35 +4,35 @@ import com.google.common.cache.CacheBuilder import com.google.common.cache.CacheLoader import com.google.common.cache.LoadingCache import com.tencent.bkrepo.archive.config.ArchiveProperties -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.credentials.StorageCredentials import com.tencent.bkrepo.repository.api.RepositoryClient -import com.tencent.bkrepo.repository.api.StorageCredentialsClient +import org.slf4j.LoggerFactory +import org.springframework.stereotype.Component import java.util.concurrent.ArrayBlockingQueue +import java.util.concurrent.BlockingQueue import java.util.concurrent.ThreadFactory import java.util.concurrent.ThreadPoolExecutor import java.util.concurrent.TimeUnit -import org.slf4j.LoggerFactory -import org.springframework.stereotype.Component -import java.util.concurrent.BlockingQueue @Component class ArchiveUtils( - storageCredentialsClient: StorageCredentialsClient, + storageCredentialService: StorageCredentialService, storageProperties: StorageProperties, repositoryClient: RepositoryClient, archiveProperties: ArchiveProperties, ) { init { - Companion.storageCredentialsClient = storageCredentialsClient + Companion.storageCredentialService = storageCredentialService Companion.repositoryClient = repositoryClient Companion.archiveProperties = archiveProperties defaultStorageCredentials = storageProperties.defaultStorageCredentials() } companion object { - private lateinit var storageCredentialsClient: StorageCredentialsClient + private lateinit var storageCredentialService: StorageCredentialService private lateinit var defaultStorageCredentials: StorageCredentials private lateinit var repositoryClient: RepositoryClient private lateinit var archiveProperties: ArchiveProperties @@ -44,7 +44,7 @@ class ArchiveUtils( private fun loadStorageCredentials(key: String): StorageCredentials { if (key.isEmpty()) return defaultStorageCredentials - return storageCredentialsClient.findByKey(key).data ?: defaultStorageCredentials + return storageCredentialService.findByKey(key) ?: defaultStorageCredentials } fun getStorageCredentials(key: String?): StorageCredentials { diff --git a/src/backend/archive/biz-archive/src/test/kotlin/com/tencent/bkrepo/archive/core/FileCoreProcessorTest.kt b/src/backend/archive/biz-archive/src/test/kotlin/com/tencent/bkrepo/archive/core/FileCoreProcessorTest.kt index 129969cac8..ab43c744ad 100644 --- a/src/backend/archive/biz-archive/src/test/kotlin/com/tencent/bkrepo/archive/core/FileCoreProcessorTest.kt +++ b/src/backend/archive/biz-archive/src/test/kotlin/com/tencent/bkrepo/archive/core/FileCoreProcessorTest.kt @@ -10,7 +10,6 @@ import com.tencent.bkrepo.common.storage.StorageAutoConfiguration import com.tencent.bkrepo.common.storage.core.StorageService import com.tencent.bkrepo.repository.api.FileReferenceClient import com.tencent.bkrepo.repository.api.RepositoryClient -import com.tencent.bkrepo.repository.api.StorageCredentialsClient import org.junit.jupiter.api.AfterAll import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll @@ -38,9 +37,6 @@ class FileCoreProcessorTest @Autowired constructor( @MockBean lateinit var fileReferenceClient: FileReferenceClient - @MockBean - lateinit var storageCredentialsClient: StorageCredentialsClient - @MockBean lateinit var repositoryClient: RepositoryClient diff --git a/src/backend/archive/biz-archive/src/test/kotlin/com/tencent/bkrepo/archive/core/compress/BDZipManagerTest.kt b/src/backend/archive/biz-archive/src/test/kotlin/com/tencent/bkrepo/archive/core/compress/BDZipManagerTest.kt index 21f4067ce5..f890ce6254 100644 --- a/src/backend/archive/biz-archive/src/test/kotlin/com/tencent/bkrepo/archive/core/compress/BDZipManagerTest.kt +++ b/src/backend/archive/biz-archive/src/test/kotlin/com/tencent/bkrepo/archive/core/compress/BDZipManagerTest.kt @@ -14,7 +14,6 @@ import com.tencent.bkrepo.common.metadata.service.file.FileReferenceService import com.tencent.bkrepo.common.storage.StorageAutoConfiguration import com.tencent.bkrepo.common.storage.core.StorageService import com.tencent.bkrepo.repository.api.RepositoryClient -import com.tencent.bkrepo.repository.api.StorageCredentialsClient import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach @@ -45,9 +44,6 @@ class BDZipManagerTest @Autowired constructor( @MockBean lateinit var fileReferenceService: FileReferenceService - @MockBean - lateinit var storageCredentialsClient: StorageCredentialsClient - @MockBean lateinit var repositoryClient: RepositoryClient diff --git a/src/backend/archive/biz-archive/src/test/kotlin/com/tencent/bkrepo/archive/service/CompressServiceTest.kt b/src/backend/archive/biz-archive/src/test/kotlin/com/tencent/bkrepo/archive/service/CompressServiceTest.kt index aa4ace8af2..99120da73a 100644 --- a/src/backend/archive/biz-archive/src/test/kotlin/com/tencent/bkrepo/archive/service/CompressServiceTest.kt +++ b/src/backend/archive/biz-archive/src/test/kotlin/com/tencent/bkrepo/archive/service/CompressServiceTest.kt @@ -12,7 +12,6 @@ import com.tencent.bkrepo.common.storage.StorageAutoConfiguration import com.tencent.bkrepo.common.storage.core.StorageService import com.tencent.bkrepo.repository.api.FileReferenceClient import com.tencent.bkrepo.repository.api.RepositoryClient -import com.tencent.bkrepo.repository.api.StorageCredentialsClient import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test @@ -38,9 +37,6 @@ class CompressServiceTest @Autowired constructor( @MockBean lateinit var fileReferenceClient: FileReferenceClient - @MockBean - lateinit var storageCredentialsClient: StorageCredentialsClient - @MockBean lateinit var repositoryClient: RepositoryClient diff --git a/src/backend/common/common-artifact/artifact-cache/src/main/kotlin/com/tencent/bkrepo/common/artifact/cache/service/impl/DefaultPreloadPlanExecutor.kt b/src/backend/common/common-artifact/artifact-cache/src/main/kotlin/com/tencent/bkrepo/common/artifact/cache/service/impl/DefaultPreloadPlanExecutor.kt index f01d697bac..066231118f 100644 --- a/src/backend/common/common-artifact/artifact-cache/src/main/kotlin/com/tencent/bkrepo/common/artifact/cache/service/impl/DefaultPreloadPlanExecutor.kt +++ b/src/backend/common/common-artifact/artifact-cache/src/main/kotlin/com/tencent/bkrepo/common/artifact/cache/service/impl/DefaultPreloadPlanExecutor.kt @@ -36,7 +36,8 @@ import com.tencent.bkrepo.common.artifact.cache.service.PreloadListener import com.tencent.bkrepo.common.artifact.cache.service.PreloadPlanExecutor import com.tencent.bkrepo.common.artifact.stream.ArtifactInputStream import com.tencent.bkrepo.common.artifact.stream.Range -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.core.StorageService import com.tencent.bkrepo.common.storage.core.cache.CacheStorageService import com.tencent.bkrepo.common.storage.core.locator.FileLocator @@ -44,7 +45,6 @@ import com.tencent.bkrepo.common.storage.credentials.StorageCredentials import com.tencent.bkrepo.common.storage.monitor.Throughput import com.tencent.bkrepo.common.storage.monitor.measureThroughput import com.tencent.bkrepo.common.storage.util.existReal -import com.tencent.bkrepo.repository.api.StorageCredentialsClient import org.slf4j.LoggerFactory import java.nio.file.Files import java.nio.file.Paths @@ -60,7 +60,7 @@ import java.util.concurrent.TimeUnit class DefaultPreloadPlanExecutor( private val preloadProperties: ArtifactPreloadProperties, private val cacheStorageService: StorageService, - private val storageCredentialsClient: StorageCredentialsClient, + private val storageCredentialService: StorageCredentialService, private val fileLocator: FileLocator, private val storageProperties: StorageProperties, ) : PreloadPlanExecutor { @@ -75,7 +75,7 @@ class DefaultPreloadPlanExecutor( require(cacheStorageService is CacheStorageService) updateExecutor() val credentials = if (plan.credentialsKey != null) { - storageCredentialsClient.findByKey(plan.credentialsKey).data!! + storageCredentialService.findByKey(plan.credentialsKey)!! } else { storageProperties.defaultStorageCredentials() } diff --git a/src/backend/common/common-artifact/artifact-cache/src/test/kotlin/com/tencent/bkrepo/common/artifact/cache/service/impl/ArtifactPreloadBaseServiceTest.kt b/src/backend/common/common-artifact/artifact-cache/src/test/kotlin/com/tencent/bkrepo/common/artifact/cache/service/impl/ArtifactPreloadBaseServiceTest.kt index 6c48770d78..7d46e044c4 100644 --- a/src/backend/common/common-artifact/artifact-cache/src/test/kotlin/com/tencent/bkrepo/common/artifact/cache/service/impl/ArtifactPreloadBaseServiceTest.kt +++ b/src/backend/common/common-artifact/artifact-cache/src/test/kotlin/com/tencent/bkrepo/common/artifact/cache/service/impl/ArtifactPreloadBaseServiceTest.kt @@ -32,15 +32,15 @@ import com.tencent.bkrepo.common.artifact.api.ArtifactFile import com.tencent.bkrepo.common.artifact.api.FileSystemArtifactFile import com.tencent.bkrepo.common.artifact.cache.config.ArtifactPreloadConfiguration import com.tencent.bkrepo.common.artifact.cache.config.ArtifactPreloadProperties +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService import com.tencent.bkrepo.common.storage.StorageAutoConfiguration -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.core.StorageService import com.tencent.bkrepo.common.storage.core.cache.CacheStorageService import com.tencent.bkrepo.common.storage.core.locator.FileLocator import com.tencent.bkrepo.common.storage.credentials.StorageCredentials import com.tencent.bkrepo.repository.api.NodeClient import com.tencent.bkrepo.repository.api.RepositoryClient -import com.tencent.bkrepo.repository.api.StorageCredentialsClient import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.TestInstance import org.springframework.boot.autoconfigure.ImportAutoConfiguration @@ -73,7 +73,7 @@ open class ArtifactPreloadBaseServiceTest( protected lateinit var repositoryClient: RepositoryClient @MockBean - protected lateinit var storageCredentialsClient: StorageCredentialsClient + protected lateinit var storageCredentialService: StorageCredentialService protected fun createTempArtifactFile(size: Long): ArtifactFile { val tempFile = File.createTempFile("preload-", ".tmp") diff --git a/src/backend/common/common-artifact/artifact-cache/src/test/kotlin/com/tencent/bkrepo/common/artifact/cache/service/impl/ArtifactPreloadPlanServiceImplTest.kt b/src/backend/common/common-artifact/artifact-cache/src/test/kotlin/com/tencent/bkrepo/common/artifact/cache/service/impl/ArtifactPreloadPlanServiceImplTest.kt index 9d407befa3..c0be76a819 100644 --- a/src/backend/common/common-artifact/artifact-cache/src/test/kotlin/com/tencent/bkrepo/common/artifact/cache/service/impl/ArtifactPreloadPlanServiceImplTest.kt +++ b/src/backend/common/common-artifact/artifact-cache/src/test/kotlin/com/tencent/bkrepo/common/artifact/cache/service/impl/ArtifactPreloadPlanServiceImplTest.kt @@ -40,7 +40,7 @@ import com.tencent.bkrepo.common.artifact.pojo.RepositoryCategory import com.tencent.bkrepo.common.artifact.pojo.RepositoryType import com.tencent.bkrepo.common.artifact.pojo.configuration.local.LocalConfiguration import com.tencent.bkrepo.common.mongo.dao.util.Pages -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.core.StorageService import com.tencent.bkrepo.common.storage.core.locator.FileLocator import com.tencent.bkrepo.common.storage.util.existReal diff --git a/src/backend/common/common-artifact/artifact-cache/src/test/kotlin/com/tencent/bkrepo/common/artifact/cache/service/impl/DefaultPreloadPlanExecutorTest.kt b/src/backend/common/common-artifact/artifact-cache/src/test/kotlin/com/tencent/bkrepo/common/artifact/cache/service/impl/DefaultPreloadPlanExecutorTest.kt index 242bc6e482..77e757876f 100644 --- a/src/backend/common/common-artifact/artifact-cache/src/test/kotlin/com/tencent/bkrepo/common/artifact/cache/service/impl/DefaultPreloadPlanExecutorTest.kt +++ b/src/backend/common/common-artifact/artifact-cache/src/test/kotlin/com/tencent/bkrepo/common/artifact/cache/service/impl/DefaultPreloadPlanExecutorTest.kt @@ -28,14 +28,13 @@ package com.tencent.bkrepo.common.artifact.cache.service.impl import com.tencent.bkrepo.common.api.constant.StringPool -import com.tencent.bkrepo.common.api.pojo.Response import com.tencent.bkrepo.common.artifact.api.ArtifactFile import com.tencent.bkrepo.common.artifact.cache.UT_PROJECT_ID import com.tencent.bkrepo.common.artifact.cache.UT_REPO_NAME import com.tencent.bkrepo.common.artifact.cache.UT_SHA256 import com.tencent.bkrepo.common.artifact.cache.config.ArtifactPreloadProperties import com.tencent.bkrepo.common.artifact.cache.pojo.ArtifactPreloadPlan -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.core.StorageService import com.tencent.bkrepo.common.storage.core.cache.CacheStorageService import com.tencent.bkrepo.common.storage.core.locator.FileLocator @@ -172,8 +171,8 @@ class DefaultPreloadPlanExecutorTest @Autowired constructor( private fun resetMock() { val defaultCredentials = storageProperties.defaultStorageCredentials() as FileSystemCredentials - whenever(storageCredentialsClient.findByKey(anyString())).thenReturn( - Response(0, null, defaultCredentials.copy(key = "test")) + whenever(storageCredentialService.findByKey(anyString())).thenReturn( + defaultCredentials.copy(key = "test") ) } } diff --git a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/cns/impl/CnsServiceImpl.kt b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/cns/impl/CnsServiceImpl.kt index 1e115b2e62..1b93fdbe18 100644 --- a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/cns/impl/CnsServiceImpl.kt +++ b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/cns/impl/CnsServiceImpl.kt @@ -34,13 +34,13 @@ import com.tencent.bkrepo.common.api.pojo.Response import com.tencent.bkrepo.common.artifact.cns.CnsProperties import com.tencent.bkrepo.common.artifact.cns.CnsService import com.tencent.bkrepo.common.artifact.pojo.RepositoryType +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService import com.tencent.bkrepo.common.security.constant.MS_AUTH_HEADER_SECURITY_TOKEN import com.tencent.bkrepo.common.security.service.ServiceAuthManager import com.tencent.bkrepo.common.service.otel.util.AsyncUtils.trace import com.tencent.bkrepo.common.service.util.HttpContextHolder -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.core.StorageService -import com.tencent.bkrepo.repository.api.StorageCredentialsClient import com.tencent.bkrepo.repository.constant.SYSTEM_USER import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Value @@ -62,7 +62,7 @@ import java.util.concurrent.TimeUnit class CnsServiceImpl( private val discoveryClient: DiscoveryClient, private val storageService: StorageService, - private val storageCredentialsClient: StorageCredentialsClient, + private val storageCredentialService: StorageCredentialService, private val storageProperties: StorageProperties, private val cnsProperties: CnsProperties, private val serviceAuthManager: ServiceAuthManager @@ -80,7 +80,7 @@ class CnsServiceImpl( private val restTemplate = RestTemplate() override fun exist(key: String?, sha256: String): Boolean { - val storageCredentials = storageCredentialsClient.findByKey(key).data + val storageCredentials = storageCredentialService.findByKey(key) ?: storageProperties.defaultStorageCredentials() return storageService.exist(sha256, storageCredentials) } diff --git a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/manager/NodeResourceFactoryImpl.kt b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/manager/NodeResourceFactoryImpl.kt index 22fd07c76c..fc228a378b 100644 --- a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/manager/NodeResourceFactoryImpl.kt +++ b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/manager/NodeResourceFactoryImpl.kt @@ -37,6 +37,7 @@ import com.tencent.bkrepo.common.artifact.manager.resource.NodeResource import com.tencent.bkrepo.common.artifact.manager.resource.RemoteNodeResource import com.tencent.bkrepo.common.artifact.stream.Range import com.tencent.bkrepo.common.metadata.service.blocknode.BlockNodeService +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService import com.tencent.bkrepo.common.service.cluster.ClusterInfo import com.tencent.bkrepo.common.service.cluster.properties.ClusterProperties import com.tencent.bkrepo.common.storage.core.StorageService @@ -44,13 +45,12 @@ import com.tencent.bkrepo.common.storage.credentials.StorageCredentials import com.tencent.bkrepo.fs.server.constant.FS_ATTR_KEY import com.tencent.bkrepo.replication.api.ClusterNodeClient import com.tencent.bkrepo.replication.exception.ReplicationMessageCode -import com.tencent.bkrepo.repository.api.StorageCredentialsClient import com.tencent.bkrepo.repository.pojo.node.NodeInfo class NodeResourceFactoryImpl( private val clusterProperties: ClusterProperties, private val storageService: StorageService, - private val storageCredentialsClient: StorageCredentialsClient, + private val storageCredentialService: StorageCredentialService, private val blockNodeService: BlockNodeService, private val clusterNodeClient: ClusterNodeClient, private val archiveClient: ArchiveClient, @@ -88,7 +88,7 @@ class NodeResourceFactoryImpl( range, storageCredentials, storageService, - storageCredentialsClient, + storageCredentialService, archiveClient, ) } diff --git a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/manager/resource/LocalNodeResource.kt b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/manager/resource/LocalNodeResource.kt index fed0cdd898..9ec4c5d55b 100644 --- a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/manager/resource/LocalNodeResource.kt +++ b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/manager/resource/LocalNodeResource.kt @@ -35,10 +35,10 @@ import com.tencent.bkrepo.common.api.message.CommonMessageCode import com.tencent.bkrepo.common.artifact.repository.context.ArtifactContextHolder import com.tencent.bkrepo.common.artifact.stream.ArtifactInputStream import com.tencent.bkrepo.common.artifact.stream.Range +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService import com.tencent.bkrepo.common.security.util.SecurityUtils import com.tencent.bkrepo.common.storage.core.StorageService import com.tencent.bkrepo.common.storage.credentials.StorageCredentials -import com.tencent.bkrepo.repository.api.StorageCredentialsClient import com.tencent.bkrepo.repository.pojo.node.NodeInfo import com.tencent.bkrepo.repository.pojo.repo.RepositoryDetail import org.slf4j.LoggerFactory @@ -51,7 +51,7 @@ class LocalNodeResource( private val range: Range, private val storageCredentials: StorageCredentials?, private val storageService: StorageService, - private val storageCredentialsClient: StorageCredentialsClient, + private val storageCredentialService: StorageCredentialService, private val archiveClient: ArchiveClient, ) : AbstractNodeResource() { @@ -98,7 +98,7 @@ class LocalNodeResource( node.copyFromCredentialsKey?.let { val digest = node.sha256!! logger.info("load data [$digest] from copy credentialsKey [$it]") - val fromCredentialsKey = storageCredentialsClient.findByKey(it).data + val fromCredentialsKey = storageCredentialService.findByKey(it) return storageService.load(digest, range, fromCredentialsKey) } return null @@ -150,7 +150,7 @@ class LocalNodeResource( * */ private fun findStorageCredentialsByKey(credentialsKey: String?): StorageCredentials? { credentialsKey ?: return null - return storageCredentialsClient.findByKey(credentialsKey).data + return storageCredentialService.findByKey(credentialsKey) } private fun restore(node: NodeInfo, storageCredentials: StorageCredentials?) { diff --git a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/metrics/ArtifactCacheMetrics.kt b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/metrics/ArtifactCacheMetrics.kt index 9fe26b17d9..ea28a3b8d3 100644 --- a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/metrics/ArtifactCacheMetrics.kt +++ b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/metrics/ArtifactCacheMetrics.kt @@ -33,7 +33,7 @@ import com.tencent.bkrepo.common.artifact.repository.context.ArtifactContextHold import com.tencent.bkrepo.common.artifact.resolve.response.ArtifactResource import com.tencent.bkrepo.common.artifact.stream.ArtifactInputStream.Companion.METADATA_KEY_CACHE_ENABLED import com.tencent.bkrepo.common.artifact.stream.FileArtifactInputStream -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.credentials.StorageCredentials import com.tencent.bkrepo.repository.pojo.repo.RepositoryDetail import io.micrometer.core.instrument.Counter diff --git a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/metrics/ArtifactMetricsConfiguration.kt b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/metrics/ArtifactMetricsConfiguration.kt index 64e61267a8..aaecb0676c 100644 --- a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/metrics/ArtifactMetricsConfiguration.kt +++ b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/metrics/ArtifactMetricsConfiguration.kt @@ -34,7 +34,7 @@ package com.tencent.bkrepo.common.artifact.metrics import com.tencent.bkrepo.common.artifact.metrics.export.ArtifactMetricsExporter import com.tencent.bkrepo.common.metrics.push.custom.CustomMetricsExporter import com.tencent.bkrepo.common.service.actuator.CommonTagProvider -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import org.springframework.beans.factory.ObjectProvider import org.springframework.boot.actuate.autoconfigure.metrics.export.influx.InfluxProperties import org.springframework.boot.autoconfigure.condition.ConditionalOnBean diff --git a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/metrics/DefaultArtifactTagProvider.kt b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/metrics/DefaultArtifactTagProvider.kt index 3b2734fccb..d8039e56ca 100644 --- a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/metrics/DefaultArtifactTagProvider.kt +++ b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/metrics/DefaultArtifactTagProvider.kt @@ -34,7 +34,7 @@ import com.tencent.bkrepo.common.artifact.repository.context.ArtifactContextHold import com.tencent.bkrepo.common.artifact.resolve.file.ArtifactDataReceiver import com.tencent.bkrepo.common.artifact.stream.ArtifactInputStream import com.tencent.bkrepo.common.artifact.stream.FileArtifactInputStream -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.credentials.StorageCredentials import com.tencent.bkrepo.repository.pojo.repo.RepositoryDetail import io.micrometer.core.instrument.Tag diff --git a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/repository/context/ArtifactContextHolder.kt b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/repository/context/ArtifactContextHolder.kt index e8f52d1c7c..414b71f9a5 100644 --- a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/repository/context/ArtifactContextHolder.kt +++ b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/repository/context/ArtifactContextHolder.kt @@ -50,7 +50,7 @@ import com.tencent.bkrepo.common.artifact.repository.core.ArtifactRepository import com.tencent.bkrepo.common.artifact.repository.proxy.ProxyRepository import com.tencent.bkrepo.common.security.http.core.HttpAuthSecurity import com.tencent.bkrepo.common.service.util.HttpContextHolder -import com.tencent.bkrepo.common.storage.core.config.RateLimitProperties +import com.tencent.bkrepo.common.storage.config.RateLimitProperties import com.tencent.bkrepo.repository.pojo.node.NodeDetail import com.tencent.bkrepo.repository.pojo.repo.RepositoryDetail import org.springframework.beans.factory.ObjectProvider diff --git a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/repository/redirect/CosRedirectService.kt b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/repository/redirect/CosRedirectService.kt index b20135b677..0bfdd3dd15 100644 --- a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/repository/redirect/CosRedirectService.kt +++ b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/repository/redirect/CosRedirectService.kt @@ -40,7 +40,7 @@ import com.tencent.bkrepo.common.artifact.util.http.HttpRangeUtils import com.tencent.bkrepo.common.security.manager.PermissionManager import com.tencent.bkrepo.common.security.util.SecurityUtils import com.tencent.bkrepo.common.service.util.HttpContextHolder -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.core.StorageService import com.tencent.bkrepo.common.storage.credentials.InnerCosCredentials import com.tencent.bkrepo.common.storage.credentials.StorageCredentials diff --git a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/repository/redirect/LinkNodeRedirectService.kt b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/repository/redirect/LinkNodeRedirectService.kt index 31bd563afa..b96d7a479e 100644 --- a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/repository/redirect/LinkNodeRedirectService.kt +++ b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/repository/redirect/LinkNodeRedirectService.kt @@ -38,7 +38,7 @@ import com.tencent.bkrepo.common.artifact.constant.METADATA_KEY_LINK_REPO import com.tencent.bkrepo.common.artifact.repository.context.ArtifactContextHolder import com.tencent.bkrepo.common.artifact.repository.context.ArtifactContextHolder.RepositoryId import com.tencent.bkrepo.common.artifact.repository.context.ArtifactDownloadContext -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.repository.pojo.node.NodeDetail import org.springframework.core.annotation.Order import org.springframework.stereotype.Service diff --git a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/resolve/ArtifactResolverConfiguration.kt b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/resolve/ArtifactResolverConfiguration.kt index 4ef5b93371..22d3dbfb65 100644 --- a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/resolve/ArtifactResolverConfiguration.kt +++ b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/resolve/ArtifactResolverConfiguration.kt @@ -38,7 +38,7 @@ import com.tencent.bkrepo.common.artifact.resolve.path.DefaultArtifactInfoResolv import com.tencent.bkrepo.common.artifact.resolve.path.ResolverMap import com.tencent.bkrepo.common.artifact.resolve.response.ArtifactResourceWriter import com.tencent.bkrepo.common.artifact.resolve.response.DefaultArtifactResourceWriter -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration diff --git a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/resolve/file/ArtifactDataReceiver.kt b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/resolve/file/ArtifactDataReceiver.kt index 669faef36f..1fa20ddcc6 100644 --- a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/resolve/file/ArtifactDataReceiver.kt +++ b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/resolve/file/ArtifactDataReceiver.kt @@ -35,9 +35,9 @@ import com.tencent.bkrepo.common.artifact.metrics.TrafficHandler import com.tencent.bkrepo.common.artifact.stream.DigestCalculateListener import com.tencent.bkrepo.common.artifact.stream.rateLimit import com.tencent.bkrepo.common.artifact.util.http.IOExceptionUtils -import com.tencent.bkrepo.common.storage.core.config.ReceiveProperties +import com.tencent.bkrepo.common.storage.config.ReceiveProperties import com.tencent.bkrepo.common.storage.core.locator.HashFileLocator -import com.tencent.bkrepo.common.storage.monitor.MonitorProperties +import com.tencent.bkrepo.common.storage.config.MonitorProperties import com.tencent.bkrepo.common.storage.monitor.StorageHealthMonitor import com.tencent.bkrepo.common.storage.monitor.Throughput import com.tencent.bkrepo.common.storage.util.createFile diff --git a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/resolve/file/ArtifactFileFactory.kt b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/resolve/file/ArtifactFileFactory.kt index 741aed1f96..d99b4b93c5 100644 --- a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/resolve/file/ArtifactFileFactory.kt +++ b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/resolve/file/ArtifactFileFactory.kt @@ -36,7 +36,7 @@ import com.tencent.bkrepo.common.artifact.resolve.file.chunk.RandomAccessArtifac import com.tencent.bkrepo.common.artifact.resolve.file.multipart.MultipartArtifactFile import com.tencent.bkrepo.common.artifact.resolve.file.stream.StreamArtifactFile import com.tencent.bkrepo.common.bksync.BlockChannel -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.credentials.StorageCredentials import com.tencent.bkrepo.common.storage.monitor.StorageHealthMonitor import com.tencent.bkrepo.common.storage.monitor.StorageHealthMonitorHelper diff --git a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/resolve/file/UploadConfigElement.kt b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/resolve/file/UploadConfigElement.kt index 8da20e7a86..59f91a016a 100644 --- a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/resolve/file/UploadConfigElement.kt +++ b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/resolve/file/UploadConfigElement.kt @@ -31,7 +31,7 @@ package com.tencent.bkrepo.common.artifact.resolve.file -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import org.springframework.util.unit.DataSize import javax.servlet.MultipartConfigElement diff --git a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/resolve/file/chunk/ChunkedArtifactFile.kt b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/resolve/file/chunk/ChunkedArtifactFile.kt index b51037c9df..748fb66712 100644 --- a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/resolve/file/chunk/ChunkedArtifactFile.kt +++ b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/resolve/file/chunk/ChunkedArtifactFile.kt @@ -32,7 +32,7 @@ import com.tencent.bkrepo.common.artifact.event.ArtifactReceivedEvent import com.tencent.bkrepo.common.artifact.hash.sha1 import com.tencent.bkrepo.common.artifact.resolve.file.ArtifactDataReceiver import com.tencent.bkrepo.common.service.util.SpringContextUtils -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.credentials.StorageCredentials import com.tencent.bkrepo.common.storage.monitor.StorageHealthMonitor import com.tencent.bkrepo.common.storage.monitor.Throughput diff --git a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/resolve/file/chunk/RandomAccessArtifactFile.kt b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/resolve/file/chunk/RandomAccessArtifactFile.kt index 34acca9765..cbea40ee8b 100644 --- a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/resolve/file/chunk/RandomAccessArtifactFile.kt +++ b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/resolve/file/chunk/RandomAccessArtifactFile.kt @@ -5,7 +5,7 @@ import com.tencent.bkrepo.common.artifact.event.ArtifactReceivedEvent import com.tencent.bkrepo.common.artifact.hash.sha1 import com.tencent.bkrepo.common.artifact.resolve.file.ArtifactDataReceiver import com.tencent.bkrepo.common.service.util.SpringContextUtils -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.credentials.StorageCredentials import com.tencent.bkrepo.common.storage.monitor.StorageHealthMonitor import com.tencent.bkrepo.common.storage.monitor.Throughput diff --git a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/resolve/file/multipart/MultipartArtifactFile.kt b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/resolve/file/multipart/MultipartArtifactFile.kt index f0593b15eb..657a4db3ce 100644 --- a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/resolve/file/multipart/MultipartArtifactFile.kt +++ b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/resolve/file/multipart/MultipartArtifactFile.kt @@ -28,7 +28,7 @@ package com.tencent.bkrepo.common.artifact.resolve.file.multipart import com.tencent.bkrepo.common.artifact.resolve.file.stream.StreamArtifactFile -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.credentials.StorageCredentials import com.tencent.bkrepo.common.storage.monitor.StorageHealthMonitor import org.springframework.web.multipart.MultipartFile diff --git a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/resolve/file/stream/StreamArtifactFile.kt b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/resolve/file/stream/StreamArtifactFile.kt index 1d353e6176..f08f0c7445 100644 --- a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/resolve/file/stream/StreamArtifactFile.kt +++ b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/resolve/file/stream/StreamArtifactFile.kt @@ -32,7 +32,7 @@ import com.tencent.bkrepo.common.artifact.event.ArtifactReceivedEvent import com.tencent.bkrepo.common.artifact.hash.sha1 import com.tencent.bkrepo.common.artifact.resolve.file.ArtifactDataReceiver import com.tencent.bkrepo.common.service.util.SpringContextUtils -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.credentials.StorageCredentials import com.tencent.bkrepo.common.storage.monitor.StorageHealthMonitor import com.tencent.bkrepo.common.storage.util.toPath diff --git a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/resolve/response/AbstractArtifactResourceHandler.kt b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/resolve/response/AbstractArtifactResourceHandler.kt index 6b9b5c0ca1..403c4d16c4 100644 --- a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/resolve/response/AbstractArtifactResourceHandler.kt +++ b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/resolve/response/AbstractArtifactResourceHandler.kt @@ -35,7 +35,7 @@ import com.tencent.bkrepo.common.artifact.metrics.RecordAbleInputStream import com.tencent.bkrepo.common.artifact.repository.context.ArtifactContextHolder import com.tencent.bkrepo.common.artifact.stream.rateLimit import com.tencent.bkrepo.common.artifact.util.http.IOExceptionUtils -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.monitor.Throughput import com.tencent.bkrepo.common.storage.monitor.measureThroughput import org.slf4j.LoggerFactory diff --git a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/resolve/response/DefaultArtifactResourceWriter.kt b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/resolve/response/DefaultArtifactResourceWriter.kt index dcf6fbbadd..12e9fefee9 100644 --- a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/resolve/response/DefaultArtifactResourceWriter.kt +++ b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/resolve/response/DefaultArtifactResourceWriter.kt @@ -45,7 +45,7 @@ import com.tencent.bkrepo.common.artifact.util.http.HttpHeaderUtils.encodeDispos import com.tencent.bkrepo.common.artifact.util.http.IOExceptionUtils.isClientBroken import com.tencent.bkrepo.common.service.otel.util.TraceHeaderUtils import com.tencent.bkrepo.common.service.util.HttpContextHolder -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.monitor.Throughput import com.tencent.bkrepo.common.storage.monitor.measureThroughput import com.tencent.bkrepo.repository.pojo.node.NodeDetail diff --git a/src/backend/common/common-artifact/artifact-service/src/test/kotlin/com/tencent/bkrepo/common/artifact/resolve/file/ArtifactDataReceiverTest.kt b/src/backend/common/common-artifact/artifact-service/src/test/kotlin/com/tencent/bkrepo/common/artifact/resolve/file/ArtifactDataReceiverTest.kt index 77d2bdbc7e..884739d639 100644 --- a/src/backend/common/common-artifact/artifact-service/src/test/kotlin/com/tencent/bkrepo/common/artifact/resolve/file/ArtifactDataReceiverTest.kt +++ b/src/backend/common/common-artifact/artifact-service/src/test/kotlin/com/tencent/bkrepo/common/artifact/resolve/file/ArtifactDataReceiverTest.kt @@ -31,8 +31,8 @@ import com.tencent.bkrepo.common.api.constant.StringPool.randomString import com.tencent.bkrepo.common.artifact.metrics.ARTIFACT_UPLOADING_TIME import com.tencent.bkrepo.common.artifact.metrics.ArtifactMetrics import com.tencent.bkrepo.common.artifact.stream.RateLimitInputStream -import com.tencent.bkrepo.common.storage.core.config.ReceiveProperties -import com.tencent.bkrepo.common.storage.monitor.MonitorProperties +import com.tencent.bkrepo.common.storage.config.ReceiveProperties +import com.tencent.bkrepo.common.storage.config.MonitorProperties import com.tencent.bkrepo.common.storage.util.toPath import io.micrometer.core.instrument.Timer import io.micrometer.core.instrument.simple.SimpleMeterRegistry diff --git a/src/backend/common/common-artifact/artifact-service/src/test/kotlin/com/tencent/bkrepo/common/artifact/resolve/file/chunk/ChunkArtifactFileTest.kt b/src/backend/common/common-artifact/artifact-service/src/test/kotlin/com/tencent/bkrepo/common/artifact/resolve/file/chunk/ChunkArtifactFileTest.kt index 9d53c34265..7b86f307ea 100644 --- a/src/backend/common/common-artifact/artifact-service/src/test/kotlin/com/tencent/bkrepo/common/artifact/resolve/file/chunk/ChunkArtifactFileTest.kt +++ b/src/backend/common/common-artifact/artifact-service/src/test/kotlin/com/tencent/bkrepo/common/artifact/resolve/file/chunk/ChunkArtifactFileTest.kt @@ -30,8 +30,8 @@ package com.tencent.bkrepo.common.artifact.resolve.file.chunk import com.tencent.bkrepo.common.api.constant.StringPool import com.tencent.bkrepo.common.service.util.SpringContextUtils import com.tencent.bkrepo.common.storage.config.UploadProperties -import com.tencent.bkrepo.common.storage.core.StorageProperties -import com.tencent.bkrepo.common.storage.core.config.ReceiveProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties +import com.tencent.bkrepo.common.storage.config.ReceiveProperties import com.tencent.bkrepo.common.storage.credentials.FileSystemCredentials import com.tencent.bkrepo.common.storage.monitor.StorageHealthMonitor import io.mockk.every diff --git a/src/backend/common/common-artifact/artifact-service/src/test/kotlin/com/tencent/bkrepo/common/artifact/resolve/file/stream/StreamArtifactFileTest.kt b/src/backend/common/common-artifact/artifact-service/src/test/kotlin/com/tencent/bkrepo/common/artifact/resolve/file/stream/StreamArtifactFileTest.kt index 929ebfdae5..91a179d9f6 100644 --- a/src/backend/common/common-artifact/artifact-service/src/test/kotlin/com/tencent/bkrepo/common/artifact/resolve/file/stream/StreamArtifactFileTest.kt +++ b/src/backend/common/common-artifact/artifact-service/src/test/kotlin/com/tencent/bkrepo/common/artifact/resolve/file/stream/StreamArtifactFileTest.kt @@ -30,10 +30,10 @@ package com.tencent.bkrepo.common.artifact.resolve.file.stream import com.tencent.bkrepo.common.api.constant.StringPool.randomString import com.tencent.bkrepo.common.service.util.SpringContextUtils import com.tencent.bkrepo.common.storage.config.UploadProperties -import com.tencent.bkrepo.common.storage.core.StorageProperties -import com.tencent.bkrepo.common.storage.core.config.ReceiveProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties +import com.tencent.bkrepo.common.storage.config.ReceiveProperties import com.tencent.bkrepo.common.storage.credentials.FileSystemCredentials -import com.tencent.bkrepo.common.storage.monitor.MonitorProperties +import com.tencent.bkrepo.common.storage.config.MonitorProperties import com.tencent.bkrepo.common.storage.monitor.StorageHealthMonitor import com.tencent.bkrepo.common.storage.util.toPath import io.mockk.every diff --git a/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/dao/repo/RRepositoryDao.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/dao/repo/RRepositoryDao.kt new file mode 100644 index 0000000000..e068fdf2aa --- /dev/null +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/dao/repo/RRepositoryDao.kt @@ -0,0 +1,86 @@ +/* + * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. + * + * Copyright (C) 2020 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.bkrepo.common.metadata.dao.repo + +import com.tencent.bkrepo.common.metadata.condition.ReactiveCondition +import com.tencent.bkrepo.common.metadata.model.TRepository +import com.tencent.bkrepo.common.metadata.util.RepoQueryHelper.buildSingleQuery +import com.tencent.bkrepo.common.mongo.reactive.dao.SimpleMongoReactiveDao +import org.springframework.context.annotation.Conditional +import org.springframework.data.mongodb.core.query.Query +import org.springframework.data.mongodb.core.query.Update +import org.springframework.data.mongodb.core.query.isEqualTo +import org.springframework.stereotype.Repository + +/** + * 仓库数据访问层 + */ +@Repository +@Conditional(ReactiveCondition::class) +class RRepositoryDao : SimpleMongoReactiveDao() { + + /** + * 根据项目[projectId]、名称[name]和类型[type]查询仓库 + */ + suspend fun findByNameAndType(projectId: String, name: String, type: String? = null): TRepository? { + val query = buildSingleQuery(projectId, name, type) + return this.findOne(query, TRepository::class.java) + } + + /** + * 根据[id]删除仓库 + */ + suspend fun deleteById(id: String?) { + if (id.isNullOrBlank()) { + return + } + val query = Query(TRepository::id.isEqualTo(id)) + this.remove(query) + } + + /** + * 查询是否有使用指定存储凭证的仓库 + */ + suspend fun existsByCredentialsKey(credentialsKey: String): Boolean { + val query = Query(TRepository::credentialsKey.isEqualTo(credentialsKey)) + .addCriteria(TRepository::deleted.isEqualTo(null)) + return this.exists(query) + } + + + + suspend fun unsetOldCredentialsKey(projectId: String, repoName: String, repoType: String? = null) { + val query = buildSingleQuery(projectId, repoName, repoType) + val update = Update().unset(TRepository::oldCredentialsKey.name) + updateFirst(query, update) + } +} diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/dao/repository/StorageCredentialsRepository.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/dao/repo/RStorageCredentialsDao.kt similarity index 61% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/dao/repository/StorageCredentialsRepository.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/dao/repo/RStorageCredentialsDao.kt index 177b34cf32..79b5c365f4 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/dao/repository/StorageCredentialsRepository.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/dao/repo/RStorageCredentialsDao.kt @@ -29,11 +29,32 @@ * SOFTWARE. */ -package com.tencent.bkrepo.repository.dao.repository +package com.tencent.bkrepo.common.metadata.dao.repo -import com.tencent.bkrepo.repository.model.TStorageCredentials -import org.springframework.data.mongodb.repository.MongoRepository +import com.tencent.bkrepo.common.metadata.condition.ReactiveCondition +import com.tencent.bkrepo.common.metadata.model.TStorageCredentials +import com.tencent.bkrepo.common.mongo.reactive.dao.SimpleMongoReactiveDao +import org.springframework.context.annotation.Conditional +import org.springframework.data.mongodb.core.query.Criteria +import org.springframework.data.mongodb.core.query.Query +import org.springframework.data.mongodb.core.query.isEqualTo import org.springframework.stereotype.Repository @Repository -interface StorageCredentialsRepository : MongoRepository +@Conditional(ReactiveCondition::class) +class RStorageCredentialsDao : SimpleMongoReactiveDao() { + + suspend fun count(): Long { + return this.count(Query()) + } + + suspend fun deleteById(id: String) { + val query = Query(Criteria.where(ID).isEqualTo(id)) + this.remove(query) + } + + suspend fun existsById(id: String): Boolean { + val query = Query(Criteria.where(ID).isEqualTo(id)) + return this.exists(query) + } +} diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/dao/RepositoryDao.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/dao/repo/RepositoryDao.kt similarity index 78% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/dao/RepositoryDao.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/dao/repo/RepositoryDao.kt index f32bcada40..0df74b2bda 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/dao/RepositoryDao.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/dao/repo/RepositoryDao.kt @@ -29,22 +29,23 @@ * SOFTWARE. */ -package com.tencent.bkrepo.repository.dao +package com.tencent.bkrepo.common.metadata.dao.repo -import com.tencent.bkrepo.common.artifact.pojo.RepositoryType +import com.tencent.bkrepo.common.metadata.condition.SyncCondition +import com.tencent.bkrepo.common.metadata.model.TRepository +import com.tencent.bkrepo.common.metadata.util.RepoQueryHelper.buildSingleQuery import com.tencent.bkrepo.common.mongo.dao.simple.SimpleMongoDao -import com.tencent.bkrepo.repository.model.TRepository +import org.springframework.context.annotation.Conditional import org.springframework.data.mongodb.core.query.Query import org.springframework.data.mongodb.core.query.Update -import org.springframework.data.mongodb.core.query.and import org.springframework.data.mongodb.core.query.isEqualTo -import org.springframework.data.mongodb.core.query.where import org.springframework.stereotype.Repository /** * 仓库数据访问层 */ @Repository +@Conditional(SyncCondition::class) class RepositoryDao : SimpleMongoDao() { /** @@ -75,18 +76,6 @@ class RepositoryDao : SimpleMongoDao() { return this.exists(query) } - /** - * 构造单个仓库查询条件 - */ - fun buildSingleQuery(projectId: String, repoName: String, repoType: String? = null): Query { - val criteria = where(TRepository::projectId).isEqualTo(projectId) - .and(TRepository::name).isEqualTo(repoName) - .and(TRepository::deleted).isEqualTo(null) - if (repoType != null && repoType.toUpperCase() != RepositoryType.NONE.name) { - criteria.and(TRepository::type).isEqualTo(repoType.toUpperCase()) - } - return Query(criteria) - } fun unsetOldCredentialsKey(projectId: String, repoName: String, repoType: String? = null) { val query = buildSingleQuery(projectId, repoName, repoType) diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/dao/repository/RepoRepository.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/dao/repo/StorageCredentialsDao.kt similarity index 62% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/dao/repository/RepoRepository.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/dao/repo/StorageCredentialsDao.kt index 6bcdaa794b..a6c7d68065 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/dao/repository/RepoRepository.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/dao/repo/StorageCredentialsDao.kt @@ -29,14 +29,32 @@ * SOFTWARE. */ -package com.tencent.bkrepo.repository.dao.repository +package com.tencent.bkrepo.common.metadata.dao.repo -import com.tencent.bkrepo.repository.model.TRepository -import org.springframework.data.mongodb.repository.MongoRepository +import com.tencent.bkrepo.common.metadata.condition.SyncCondition +import com.tencent.bkrepo.common.metadata.model.TStorageCredentials +import com.tencent.bkrepo.common.mongo.dao.simple.SimpleMongoDao +import org.springframework.context.annotation.Conditional +import org.springframework.data.mongodb.core.query.Criteria +import org.springframework.data.mongodb.core.query.Query +import org.springframework.data.mongodb.core.query.isEqualTo import org.springframework.stereotype.Repository -/** - * 仓库mongo repository - */ @Repository -interface RepoRepository : MongoRepository +@Conditional(SyncCondition::class) +class StorageCredentialsDao : SimpleMongoDao() { + + fun count(): Long { + return this.count(Query()) + } + + fun deleteById(id: String) { + val query = Query(Criteria.where(ID).isEqualTo(id)) + this.remove(query) + } + + fun existsById(id: String): Boolean { + val query = Query(Criteria.where(ID).isEqualTo(id)) + return this.exists(query) + } +} diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/model/TRepository.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/model/TRepository.kt similarity index 98% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/model/TRepository.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/model/TRepository.kt index 26ed1849d5..d62e555a6e 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/model/TRepository.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/model/TRepository.kt @@ -29,7 +29,7 @@ * SOFTWARE. */ -package com.tencent.bkrepo.repository.model +package com.tencent.bkrepo.common.metadata.model import com.tencent.bkrepo.common.artifact.pojo.RepositoryCategory import com.tencent.bkrepo.common.artifact.pojo.RepositoryType diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/model/TStorageCredentials.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/model/TStorageCredentials.kt similarity index 97% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/model/TStorageCredentials.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/model/TStorageCredentials.kt index 670394f645..c411c6c086 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/model/TStorageCredentials.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/model/TStorageCredentials.kt @@ -29,7 +29,7 @@ * SOFTWARE. */ -package com.tencent.bkrepo.repository.model +package com.tencent.bkrepo.common.metadata.model import org.springframework.data.mongodb.core.mapping.Document import java.time.LocalDateTime diff --git a/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/file/impl/FileReferenceServiceImpl.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/file/impl/FileReferenceServiceImpl.kt index a84d42d6c9..a479c5ad6a 100644 --- a/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/file/impl/FileReferenceServiceImpl.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/file/impl/FileReferenceServiceImpl.kt @@ -36,9 +36,9 @@ import com.tencent.bkrepo.common.artifact.message.ArtifactMessageCode import com.tencent.bkrepo.common.metadata.condition.SyncCondition import com.tencent.bkrepo.common.metadata.dao.file.FileReferenceDao import com.tencent.bkrepo.common.metadata.model.TFileReference +import com.tencent.bkrepo.common.metadata.pojo.file.FileReference import com.tencent.bkrepo.common.metadata.service.file.FileReferenceService import com.tencent.bkrepo.common.metadata.util.FileReferenceQueryHelper.buildQuery -import com.tencent.bkrepo.common.metadata.pojo.file.FileReference import org.slf4j.LoggerFactory import org.springframework.context.annotation.Conditional import org.springframework.dao.DuplicateKeyException diff --git a/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/repo/RStorageCredentialService.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/repo/RStorageCredentialService.kt new file mode 100644 index 0000000000..8b7d605c32 --- /dev/null +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/repo/RStorageCredentialService.kt @@ -0,0 +1,79 @@ +/* + * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. + * + * Copyright (C) 2020 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.bkrepo.common.metadata.service.repo + +import com.tencent.bkrepo.common.storage.credentials.StorageCredentials +import com.tencent.bkrepo.repository.pojo.credendials.StorageCredentialsCreateRequest +import com.tencent.bkrepo.repository.pojo.credendials.StorageCredentialsUpdateRequest + +/** + * 存储凭证服务接口 + */ +interface RStorageCredentialService { + + /** + * 根据[request]创建存储凭证 + */ + suspend fun create(userId: String, request: StorageCredentialsCreateRequest): StorageCredentials + + /** + * 根据[request]更新存储凭证 + */ + suspend fun update(userId: String, request: StorageCredentialsUpdateRequest): StorageCredentials + + /** + * 根据[key]查询存储凭证[StorageCredentials],不存在则返回`null` + */ + suspend fun findByKey(key: String?): StorageCredentials? + + /** + * 查询存储凭证列表 + * @param region 部署区域 + */ + suspend fun list(region: String? = null): List + + /** + * 获取默认存储凭证 + */ + suspend fun default(): StorageCredentials + + /** + * 根据[key]删除存储凭证 + */ + suspend fun delete(key: String) + + /** + * 强制删除存储凭证 + * @param key 要删除的存储凭证key + */ + suspend fun forceDelete(key: String) +} diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/StorageCredentialService.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/repo/StorageCredentialService.kt similarity index 96% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/StorageCredentialService.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/repo/StorageCredentialService.kt index 00c1721aa5..5dc0c22acb 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/StorageCredentialService.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/repo/StorageCredentialService.kt @@ -29,7 +29,7 @@ * SOFTWARE. */ -package com.tencent.bkrepo.repository.service.repo +package com.tencent.bkrepo.common.metadata.service.repo import com.tencent.bkrepo.common.storage.credentials.StorageCredentials import com.tencent.bkrepo.repository.pojo.credendials.StorageCredentialsCreateRequest @@ -53,7 +53,7 @@ interface StorageCredentialService { /** * 根据[key]查询存储凭证[StorageCredentials],不存在则返回`null` */ - fun findByKey(key: String): StorageCredentials? + fun findByKey(key: String?): StorageCredentials? /** * 查询存储凭证列表 diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/StorageCredentialsUpdater.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/repo/StorageCredentialsUpdater.kt similarity index 97% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/StorageCredentialsUpdater.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/repo/StorageCredentialsUpdater.kt index 3298c7c752..2ae277e4ec 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/StorageCredentialsUpdater.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/repo/StorageCredentialsUpdater.kt @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.repository.service.repo +package com.tencent.bkrepo.common.metadata.service.repo import com.tencent.bkrepo.common.storage.credentials.StorageCredentials import com.tencent.bkrepo.repository.pojo.credendials.StorageCredentialsUpdateRequest diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/InnerCosStorageCredentialsUpdater.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/repo/impl/InnerCosStorageCredentialsUpdater.kt similarity index 94% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/InnerCosStorageCredentialsUpdater.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/repo/impl/InnerCosStorageCredentialsUpdater.kt index ad8cbbdd01..0c00df8962 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/InnerCosStorageCredentialsUpdater.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/repo/impl/InnerCosStorageCredentialsUpdater.kt @@ -25,14 +25,14 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.repository.service.repo.impl +package com.tencent.bkrepo.common.metadata.service.repo.impl import com.tencent.bkrepo.common.api.exception.ErrorCodeException import com.tencent.bkrepo.common.api.message.CommonMessageCode import com.tencent.bkrepo.common.storage.credentials.InnerCosCredentials import com.tencent.bkrepo.common.storage.credentials.StorageCredentials import com.tencent.bkrepo.repository.pojo.credendials.StorageCredentialsUpdateRequest -import com.tencent.bkrepo.repository.service.repo.StorageCredentialsUpdater +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialsUpdater import org.springframework.stereotype.Component @Component("InnerCosCredentialsUpdater") diff --git a/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/repo/impl/RStorageCredentialServiceImpl.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/repo/impl/RStorageCredentialServiceImpl.kt new file mode 100644 index 0000000000..cc7f0abe28 --- /dev/null +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/repo/impl/RStorageCredentialServiceImpl.kt @@ -0,0 +1,122 @@ +/* + * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. + * + * Copyright (C) 2020 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.bkrepo.common.metadata.service.repo.impl + +import com.tencent.bkrepo.common.api.exception.BadRequestException +import com.tencent.bkrepo.common.api.exception.ErrorCodeException +import com.tencent.bkrepo.common.api.exception.NotFoundException +import com.tencent.bkrepo.common.api.message.CommonMessageCode +import com.tencent.bkrepo.common.metadata.condition.ReactiveCondition +import com.tencent.bkrepo.common.metadata.dao.repo.RRepositoryDao +import com.tencent.bkrepo.common.metadata.dao.repo.RStorageCredentialsDao +import com.tencent.bkrepo.common.metadata.service.repo.RStorageCredentialService +import com.tencent.bkrepo.common.metadata.util.StorageCredentialHelper +import com.tencent.bkrepo.common.metadata.util.StorageCredentialHelper.Companion.buildStorageCredential +import com.tencent.bkrepo.common.metadata.util.StorageCredentialHelper.Companion.checkCreateRequest +import com.tencent.bkrepo.common.metadata.util.StorageCredentialHelper.Companion.convert +import com.tencent.bkrepo.common.storage.config.StorageProperties +import com.tencent.bkrepo.common.storage.credentials.StorageCredentials +import com.tencent.bkrepo.repository.message.RepositoryMessageCode +import com.tencent.bkrepo.repository.pojo.credendials.StorageCredentialsCreateRequest +import com.tencent.bkrepo.repository.pojo.credendials.StorageCredentialsUpdateRequest +import org.springframework.context.annotation.Conditional +import org.springframework.stereotype.Service +import org.springframework.transaction.annotation.Transactional + +/** + * 存储凭证服务实现类 + */ +@Service +@Conditional(ReactiveCondition::class) +class RStorageCredentialServiceImpl( + private val repositoryDao: RRepositoryDao, + private val storageCredentialsDao: RStorageCredentialsDao, + private val storageProperties: StorageProperties, +) : RStorageCredentialService { + + @Transactional(rollbackFor = [Throwable::class]) + override suspend fun create(userId: String, request: StorageCredentialsCreateRequest): StorageCredentials { + checkCreateRequest(request) + storageCredentialsDao.findById(request.key)?.run { + throw ErrorCodeException(CommonMessageCode.RESOURCE_EXISTED, request.key) + } + val storageCredential = buildStorageCredential(request, userId) + val savedCredentials = storageCredentialsDao.save(storageCredential) + return convert(savedCredentials) + } + + @Transactional(rollbackFor = [Throwable::class]) + override suspend fun update(userId: String, request: StorageCredentialsUpdateRequest): StorageCredentials { + requireNotNull(request.key) + val tStorageCredentials = storageCredentialsDao.findById(request.key!!) + ?: throw NotFoundException(RepositoryMessageCode.STORAGE_CREDENTIALS_NOT_FOUND) + StorageCredentialHelper.updateCredentials(tStorageCredentials, request) + val updatedCredentials = storageCredentialsDao.save(tStorageCredentials) + return convert(updatedCredentials) + } + + override suspend fun findByKey(key: String?): StorageCredentials? { + return if (key.isNullOrBlank()) { + storageProperties.defaultStorageCredentials() + } else { + storageCredentialsDao.findById(key)?.let { convert(it) } + } + } + + override suspend fun list(region: String?): List { + return storageCredentialsDao.findAll() + .filter { region.isNullOrBlank() || it.region == region } + .map { convert(it) } + } + + override suspend fun default(): StorageCredentials { + return storageProperties.defaultStorageCredentials() + } + + @Transactional(rollbackFor = [Throwable::class]) + override suspend fun delete(key: String) { + if (!storageCredentialsDao.existsById(key)) { + throw NotFoundException(RepositoryMessageCode.STORAGE_CREDENTIALS_NOT_FOUND) + } + val credentialsCount = storageCredentialsDao.count() + if (repositoryDao.existsByCredentialsKey(key) || credentialsCount <= 1) { + throw BadRequestException(RepositoryMessageCode.STORAGE_CREDENTIALS_IN_USE) + } + // 可能判断完凭证未被使用后,删除凭证前,又有新增的仓库使用凭证,出现这种情况后需要修改新增仓库的凭证 + return storageCredentialsDao.deleteById(key) + } + + @Transactional(rollbackFor = [Throwable::class]) + override suspend fun forceDelete(key: String) { + return storageCredentialsDao.deleteById(key) + } +} diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/StorageCredentialServiceImpl.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/repo/impl/StorageCredentialServiceImpl.kt similarity index 52% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/StorageCredentialServiceImpl.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/repo/impl/StorageCredentialServiceImpl.kt index d75f79337c..075e916df1 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/StorageCredentialServiceImpl.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/service/repo/impl/StorageCredentialServiceImpl.kt @@ -29,99 +29,71 @@ * SOFTWARE. */ -package com.tencent.bkrepo.repository.service.repo.impl +package com.tencent.bkrepo.common.metadata.service.repo.impl import com.tencent.bkrepo.common.api.exception.BadRequestException import com.tencent.bkrepo.common.api.exception.ErrorCodeException import com.tencent.bkrepo.common.api.exception.NotFoundException import com.tencent.bkrepo.common.api.message.CommonMessageCode -import com.tencent.bkrepo.common.api.util.readJsonString -import com.tencent.bkrepo.common.api.util.toJsonString -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.metadata.condition.SyncCondition +import com.tencent.bkrepo.common.metadata.dao.repo.RepositoryDao +import com.tencent.bkrepo.common.metadata.dao.repo.StorageCredentialsDao +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService +import com.tencent.bkrepo.common.metadata.util.StorageCredentialHelper +import com.tencent.bkrepo.common.metadata.util.StorageCredentialHelper.Companion.buildStorageCredential +import com.tencent.bkrepo.common.metadata.util.StorageCredentialHelper.Companion.checkCreateRequest +import com.tencent.bkrepo.common.metadata.util.StorageCredentialHelper.Companion.convert +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.credentials.StorageCredentials -import com.tencent.bkrepo.repository.dao.RepositoryDao -import com.tencent.bkrepo.repository.dao.repository.StorageCredentialsRepository import com.tencent.bkrepo.repository.message.RepositoryMessageCode -import com.tencent.bkrepo.repository.model.TStorageCredentials import com.tencent.bkrepo.repository.pojo.credendials.StorageCredentialsCreateRequest import com.tencent.bkrepo.repository.pojo.credendials.StorageCredentialsUpdateRequest -import com.tencent.bkrepo.repository.service.repo.StorageCredentialService -import com.tencent.bkrepo.repository.service.repo.StorageCredentialsUpdater -import org.springframework.data.repository.findByIdOrNull +import org.springframework.context.annotation.Conditional import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional -import java.time.LocalDateTime /** * 存储凭证服务实现类 */ @Service +@Conditional(SyncCondition::class) class StorageCredentialServiceImpl( private val repositoryDao: RepositoryDao, - private val storageCredentialsRepository: StorageCredentialsRepository, + private val storageCredentialsDao: StorageCredentialsDao, private val storageProperties: StorageProperties, - private val credentialUpdaters: Map ) : StorageCredentialService { @Transactional(rollbackFor = [Throwable::class]) override fun create(userId: String, request: StorageCredentialsCreateRequest): StorageCredentials { - takeIf { request.key.isNotBlank() } ?: throw ErrorCodeException(CommonMessageCode.PARAMETER_INVALID, "key") - // 目前的实现方式有个限制:新增的存储方式和默认的存储方式必须相同 - if (storageProperties.defaultStorageCredentials()::class != request.credentials::class) { - throw throw ErrorCodeException(CommonMessageCode.PARAMETER_INVALID, "type") - } - storageCredentialsRepository.findByIdOrNull(request.key)?.run { + checkCreateRequest(request) + storageCredentialsDao.findById(request.key)?.run { throw ErrorCodeException(CommonMessageCode.RESOURCE_EXISTED, request.key) } - val storageCredential = TStorageCredentials( - id = request.key, - createdBy = userId, - createdDate = LocalDateTime.now(), - lastModifiedBy = userId, - lastModifiedDate = LocalDateTime.now(), - credentials = request.credentials.toJsonString(), - region = request.region - ) - val savedCredentials = storageCredentialsRepository.save(storageCredential) + val storageCredential = buildStorageCredential(request, userId) + val savedCredentials = storageCredentialsDao.save(storageCredential) return convert(savedCredentials) } @Transactional(rollbackFor = [Throwable::class]) override fun update(userId: String, request: StorageCredentialsUpdateRequest): StorageCredentials { requireNotNull(request.key) - val tStorageCredentials = storageCredentialsRepository.findByIdOrNull(request.key!!) + val tStorageCredentials = storageCredentialsDao.findById(request.key!!) ?: throw NotFoundException(RepositoryMessageCode.STORAGE_CREDENTIALS_NOT_FOUND) - val storageCredentials = tStorageCredentials.credentials.readJsonString() - - storageCredentials.apply { - cache = cache.copy( - loadCacheFirst = request.credentials.cache.loadCacheFirst, - expireDays = request.credentials.cache.expireDays, - expireDuration = request.credentials.cache.expireDuration, - maxSize = request.credentials.cache.maxSize, - ) - upload = upload.copy( - localPath = request.credentials.upload.localPath, - workers = request.credentials.upload.workers - ) - compress = compress.copy( - path = request.credentials.compress.path, - ratio = request.credentials.compress.ratio - ) - credentialUpdaters[StorageCredentialsUpdater.name(this::class.java)]?.update(this, request) - } - - tStorageCredentials.credentials = storageCredentials.toJsonString() - val updatedCredentials = storageCredentialsRepository.save(tStorageCredentials) + StorageCredentialHelper.updateCredentials(tStorageCredentials, request) + val updatedCredentials = storageCredentialsDao.save(tStorageCredentials) return convert(updatedCredentials) } - override fun findByKey(key: String): StorageCredentials? { - return storageCredentialsRepository.findByIdOrNull(key)?.let { convert(it) } + override fun findByKey(key: String?): StorageCredentials? { + return if (key.isNullOrBlank()) { + storageProperties.defaultStorageCredentials() + } else { + storageCredentialsDao.findById(key)?.let { convert(it) } + } } override fun list(region: String?): List { - return storageCredentialsRepository.findAll() + return storageCredentialsDao.findAll() .filter { region.isNullOrBlank() || it.region == region } .map { convert(it) } } @@ -132,23 +104,19 @@ class StorageCredentialServiceImpl( @Transactional(rollbackFor = [Throwable::class]) override fun delete(key: String) { - if (!storageCredentialsRepository.existsById(key)) { + if (!storageCredentialsDao.existsById(key)) { throw NotFoundException(RepositoryMessageCode.STORAGE_CREDENTIALS_NOT_FOUND) } - val credentialsCount = storageCredentialsRepository.count() + val credentialsCount = storageCredentialsDao.count() if (repositoryDao.existsByCredentialsKey(key) || credentialsCount <= 1) { throw BadRequestException(RepositoryMessageCode.STORAGE_CREDENTIALS_IN_USE) } // 可能判断完凭证未被使用后,删除凭证前,又有新增的仓库使用凭证,出现这种情况后需要修改新增仓库的凭证 - return storageCredentialsRepository.deleteById(key) + return storageCredentialsDao.deleteById(key) } @Transactional(rollbackFor = [Throwable::class]) override fun forceDelete(key: String) { - return storageCredentialsRepository.deleteById(key) - } - - private fun convert(credentials: TStorageCredentials): StorageCredentials { - return credentials.credentials.readJsonString().apply { this.key = credentials.id } + return storageCredentialsDao.deleteById(key) } } diff --git a/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/util/RepoQueryHelper.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/util/RepoQueryHelper.kt new file mode 100644 index 0000000000..71403eb92a --- /dev/null +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/util/RepoQueryHelper.kt @@ -0,0 +1,52 @@ +/* + * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. + * + * Copyright (C) 2024 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.bkrepo.common.metadata.util + +import com.tencent.bkrepo.common.artifact.pojo.RepositoryType +import com.tencent.bkrepo.common.metadata.model.TRepository +import org.springframework.data.mongodb.core.query.Query +import org.springframework.data.mongodb.core.query.and +import org.springframework.data.mongodb.core.query.isEqualTo +import org.springframework.data.mongodb.core.query.where +import java.util.Locale + +object RepoQueryHelper { + + /** + * 构造单个仓库查询条件 + */ + fun buildSingleQuery(projectId: String, repoName: String, repoType: String? = null): Query { + val criteria = where(TRepository::projectId).isEqualTo(projectId) + .and(TRepository::name).isEqualTo(repoName) + .and(TRepository::deleted).isEqualTo(null) + if (repoType != null && repoType.uppercase(Locale.getDefault()) != RepositoryType.NONE.name) { + criteria.and(TRepository::type).isEqualTo(repoType.uppercase(Locale.getDefault())) + } + return Query(criteria) + } +} diff --git a/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/util/StorageCredentialHelper.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/util/StorageCredentialHelper.kt new file mode 100644 index 0000000000..1e8f50a355 --- /dev/null +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/util/StorageCredentialHelper.kt @@ -0,0 +1,110 @@ +/* + * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. + * + * Copyright (C) 2024 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.bkrepo.common.metadata.util + +import com.tencent.bkrepo.common.api.exception.ErrorCodeException +import com.tencent.bkrepo.common.api.message.CommonMessageCode +import com.tencent.bkrepo.common.api.util.readJsonString +import com.tencent.bkrepo.common.api.util.toJsonString +import com.tencent.bkrepo.common.metadata.model.TStorageCredentials +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialsUpdater +import com.tencent.bkrepo.common.storage.config.StorageProperties +import com.tencent.bkrepo.common.storage.credentials.StorageCredentials +import com.tencent.bkrepo.repository.pojo.credendials.StorageCredentialsCreateRequest +import com.tencent.bkrepo.repository.pojo.credendials.StorageCredentialsUpdateRequest +import org.springframework.stereotype.Component +import java.time.LocalDateTime + +@Component +class StorageCredentialHelper( + credentialUpdaters: Map, + storageProperties: StorageProperties, +) { + + init { + Companion.credentialUpdaters = credentialUpdaters + Companion.storageProperties = storageProperties + } + + companion object { + private lateinit var credentialUpdaters: Map + private lateinit var storageProperties: StorageProperties + + fun updateCredentials( + tStorageCredentials: TStorageCredentials, + request: StorageCredentialsUpdateRequest + ) { + val storageCredentials = tStorageCredentials.credentials.readJsonString() + + storageCredentials.apply { + cache = cache.copy( + loadCacheFirst = request.credentials.cache.loadCacheFirst, + expireDays = request.credentials.cache.expireDays, + expireDuration = request.credentials.cache.expireDuration, + maxSize = request.credentials.cache.maxSize, + ) + upload = upload.copy( + localPath = request.credentials.upload.localPath, + workers = request.credentials.upload.workers + ) + compress = compress.copy( + path = request.credentials.compress.path, + ratio = request.credentials.compress.ratio + ) + credentialUpdaters[StorageCredentialsUpdater.name(this::class.java)]?.update(this, request) + } + + tStorageCredentials.credentials = storageCredentials.toJsonString() + } + + fun convert(credentials: TStorageCredentials): StorageCredentials { + return credentials.credentials.readJsonString().apply { this.key = credentials.id } + } + + fun buildStorageCredential( + request: StorageCredentialsCreateRequest, + userId: String + ) = TStorageCredentials( + id = request.key, + createdBy = userId, + createdDate = LocalDateTime.now(), + lastModifiedBy = userId, + lastModifiedDate = LocalDateTime.now(), + credentials = request.credentials.toJsonString(), + region = request.region + ) + + fun checkCreateRequest(request: StorageCredentialsCreateRequest) { + takeIf { request.key.isNotBlank() } ?: throw ErrorCodeException(CommonMessageCode.PARAMETER_INVALID, "key") + // 目前的实现方式有个限制:新增的存储方式和默认的存储方式必须相同 + if (storageProperties.defaultStorageCredentials()::class != request.credentials::class) { + throw throw ErrorCodeException(CommonMessageCode.PARAMETER_INVALID, "type") + } + } + } +} diff --git a/src/backend/common/common-mongo-reactive/src/main/kotlin/com/tencent/bkrepo/common/mongo/reactive/dao/AbstractMongoReactiveDao.kt b/src/backend/common/common-mongo-reactive/src/main/kotlin/com/tencent/bkrepo/common/mongo/reactive/dao/AbstractMongoReactiveDao.kt index b5a44f557d..842aa68375 100644 --- a/src/backend/common/common-mongo-reactive/src/main/kotlin/com/tencent/bkrepo/common/mongo/reactive/dao/AbstractMongoReactiveDao.kt +++ b/src/backend/common/common-mongo-reactive/src/main/kotlin/com/tencent/bkrepo/common/mongo/reactive/dao/AbstractMongoReactiveDao.kt @@ -58,6 +58,10 @@ abstract class AbstractMongoReactiveDao : MongoReactiveDao { return find(query, classType) } + suspend fun findAll(): List { + return findAll(classType) + } + override suspend fun find(query: Query, clazz: Class): List { if (logger.isDebugEnabled) { logger.debug("Mongo Dao find: [$query] [$clazz]") @@ -67,6 +71,15 @@ abstract class AbstractMongoReactiveDao : MongoReactiveDao { .collectList().awaitSingle() } + override suspend fun findAll(clazz: Class): List { + if (logger.isDebugEnabled) { + logger.debug("Mongo Dao findAll: [$clazz]") + } + return determineReactiveMongoOperations() + .findAll(clazz, determineCollectionName()) + .collectList().awaitSingle() + } + override suspend fun updateFirst(query: Query, update: Update): UpdateResult { if (logger.isDebugEnabled) { logger.debug("Mongo Dao updateFirst: [$query], [$update]") @@ -166,5 +179,10 @@ abstract class AbstractMongoReactiveDao : MongoReactiveDao { companion object { private val logger = LoggerFactory.getLogger(AbstractMongoReactiveDao::class.java) + + /** + * mongodb 默认id字段 + */ + const val ID = "_id" } } diff --git a/src/backend/common/common-mongo-reactive/src/main/kotlin/com/tencent/bkrepo/common/mongo/reactive/dao/MongoReactiveDao.kt b/src/backend/common/common-mongo-reactive/src/main/kotlin/com/tencent/bkrepo/common/mongo/reactive/dao/MongoReactiveDao.kt index 063905235b..77079ddb76 100644 --- a/src/backend/common/common-mongo-reactive/src/main/kotlin/com/tencent/bkrepo/common/mongo/reactive/dao/MongoReactiveDao.kt +++ b/src/backend/common/common-mongo-reactive/src/main/kotlin/com/tencent/bkrepo/common/mongo/reactive/dao/MongoReactiveDao.kt @@ -47,6 +47,11 @@ interface MongoReactiveDao { */ suspend fun find(query: Query, clazz: Class): List + /** + * 通过查询对象查询文档集合,返回元素类型由clazz指定 + */ + suspend fun findAll(clazz: Class): List + /** * 新增文档到数据库的集合中 */ diff --git a/src/backend/common/common-mongo-reactive/src/main/kotlin/com/tencent/bkrepo/common/mongo/reactive/dao/SimpleMongoReactiveDao.kt b/src/backend/common/common-mongo-reactive/src/main/kotlin/com/tencent/bkrepo/common/mongo/reactive/dao/SimpleMongoReactiveDao.kt index f9df744fa4..6d8a2be1c7 100644 --- a/src/backend/common/common-mongo-reactive/src/main/kotlin/com/tencent/bkrepo/common/mongo/reactive/dao/SimpleMongoReactiveDao.kt +++ b/src/backend/common/common-mongo-reactive/src/main/kotlin/com/tencent/bkrepo/common/mongo/reactive/dao/SimpleMongoReactiveDao.kt @@ -29,7 +29,9 @@ package com.tencent.bkrepo.common.mongo.reactive.dao import org.springframework.beans.factory.annotation.Autowired import org.springframework.data.mongodb.core.ReactiveMongoOperations +import org.springframework.data.mongodb.core.query.Criteria import org.springframework.data.mongodb.core.query.Query +import org.springframework.data.mongodb.core.query.isEqualTo open class SimpleMongoReactiveDao : AbstractMongoReactiveDao() { @@ -49,4 +51,14 @@ open class SimpleMongoReactiveDao : AbstractMongoReactiveDao() { override fun determineCollectionName(entity: E): String { return collectionName } + + /** + * 根据主键"_id"查找记录 + */ + suspend fun findById(id: String): E? { + if (id.isBlank()) { + return null + } + return this.findOne(Query.query(Criteria.where(ID).isEqualTo(id))) + } } diff --git a/src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/monitor/MonitorProperties.kt b/src/backend/common/common-storage/storage-api/src/main/kotlin/com/tencent/bkrepo/common/storage/config/MonitorProperties.kt similarity index 97% rename from src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/monitor/MonitorProperties.kt rename to src/backend/common/common-storage/storage-api/src/main/kotlin/com/tencent/bkrepo/common/storage/config/MonitorProperties.kt index 4c3dfabaec..cdf506965f 100644 --- a/src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/monitor/MonitorProperties.kt +++ b/src/backend/common/common-storage/storage-api/src/main/kotlin/com/tencent/bkrepo/common/storage/config/MonitorProperties.kt @@ -29,7 +29,7 @@ * SOFTWARE. */ -package com.tencent.bkrepo.common.storage.monitor +package com.tencent.bkrepo.common.storage.config import org.springframework.util.unit.DataSize import java.time.Duration diff --git a/src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/core/config/RateLimitProperties.kt b/src/backend/common/common-storage/storage-api/src/main/kotlin/com/tencent/bkrepo/common/storage/config/RateLimitProperties.kt similarity index 97% rename from src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/core/config/RateLimitProperties.kt rename to src/backend/common/common-storage/storage-api/src/main/kotlin/com/tencent/bkrepo/common/storage/config/RateLimitProperties.kt index 6c747c7159..42b51dc72d 100644 --- a/src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/core/config/RateLimitProperties.kt +++ b/src/backend/common/common-storage/storage-api/src/main/kotlin/com/tencent/bkrepo/common/storage/config/RateLimitProperties.kt @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.common.storage.core.config +package com.tencent.bkrepo.common.storage.config import org.springframework.util.unit.DataSize diff --git a/src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/core/config/ReceiveProperties.kt b/src/backend/common/common-storage/storage-api/src/main/kotlin/com/tencent/bkrepo/common/storage/config/ReceiveProperties.kt similarity index 97% rename from src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/core/config/ReceiveProperties.kt rename to src/backend/common/common-storage/storage-api/src/main/kotlin/com/tencent/bkrepo/common/storage/config/ReceiveProperties.kt index c8ad725325..506efdbddb 100644 --- a/src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/core/config/ReceiveProperties.kt +++ b/src/backend/common/common-storage/storage-api/src/main/kotlin/com/tencent/bkrepo/common/storage/config/ReceiveProperties.kt @@ -29,7 +29,7 @@ * SOFTWARE. */ -package com.tencent.bkrepo.common.storage.core.config +package com.tencent.bkrepo.common.storage.config import org.springframework.util.unit.DataSize diff --git a/src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/core/config/RedirectProperties.kt b/src/backend/common/common-storage/storage-api/src/main/kotlin/com/tencent/bkrepo/common/storage/config/RedirectProperties.kt similarity index 97% rename from src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/core/config/RedirectProperties.kt rename to src/backend/common/common-storage/storage-api/src/main/kotlin/com/tencent/bkrepo/common/storage/config/RedirectProperties.kt index dd10022de7..124b7b567c 100644 --- a/src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/core/config/RedirectProperties.kt +++ b/src/backend/common/common-storage/storage-api/src/main/kotlin/com/tencent/bkrepo/common/storage/config/RedirectProperties.kt @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.common.storage.core.config +package com.tencent.bkrepo.common.storage.config import org.springframework.util.unit.DataSize import java.time.Duration diff --git a/src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/core/config/ResponseProperties.kt b/src/backend/common/common-storage/storage-api/src/main/kotlin/com/tencent/bkrepo/common/storage/config/ResponseProperties.kt similarity index 97% rename from src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/core/config/ResponseProperties.kt rename to src/backend/common/common-storage/storage-api/src/main/kotlin/com/tencent/bkrepo/common/storage/config/ResponseProperties.kt index a55f8bee11..26a3ec3b47 100644 --- a/src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/core/config/ResponseProperties.kt +++ b/src/backend/common/common-storage/storage-api/src/main/kotlin/com/tencent/bkrepo/common/storage/config/ResponseProperties.kt @@ -29,7 +29,7 @@ * SOFTWARE. */ -package com.tencent.bkrepo.common.storage.core.config +package com.tencent.bkrepo.common.storage.config import org.springframework.util.unit.DataSize diff --git a/src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/core/StorageProperties.kt b/src/backend/common/common-storage/storage-api/src/main/kotlin/com/tencent/bkrepo/common/storage/config/StorageProperties.kt similarity index 91% rename from src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/core/StorageProperties.kt rename to src/backend/common/common-storage/storage-api/src/main/kotlin/com/tencent/bkrepo/common/storage/config/StorageProperties.kt index ed52c45690..f61d779c53 100644 --- a/src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/core/StorageProperties.kt +++ b/src/backend/common/common-storage/storage-api/src/main/kotlin/com/tencent/bkrepo/common/storage/config/StorageProperties.kt @@ -29,18 +29,14 @@ * SOFTWARE. */ -package com.tencent.bkrepo.common.storage.core +package com.tencent.bkrepo.common.storage.config -import com.tencent.bkrepo.common.storage.core.config.ReceiveProperties -import com.tencent.bkrepo.common.storage.core.config.RedirectProperties -import com.tencent.bkrepo.common.storage.core.config.ResponseProperties import com.tencent.bkrepo.common.storage.credentials.FileSystemCredentials import com.tencent.bkrepo.common.storage.credentials.HDFSCredentials import com.tencent.bkrepo.common.storage.credentials.InnerCosCredentials import com.tencent.bkrepo.common.storage.credentials.S3Credentials import com.tencent.bkrepo.common.storage.credentials.StorageCredentials import com.tencent.bkrepo.common.storage.credentials.StorageType -import com.tencent.bkrepo.common.storage.monitor.MonitorProperties import org.springframework.boot.context.properties.ConfigurationProperties import org.springframework.boot.context.properties.NestedConfigurationProperty diff --git a/src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/StorageAutoConfiguration.kt b/src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/StorageAutoConfiguration.kt index c9a3b8ef4e..1aebdf8dcb 100644 --- a/src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/StorageAutoConfiguration.kt +++ b/src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/StorageAutoConfiguration.kt @@ -34,7 +34,7 @@ package com.tencent.bkrepo.common.storage import com.tencent.bkrepo.common.api.exception.SystemErrorException import com.tencent.bkrepo.common.api.message.CommonMessageCode import com.tencent.bkrepo.common.storage.core.FileStorage -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.core.StorageService import com.tencent.bkrepo.common.storage.core.cache.CacheStorageService import com.tencent.bkrepo.common.storage.core.cache.indexer.StorageCacheIndexConfiguration diff --git a/src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/core/AbstractFileStorage.kt b/src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/core/AbstractFileStorage.kt index 9696921958..f992ae4e33 100644 --- a/src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/core/AbstractFileStorage.kt +++ b/src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/core/AbstractFileStorage.kt @@ -35,6 +35,7 @@ import com.google.common.cache.CacheBuilder import com.google.common.cache.CacheLoader import com.google.common.cache.LoadingCache import com.tencent.bkrepo.common.artifact.stream.Range +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.credentials.StorageCredentials import com.tencent.bkrepo.common.storage.listener.FileStoreRetryListener import com.tencent.bkrepo.common.storage.monitor.measureThroughput diff --git a/src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/core/AbstractStorageSupport.kt b/src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/core/AbstractStorageSupport.kt index c2984e50ad..0a8594c231 100644 --- a/src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/core/AbstractStorageSupport.kt +++ b/src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/core/AbstractStorageSupport.kt @@ -35,6 +35,7 @@ import com.tencent.bkrepo.common.api.constant.StringPool import com.tencent.bkrepo.common.artifact.api.ArtifactFile import com.tencent.bkrepo.common.artifact.stream.ArtifactInputStream import com.tencent.bkrepo.common.artifact.stream.Range +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.core.locator.FileLocator import com.tencent.bkrepo.common.storage.credentials.StorageCredentials import com.tencent.bkrepo.common.storage.filesystem.FileSystemClient diff --git a/src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/core/cache/indexer/StorageCacheIndexConfiguration.kt b/src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/core/cache/indexer/StorageCacheIndexConfiguration.kt index 3b223eaf0b..5e97ed99e5 100644 --- a/src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/core/cache/indexer/StorageCacheIndexConfiguration.kt +++ b/src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/core/cache/indexer/StorageCacheIndexConfiguration.kt @@ -27,7 +27,7 @@ package com.tencent.bkrepo.common.storage.core.cache.indexer -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.core.cache.CacheStorageService import com.tencent.bkrepo.common.storage.core.cache.indexer.StorageCacheIndexProperties.Companion.CACHE_TYPE_REDIS_LRU import com.tencent.bkrepo.common.storage.core.cache.indexer.StorageCacheIndexProperties.Companion.CACHE_TYPE_REDIS_SLRU diff --git a/src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/monitor/StorageHealthMonitor.kt b/src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/monitor/StorageHealthMonitor.kt index 38b9f5aa0a..d2dc9b34e1 100644 --- a/src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/monitor/StorageHealthMonitor.kt +++ b/src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/monitor/StorageHealthMonitor.kt @@ -29,7 +29,7 @@ package com.tencent.bkrepo.common.storage.monitor import com.tencent.bkrepo.common.api.constant.StringPool.UNKNOWN import com.tencent.bkrepo.common.api.util.HumanReadable.time -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.util.toPath import org.slf4j.LoggerFactory import java.nio.file.Files diff --git a/src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/monitor/StorageHealthMonitorHelper.kt b/src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/monitor/StorageHealthMonitorHelper.kt index 35e451959b..ad64fc4391 100644 --- a/src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/monitor/StorageHealthMonitorHelper.kt +++ b/src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/monitor/StorageHealthMonitorHelper.kt @@ -1,6 +1,6 @@ package com.tencent.bkrepo.common.storage.monitor -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.credentials.StorageCredentials import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.LinkedBlockingQueue diff --git a/src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/util/PolarisUtil.kt b/src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/util/PolarisUtil.kt index bb40bc1f01..125fe16ed7 100644 --- a/src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/util/PolarisUtil.kt +++ b/src/backend/common/common-storage/storage-service/src/main/kotlin/com/tencent/bkrepo/common/storage/util/PolarisUtil.kt @@ -27,7 +27,7 @@ package com.tencent.bkrepo.common.storage.util -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.polaris.api.core.ConsumerAPI import com.tencent.polaris.api.rpc.GetOneInstanceRequest import com.tencent.polaris.factory.api.DiscoveryAPIFactory diff --git a/src/backend/common/common-storage/storage-service/src/test/kotlin/com/tencent/bkrepo/common/storage/core/EncryptFileStorageTest.kt b/src/backend/common/common-storage/storage-service/src/test/kotlin/com/tencent/bkrepo/common/storage/core/EncryptFileStorageTest.kt index cdfaa19961..b1ad30f506 100644 --- a/src/backend/common/common-storage/storage-service/src/test/kotlin/com/tencent/bkrepo/common/storage/core/EncryptFileStorageTest.kt +++ b/src/backend/common/common-storage/storage-service/src/test/kotlin/com/tencent/bkrepo/common/storage/core/EncryptFileStorageTest.kt @@ -31,6 +31,7 @@ import com.tencent.bkrepo.common.api.constant.StringPool import com.tencent.bkrepo.common.artifact.hash.sha256 import com.tencent.bkrepo.common.artifact.stream.Range import com.tencent.bkrepo.common.storage.StorageAutoConfiguration +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.credentials.FileSystemCredentials import com.tencent.bkrepo.common.storage.filesystem.FileSystemClient import org.junit.jupiter.api.AfterEach diff --git a/src/backend/common/common-storage/storage-service/src/test/kotlin/com/tencent/bkrepo/common/storage/core/cache/CacheStorageServiceTest.kt b/src/backend/common/common-storage/storage-service/src/test/kotlin/com/tencent/bkrepo/common/storage/core/cache/CacheStorageServiceTest.kt index 843328a4c9..9f80c9e964 100644 --- a/src/backend/common/common-storage/storage-service/src/test/kotlin/com/tencent/bkrepo/common/storage/core/cache/CacheStorageServiceTest.kt +++ b/src/backend/common/common-storage/storage-service/src/test/kotlin/com/tencent/bkrepo/common/storage/core/cache/CacheStorageServiceTest.kt @@ -38,7 +38,7 @@ import com.tencent.bkrepo.common.artifact.hash.sha256 import com.tencent.bkrepo.common.artifact.stream.Range import com.tencent.bkrepo.common.storage.StorageAutoConfiguration import com.tencent.bkrepo.common.storage.core.FileStorage -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.core.StorageService import com.tencent.bkrepo.common.storage.core.locator.FileLocator import com.tencent.bkrepo.common.storage.filesystem.FileSystemClient diff --git a/src/backend/common/common-storage/storage-service/src/test/kotlin/com/tencent/bkrepo/common/storage/core/overlay/OverlaySupportTest.kt b/src/backend/common/common-storage/storage-service/src/test/kotlin/com/tencent/bkrepo/common/storage/core/overlay/OverlaySupportTest.kt index ab391088e3..0e407dd990 100644 --- a/src/backend/common/common-storage/storage-service/src/test/kotlin/com/tencent/bkrepo/common/storage/core/overlay/OverlaySupportTest.kt +++ b/src/backend/common/common-storage/storage-service/src/test/kotlin/com/tencent/bkrepo/common/storage/core/overlay/OverlaySupportTest.kt @@ -31,7 +31,7 @@ import com.tencent.bkrepo.common.artifact.api.toArtifactFile import com.tencent.bkrepo.common.artifact.hash.sha256 import com.tencent.bkrepo.common.artifact.stream.Range import com.tencent.bkrepo.common.storage.StorageAutoConfiguration -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.core.StorageService import com.tencent.bkrepo.common.storage.pojo.RegionResource import org.apache.commons.io.FileUtils diff --git a/src/backend/common/common-storage/storage-service/src/test/kotlin/com/tencent/bkrepo/common/storage/credentials/StorageCredentialsTest.kt b/src/backend/common/common-storage/storage-service/src/test/kotlin/com/tencent/bkrepo/common/storage/credentials/StorageCredentialsTest.kt index e819e770c0..768a9dd861 100644 --- a/src/backend/common/common-storage/storage-service/src/test/kotlin/com/tencent/bkrepo/common/storage/credentials/StorageCredentialsTest.kt +++ b/src/backend/common/common-storage/storage-service/src/test/kotlin/com/tencent/bkrepo/common/storage/credentials/StorageCredentialsTest.kt @@ -33,7 +33,7 @@ package com.tencent.bkrepo.common.storage.credentials import com.tencent.bkrepo.common.api.util.readJsonString import com.tencent.bkrepo.common.api.util.toJsonString -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith diff --git a/src/backend/common/common-storage/storage-service/src/test/kotlin/com/tencent/bkrepo/common/storage/monitor/StorageHealthMonitorHelperTest.kt b/src/backend/common/common-storage/storage-service/src/test/kotlin/com/tencent/bkrepo/common/storage/monitor/StorageHealthMonitorHelperTest.kt index 26aa2801e5..532df6cb5c 100644 --- a/src/backend/common/common-storage/storage-service/src/test/kotlin/com/tencent/bkrepo/common/storage/monitor/StorageHealthMonitorHelperTest.kt +++ b/src/backend/common/common-storage/storage-service/src/test/kotlin/com/tencent/bkrepo/common/storage/monitor/StorageHealthMonitorHelperTest.kt @@ -1,7 +1,7 @@ package com.tencent.bkrepo.common.storage.monitor import com.tencent.bkrepo.common.storage.config.UploadProperties -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.credentials.StorageCredentials import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test diff --git a/src/backend/common/common-storage/storage-service/src/test/kotlin/com/tencent/bkrepo/common/storage/monitor/StorageHealthMonitorTest.kt b/src/backend/common/common-storage/storage-service/src/test/kotlin/com/tencent/bkrepo/common/storage/monitor/StorageHealthMonitorTest.kt index 004f3ab29e..bba8972f20 100644 --- a/src/backend/common/common-storage/storage-service/src/test/kotlin/com/tencent/bkrepo/common/storage/monitor/StorageHealthMonitorTest.kt +++ b/src/backend/common/common-storage/storage-service/src/test/kotlin/com/tencent/bkrepo/common/storage/monitor/StorageHealthMonitorTest.kt @@ -27,8 +27,9 @@ package com.tencent.bkrepo.common.storage.monitor +import com.tencent.bkrepo.common.storage.config.MonitorProperties import com.tencent.bkrepo.common.storage.config.UploadProperties -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.credentials.FileSystemCredentials import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.DisplayName diff --git a/src/backend/fs/boot-fs-server/src/main/kotlin/com/tencent/bkrepo/fs/server/storage/CoArtifactDataReceiver.kt b/src/backend/fs/boot-fs-server/src/main/kotlin/com/tencent/bkrepo/fs/server/storage/CoArtifactDataReceiver.kt index 35e189e829..38f8546a90 100644 --- a/src/backend/fs/boot-fs-server/src/main/kotlin/com/tencent/bkrepo/fs/server/storage/CoArtifactDataReceiver.kt +++ b/src/backend/fs/boot-fs-server/src/main/kotlin/com/tencent/bkrepo/fs/server/storage/CoArtifactDataReceiver.kt @@ -30,7 +30,7 @@ package com.tencent.bkrepo.fs.server.storage import com.tencent.bkrepo.common.api.constant.StringPool import com.tencent.bkrepo.common.artifact.stream.DigestCalculateListener import com.tencent.bkrepo.common.artifact.stream.closeQuietly -import com.tencent.bkrepo.common.storage.core.config.ReceiveProperties +import com.tencent.bkrepo.common.storage.config.ReceiveProperties import com.tencent.bkrepo.common.storage.monitor.StorageHealthMonitor import com.tencent.bkrepo.common.storage.monitor.Throughput import kotlinx.coroutines.reactive.awaitSingle diff --git a/src/backend/fs/boot-fs-server/src/main/kotlin/com/tencent/bkrepo/fs/server/storage/CoArtifactFile.kt b/src/backend/fs/boot-fs-server/src/main/kotlin/com/tencent/bkrepo/fs/server/storage/CoArtifactFile.kt index 19dde26fca..9c3c346cc2 100644 --- a/src/backend/fs/boot-fs-server/src/main/kotlin/com/tencent/bkrepo/fs/server/storage/CoArtifactFile.kt +++ b/src/backend/fs/boot-fs-server/src/main/kotlin/com/tencent/bkrepo/fs/server/storage/CoArtifactFile.kt @@ -29,7 +29,7 @@ package com.tencent.bkrepo.fs.server.storage import com.tencent.bkrepo.common.artifact.api.ArtifactFile import com.tencent.bkrepo.common.artifact.hash.sha1 -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.credentials.StorageCredentials import com.tencent.bkrepo.common.storage.monitor.StorageHealthMonitor import com.tencent.bkrepo.common.storage.util.toPath diff --git a/src/backend/fs/boot-fs-server/src/main/kotlin/com/tencent/bkrepo/fs/server/storage/CoArtifactFileFactory.kt b/src/backend/fs/boot-fs-server/src/main/kotlin/com/tencent/bkrepo/fs/server/storage/CoArtifactFileFactory.kt index de85bcd54f..3e296fc268 100644 --- a/src/backend/fs/boot-fs-server/src/main/kotlin/com/tencent/bkrepo/fs/server/storage/CoArtifactFileFactory.kt +++ b/src/backend/fs/boot-fs-server/src/main/kotlin/com/tencent/bkrepo/fs/server/storage/CoArtifactFileFactory.kt @@ -28,7 +28,7 @@ package com.tencent.bkrepo.fs.server.storage import com.tencent.bkrepo.common.artifact.api.ArtifactFile -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.credentials.StorageCredentials import com.tencent.bkrepo.common.storage.monitor.StorageHealthMonitor import com.tencent.bkrepo.common.storage.monitor.StorageHealthMonitorHelper diff --git a/src/backend/fs/boot-fs-server/src/test/kotlin/com/tencent/com/bkrepo/fs/storage/CoArtifactDataReceiverTest.kt b/src/backend/fs/boot-fs-server/src/test/kotlin/com/tencent/com/bkrepo/fs/storage/CoArtifactDataReceiverTest.kt index 854b40eaa5..5087db8537 100644 --- a/src/backend/fs/boot-fs-server/src/test/kotlin/com/tencent/com/bkrepo/fs/storage/CoArtifactDataReceiverTest.kt +++ b/src/backend/fs/boot-fs-server/src/test/kotlin/com/tencent/com/bkrepo/fs/storage/CoArtifactDataReceiverTest.kt @@ -28,7 +28,7 @@ package com.tencent.com.bkrepo.fs.storage import com.tencent.bkrepo.common.api.constant.StringPool -import com.tencent.bkrepo.common.storage.core.config.ReceiveProperties +import com.tencent.bkrepo.common.storage.config.ReceiveProperties import com.tencent.bkrepo.common.storage.util.toPath import com.tencent.bkrepo.fs.server.storage.CoArtifactDataReceiver import java.io.ByteArrayOutputStream diff --git a/src/backend/fs/boot-fs-server/src/test/kotlin/com/tencent/com/bkrepo/fs/storage/CoArtifactFileTest.kt b/src/backend/fs/boot-fs-server/src/test/kotlin/com/tencent/com/bkrepo/fs/storage/CoArtifactFileTest.kt index eb208755a8..2ae27289ad 100644 --- a/src/backend/fs/boot-fs-server/src/test/kotlin/com/tencent/com/bkrepo/fs/storage/CoArtifactFileTest.kt +++ b/src/backend/fs/boot-fs-server/src/test/kotlin/com/tencent/com/bkrepo/fs/storage/CoArtifactFileTest.kt @@ -32,10 +32,10 @@ import com.tencent.bkrepo.common.artifact.hash.md5 import com.tencent.bkrepo.common.artifact.hash.sha1 import com.tencent.bkrepo.common.artifact.hash.sha256 import com.tencent.bkrepo.common.storage.config.UploadProperties -import com.tencent.bkrepo.common.storage.core.StorageProperties -import com.tencent.bkrepo.common.storage.core.config.ReceiveProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties +import com.tencent.bkrepo.common.storage.config.ReceiveProperties import com.tencent.bkrepo.common.storage.credentials.FileSystemCredentials -import com.tencent.bkrepo.common.storage.monitor.MonitorProperties +import com.tencent.bkrepo.common.storage.config.MonitorProperties import com.tencent.bkrepo.common.storage.monitor.StorageHealthMonitor import com.tencent.bkrepo.fs.server.storage.CoArtifactFile import java.io.ByteArrayOutputStream diff --git a/src/backend/generic/biz-generic/src/main/kotlin/com/tencent/bkrepo/generic/artifact/GenericRemoteRepository.kt b/src/backend/generic/biz-generic/src/main/kotlin/com/tencent/bkrepo/generic/artifact/GenericRemoteRepository.kt index a39342c385..a8ec09eeca 100644 --- a/src/backend/generic/biz-generic/src/main/kotlin/com/tencent/bkrepo/generic/artifact/GenericRemoteRepository.kt +++ b/src/backend/generic/biz-generic/src/main/kotlin/com/tencent/bkrepo/generic/artifact/GenericRemoteRepository.kt @@ -67,7 +67,7 @@ import com.tencent.bkrepo.common.query.enums.OperationType import com.tencent.bkrepo.common.query.model.QueryModel import com.tencent.bkrepo.common.query.model.Rule import com.tencent.bkrepo.common.service.util.HttpContextHolder -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.innercos.http.HttpMethod.HEAD import com.tencent.bkrepo.common.storage.innercos.http.toRequestBody import com.tencent.bkrepo.common.storage.monitor.StorageHealthMonitorHelper diff --git a/src/backend/generic/biz-generic/src/main/kotlin/com/tencent/bkrepo/generic/artifact/remote/RemoteArtifactCacheWriter.kt b/src/backend/generic/biz-generic/src/main/kotlin/com/tencent/bkrepo/generic/artifact/remote/RemoteArtifactCacheWriter.kt index 773d03302b..5288453eff 100644 --- a/src/backend/generic/biz-generic/src/main/kotlin/com/tencent/bkrepo/generic/artifact/remote/RemoteArtifactCacheWriter.kt +++ b/src/backend/generic/biz-generic/src/main/kotlin/com/tencent/bkrepo/generic/artifact/remote/RemoteArtifactCacheWriter.kt @@ -32,7 +32,7 @@ import com.tencent.bkrepo.common.artifact.manager.StorageManager import com.tencent.bkrepo.common.artifact.repository.context.ArtifactContext import com.tencent.bkrepo.common.artifact.resolve.file.ArtifactDataReceiver import com.tencent.bkrepo.common.artifact.stream.StreamReadListener -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.monitor.StorageHealthMonitor import com.tencent.bkrepo.common.storage.util.toPath import com.tencent.bkrepo.generic.artifact.findRemoteMetadata diff --git a/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/task/cache/ExpiredCacheFileCleanupJob.kt b/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/task/cache/ExpiredCacheFileCleanupJob.kt index 0160c1d13b..ffeb121e8a 100644 --- a/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/task/cache/ExpiredCacheFileCleanupJob.kt +++ b/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/task/cache/ExpiredCacheFileCleanupJob.kt @@ -31,7 +31,7 @@ import com.tencent.bkrepo.common.api.util.executeAndMeasureTime import com.tencent.bkrepo.common.api.util.readJsonString import com.tencent.bkrepo.common.artifact.constant.DEFAULT_STORAGE_KEY import com.tencent.bkrepo.common.service.cluster.properties.ClusterProperties -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.core.StorageService import com.tencent.bkrepo.common.storage.credentials.StorageCredentials import com.tencent.bkrepo.common.storage.util.toPath diff --git a/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/task/cache/StorageCacheIndexEvictJob.kt b/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/task/cache/StorageCacheIndexEvictJob.kt index 934d10b7cc..40e77d0554 100644 --- a/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/task/cache/StorageCacheIndexEvictJob.kt +++ b/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/task/cache/StorageCacheIndexEvictJob.kt @@ -29,7 +29,7 @@ package com.tencent.bkrepo.job.batch.task.cache import com.tencent.bkrepo.common.service.cluster.properties.ClusterProperties import com.tencent.bkrepo.common.service.log.LoggerHolder -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.core.cache.indexer.StorageCacheIndexProperties import com.tencent.bkrepo.common.storage.core.cache.indexer.StorageCacheIndexerManager import com.tencent.bkrepo.common.storage.credentials.StorageCredentials diff --git a/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/task/cache/StorageCacheIndexJob.kt b/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/task/cache/StorageCacheIndexJob.kt index 0b94c990a1..a47245c962 100644 --- a/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/task/cache/StorageCacheIndexJob.kt +++ b/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/task/cache/StorageCacheIndexJob.kt @@ -29,7 +29,7 @@ package com.tencent.bkrepo.job.batch.task.cache import com.tencent.bkrepo.common.api.util.readJsonString import com.tencent.bkrepo.common.service.cluster.properties.ClusterProperties -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.core.cache.indexer.StorageCacheIndexProperties import com.tencent.bkrepo.common.storage.core.cache.indexer.StorageCacheIndexerManager import com.tencent.bkrepo.common.storage.credentials.StorageCredentials diff --git a/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/task/cache/StorageCacheIndexSyncJob.kt b/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/task/cache/StorageCacheIndexSyncJob.kt index 7f99438144..89fd4b553d 100644 --- a/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/task/cache/StorageCacheIndexSyncJob.kt +++ b/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/task/cache/StorageCacheIndexSyncJob.kt @@ -29,7 +29,7 @@ package com.tencent.bkrepo.job.batch.task.cache import com.tencent.bkrepo.common.service.cluster.properties.ClusterProperties import com.tencent.bkrepo.common.service.log.LoggerHolder -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.core.cache.indexer.StorageCacheIndexProperties import com.tencent.bkrepo.common.storage.core.cache.indexer.StorageCacheIndexerManager import com.tencent.bkrepo.common.storage.credentials.StorageCredentials diff --git a/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/task/clean/DeletedNodeCleanupJob.kt b/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/task/clean/DeletedNodeCleanupJob.kt index c1911173ac..ad0c8d7697 100644 --- a/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/task/clean/DeletedNodeCleanupJob.kt +++ b/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/task/clean/DeletedNodeCleanupJob.kt @@ -35,6 +35,7 @@ import com.mongodb.client.result.DeleteResult import com.tencent.bkrepo.common.api.constant.CharPool import com.tencent.bkrepo.common.artifact.exception.RepoNotFoundException import com.tencent.bkrepo.common.metadata.constant.FAKE_SHA256 +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService import com.tencent.bkrepo.common.mongo.constant.ID import com.tencent.bkrepo.common.service.cluster.properties.ClusterProperties import com.tencent.bkrepo.job.DELETED_DATE @@ -50,7 +51,6 @@ import com.tencent.bkrepo.job.batch.utils.TimeUtils import com.tencent.bkrepo.job.config.properties.DeletedNodeCleanupJobProperties import com.tencent.bkrepo.job.migrate.MigrateRepoStorageService import com.tencent.bkrepo.job.separation.service.SeparationTaskService -import com.tencent.bkrepo.repository.api.StorageCredentialsClient import org.slf4j.LoggerFactory import org.springframework.boot.context.properties.EnableConfigurationProperties import org.springframework.data.mongodb.core.findOne @@ -74,7 +74,7 @@ class DeletedNodeCleanupJob( private val properties: DeletedNodeCleanupJobProperties, private val clusterProperties: ClusterProperties, private val migrateRepoStorageService: MigrateRepoStorageService, - private val storageCredentialsClient: StorageCredentialsClient, + private val storageCredentialService: StorageCredentialService, private val separationTaskService: SeparationTaskService, ) : DefaultContextMongoDbJob(properties) { @@ -259,8 +259,8 @@ class DeletedNodeCleanupJob( } private fun handleNodeWithUnknownRepo(sha256: String) { - val credentials = storageCredentialsClient.list().data - val defaultCredentials = storageCredentialsClient.findByKey().data + val credentials = storageCredentialService.list() + val defaultCredentials = storageCredentialService.findByKey(null) if (credentials.isNullOrEmpty() && defaultCredentials == null) return val keySet = mutableSetOf() if (!credentials.isNullOrEmpty()) { diff --git a/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/task/clean/FileReferenceCleanupJob.kt b/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/task/clean/FileReferenceCleanupJob.kt index 8e7d5a61b9..b873b40d59 100644 --- a/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/task/clean/FileReferenceCleanupJob.kt +++ b/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/task/clean/FileReferenceCleanupJob.kt @@ -34,6 +34,7 @@ import com.tencent.bkrepo.archive.api.ArchiveClient import com.tencent.bkrepo.archive.constant.DEFAULT_KEY import com.tencent.bkrepo.archive.request.ArchiveFileRequest import com.tencent.bkrepo.archive.request.DeleteCompressRequest +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService import com.tencent.bkrepo.common.mongo.constant.ID import com.tencent.bkrepo.common.service.log.LoggerHolder import com.tencent.bkrepo.common.storage.core.StorageService @@ -49,7 +50,6 @@ import com.tencent.bkrepo.job.batch.utils.NodeCommonUtils import com.tencent.bkrepo.job.config.properties.FileReferenceCleanupJobProperties import com.tencent.bkrepo.job.exception.JobExecuteException import com.tencent.bkrepo.job.exception.RepoMigratingException -import com.tencent.bkrepo.repository.api.StorageCredentialsClient import com.tencent.bkrepo.repository.constant.SYSTEM_USER import org.springframework.boot.context.properties.EnableConfigurationProperties import org.springframework.data.mongodb.core.query.Criteria @@ -72,7 +72,7 @@ import kotlin.reflect.KClass @Suppress("UnstableApiUsage") class FileReferenceCleanupJob( private val storageService: StorageService, - private val storageCredentialsClient: StorageCredentialsClient, + private val storageCredentialService: StorageCredentialService, private val properties: FileReferenceCleanupJobProperties, private val archiveClient: ArchiveClient, ) : MongoDbBatchJob(properties) { @@ -219,7 +219,7 @@ class FileReferenceCleanupJob( private fun getCredentials(key: String): StorageCredentials? { return cacheMap.getOrPut(key) { - storageCredentialsClient.findByKey(key).data ?: return null + storageCredentialService.findByKey(key) ?: return null } } diff --git a/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/task/other/FileSynchronizeJob.kt b/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/task/other/FileSynchronizeJob.kt index d019af4754..ae97f27b70 100644 --- a/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/task/other/FileSynchronizeJob.kt +++ b/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/task/other/FileSynchronizeJob.kt @@ -28,13 +28,13 @@ package com.tencent.bkrepo.job.batch.task.other import com.tencent.bkrepo.common.api.util.executeAndMeasureTime +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService import com.tencent.bkrepo.common.service.cluster.properties.ClusterProperties import com.tencent.bkrepo.common.storage.core.StorageService import com.tencent.bkrepo.common.storage.credentials.StorageCredentials import com.tencent.bkrepo.job.batch.base.DefaultContextJob import com.tencent.bkrepo.job.batch.base.JobContext import com.tencent.bkrepo.job.config.properties.FileSynchronizeJobProperties -import com.tencent.bkrepo.repository.api.StorageCredentialsClient import org.slf4j.LoggerFactory import org.springframework.boot.context.properties.EnableConfigurationProperties import org.springframework.stereotype.Component @@ -46,7 +46,7 @@ import org.springframework.stereotype.Component @EnableConfigurationProperties(FileSynchronizeJobProperties::class) class FileSynchronizeJob( private val properties: FileSynchronizeJobProperties, - private val storageCredentialsClient: StorageCredentialsClient, + private val storageCredentialService: StorageCredentialService, private val storageService: StorageService, private val clusterProperties: ClusterProperties ) : DefaultContextJob(properties) { @@ -59,8 +59,7 @@ class FileSynchronizeJob( // cleanup default storage syncStorage() // cleanup extended storage - storageCredentialsClient.list(clusterProperties.region) - .data?.forEach { syncStorage(it) } + storageCredentialService.list(clusterProperties.region).forEach { syncStorage(it) } } private fun syncStorage(storage: StorageCredentials? = null) { diff --git a/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/task/stat/FileSystemStorageStatJob.kt b/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/task/stat/FileSystemStorageStatJob.kt index 89df6b7211..64aa2a99dc 100644 --- a/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/task/stat/FileSystemStorageStatJob.kt +++ b/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/task/stat/FileSystemStorageStatJob.kt @@ -28,15 +28,15 @@ package com.tencent.bkrepo.job.batch.task.stat import com.tencent.bkrepo.common.artifact.path.PathUtils +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService import com.tencent.bkrepo.common.storage.config.CacheProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.config.UploadProperties -import com.tencent.bkrepo.common.storage.core.StorageProperties import com.tencent.bkrepo.common.storage.credentials.StorageType import com.tencent.bkrepo.job.batch.base.DefaultContextJob import com.tencent.bkrepo.job.batch.base.JobContext import com.tencent.bkrepo.job.batch.task.other.FileSynchronizeJob import com.tencent.bkrepo.job.config.properties.FileSystemStorageStatJobProperties -import com.tencent.bkrepo.repository.api.StorageCredentialsClient import org.slf4j.LoggerFactory import org.springframework.boot.context.properties.EnableConfigurationProperties import org.springframework.data.mongodb.core.MongoTemplate @@ -60,7 +60,7 @@ import java.time.LocalDateTime class FileSystemStorageStatJob( properties: FileSystemStorageStatJobProperties, private val storageProperties: StorageProperties, - private val storageCredentialsClient: StorageCredentialsClient, + private val storageCredentialService: StorageCredentialService, private val mongoTemplate: MongoTemplate ) : DefaultContextJob(properties) { override fun doStart0(jobContext: JobContext) { @@ -131,7 +131,7 @@ class FileSystemStorageStatJob( } private fun findStoragePath(): Set { - val list = storageCredentialsClient.list().data ?: return emptySet() + val list = storageCredentialService.list() val default = storageProperties.defaultStorageCredentials() val result = mutableSetOf() list.forEach { diff --git a/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/task/storage/StorageReconcileJob.kt b/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/task/storage/StorageReconcileJob.kt index b8827412af..a92cf5b1ba 100644 --- a/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/task/storage/StorageReconcileJob.kt +++ b/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/task/storage/StorageReconcileJob.kt @@ -4,9 +4,10 @@ import com.google.common.hash.BloomFilter import com.google.common.hash.Funnels import com.tencent.bkrepo.common.api.constant.StringPool import com.tencent.bkrepo.common.metadata.service.file.FileReferenceService +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService import com.tencent.bkrepo.common.service.cluster.properties.ClusterProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.core.FileStorage -import com.tencent.bkrepo.common.storage.core.StorageProperties import com.tencent.bkrepo.common.storage.credentials.StorageCredentials import com.tencent.bkrepo.job.CREDENTIALS import com.tencent.bkrepo.job.SHA256 @@ -15,7 +16,6 @@ import com.tencent.bkrepo.job.batch.base.JobContext import com.tencent.bkrepo.job.batch.utils.NodeCommonUtils import com.tencent.bkrepo.job.config.properties.FileReferenceCleanupJobProperties import com.tencent.bkrepo.job.config.properties.StorageReconcileJobProperties -import com.tencent.bkrepo.repository.api.StorageCredentialsClient import org.slf4j.LoggerFactory import org.springframework.boot.context.properties.EnableConfigurationProperties import org.springframework.data.mongodb.core.query.Criteria @@ -38,7 +38,7 @@ class StorageReconcileJob( private val bloomFilterProp: FileReferenceCleanupJobProperties, private val fileStorage: FileStorage, private val clusterProperties: ClusterProperties, - private val storageCredentialsClient: StorageCredentialsClient, + private val storageCredentialService: StorageCredentialService, private val storageProperties: StorageProperties, private val fileReferenceService: FileReferenceService, ) : DefaultContextJob(properties) { @@ -47,7 +47,7 @@ class StorageReconcileJob( reconcile(storageProperties.defaultStorageCredentials()) // 校验其他存储 - storageCredentialsClient.list(clusterProperties.region).data?.forEach { + storageCredentialService.list(clusterProperties.region).forEach { reconcile(it) } } diff --git a/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/utils/RepositoryCommonUtils.kt b/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/utils/RepositoryCommonUtils.kt index d6d6f3d9c9..91840b1cba 100644 --- a/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/utils/RepositoryCommonUtils.kt +++ b/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/utils/RepositoryCommonUtils.kt @@ -4,26 +4,26 @@ import com.google.common.cache.Cache import com.google.common.cache.CacheBuilder import com.tencent.bkrepo.common.artifact.exception.RepoNotFoundException import com.tencent.bkrepo.common.artifact.pojo.RepositoryType +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService import com.tencent.bkrepo.common.storage.credentials.StorageCredentials import com.tencent.bkrepo.repository.api.RepositoryClient -import com.tencent.bkrepo.repository.api.StorageCredentialsClient import com.tencent.bkrepo.repository.pojo.repo.RepositoryDetail import org.springframework.stereotype.Component import java.util.concurrent.TimeUnit @Component class RepositoryCommonUtils( - storageCredentialsClient: StorageCredentialsClient, + storageCredentialService: StorageCredentialService, repositoryClient: RepositoryClient ) { init { - Companion.storageCredentialsClient = storageCredentialsClient + Companion.storageCredentialService = storageCredentialService Companion.repositoryClient = repositoryClient } companion object { - private lateinit var storageCredentialsClient: StorageCredentialsClient + private lateinit var storageCredentialService: StorageCredentialService private lateinit var repositoryClient: RepositoryClient private val repositoryCache = CacheBuilder.newBuilder() .maximumSize(10000) @@ -36,9 +36,9 @@ class RepositoryCommonUtils( .build() fun getStorageCredentials(credentialsKey: String): StorageCredentials? { - return storageCredentialsCache.getIfPresent(credentialsKey) ?: storageCredentialsClient.findByKey( + return storageCredentialsCache.getIfPresent(credentialsKey) ?: storageCredentialService.findByKey( credentialsKey - ).data?.apply { storageCredentialsCache.put(credentialsKey, this) } + )?.apply { storageCredentialsCache.put(credentialsKey, this) } } fun getRepositoryDetail( diff --git a/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/migrate/MigrateRepoStorageService.kt b/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/migrate/MigrateRepoStorageService.kt index bd485ccdb7..9cfb0604e3 100644 --- a/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/migrate/MigrateRepoStorageService.kt +++ b/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/migrate/MigrateRepoStorageService.kt @@ -34,7 +34,7 @@ import com.tencent.bkrepo.common.api.message.CommonMessageCode import com.tencent.bkrepo.common.api.pojo.Page import com.tencent.bkrepo.common.mongo.util.Pages import com.tencent.bkrepo.common.service.actuator.ActuatorConfiguration.Companion.SERVICE_INSTANCE_ID -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.credentials.StorageCredentials import com.tencent.bkrepo.job.batch.utils.RepositoryCommonUtils import com.tencent.bkrepo.job.migrate.config.MigrateRepoStorageProperties diff --git a/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/migrate/strategy/FileNotFoundAutoFixStrategy.kt b/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/migrate/strategy/FileNotFoundAutoFixStrategy.kt index 67413949c9..df96074f18 100644 --- a/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/migrate/strategy/FileNotFoundAutoFixStrategy.kt +++ b/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/migrate/strategy/FileNotFoundAutoFixStrategy.kt @@ -29,8 +29,9 @@ package com.tencent.bkrepo.job.migrate.strategy import com.tencent.bkrepo.common.artifact.stream.Range import com.tencent.bkrepo.common.metadata.service.file.FileReferenceService +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService import com.tencent.bkrepo.common.mongo.dao.util.sharding.HashShardingUtils.shardingSequenceFor -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.core.StorageService import com.tencent.bkrepo.common.storage.credentials.StorageCredentials import com.tencent.bkrepo.job.SHARDING_COUNT @@ -42,7 +43,6 @@ import com.tencent.bkrepo.job.migrate.dao.MigrateFailedNodeDao import com.tencent.bkrepo.job.migrate.model.TArchiveMigrateFailedNode import com.tencent.bkrepo.job.migrate.model.TMigrateFailedNode import com.tencent.bkrepo.job.migrate.pojo.Node -import com.tencent.bkrepo.repository.api.StorageCredentialsClient import org.slf4j.LoggerFactory import org.springframework.data.mongodb.core.MongoTemplate import org.springframework.data.mongodb.core.query.Criteria @@ -53,7 +53,7 @@ import org.springframework.stereotype.Component @Component class FileNotFoundAutoFixStrategy( private val mongoTemplate: MongoTemplate, - private val storageCredentialsClient: StorageCredentialsClient, + private val storageCredentialService: StorageCredentialService, private val fileReferenceService: FileReferenceService, private val storageService: StorageService, private val storageProperties: StorageProperties, @@ -126,7 +126,7 @@ class FileNotFoundAutoFixStrategy( val repoName = migrateFailedNode.repoName val fullPath = migrateFailedNode.fullPath - val allCredentials = storageCredentialsClient.list().data!! + storageProperties.defaultStorageCredentials() + val allCredentials = storageCredentialService.list() + storageProperties.defaultStorageCredentials() allCredentials.forEach { credentials -> val key = credentials.key try { diff --git a/src/backend/job/biz-job/src/test/kotlin/com/tencent/bkrepo/job/batch/FileReferenceCleanupJobTest.kt b/src/backend/job/biz-job/src/test/kotlin/com/tencent/bkrepo/job/batch/FileReferenceCleanupJobTest.kt index e218b72972..86197987d0 100644 --- a/src/backend/job/biz-job/src/test/kotlin/com/tencent/bkrepo/job/batch/FileReferenceCleanupJobTest.kt +++ b/src/backend/job/biz-job/src/test/kotlin/com/tencent/bkrepo/job/batch/FileReferenceCleanupJobTest.kt @@ -32,6 +32,7 @@ import com.tencent.bkrepo.archive.constant.DEFAULT_KEY import com.tencent.bkrepo.common.artifact.pojo.RepositoryCategory import com.tencent.bkrepo.common.artifact.pojo.RepositoryType import com.tencent.bkrepo.common.artifact.pojo.configuration.local.LocalConfiguration +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService import com.tencent.bkrepo.common.service.util.ResponseBuilder import com.tencent.bkrepo.common.storage.core.StorageService import com.tencent.bkrepo.common.storage.credentials.InnerCosCredentials @@ -43,7 +44,6 @@ import com.tencent.bkrepo.job.config.properties.FileReferenceCleanupJobPropertie import com.tencent.bkrepo.job.repository.JobSnapshotRepository import com.tencent.bkrepo.repository.api.FileReferenceClient import com.tencent.bkrepo.repository.api.RepositoryClient -import com.tencent.bkrepo.repository.api.StorageCredentialsClient import com.tencent.bkrepo.repository.pojo.repo.RepositoryDetail import org.bson.Document import org.junit.jupiter.api.AfterEach @@ -74,7 +74,7 @@ class FileReferenceCleanupJobTest : JobBaseTest() { lateinit var storageService: StorageService @MockBean - lateinit var storageCredentialsClient: StorageCredentialsClient + lateinit var storageCredentialService: StorageCredentialService @MockBean lateinit var archiveClient: ArchiveClient @@ -110,8 +110,8 @@ class FileReferenceCleanupJobTest : JobBaseTest() { fun beforeEach() { Mockito.`when`(storageService.exist(anyString(), any())).thenReturn(true) val credentials = InnerCosCredentials() - Mockito.`when`(storageCredentialsClient.findByKey(anyString())).thenReturn( - ResponseBuilder.success(credentials), + Mockito.`when`(storageCredentialService.findByKey(anyString())).thenReturn( + credentials ) Mockito.`when`(repositoryClient.getRepoDetail(anyString(), anyString(), anyString())).thenReturn( ResponseBuilder.success( diff --git a/src/backend/job/biz-job/src/test/kotlin/com/tencent/bkrepo/job/batch/task/clean/DeletedNodeCleanupJobTest.kt b/src/backend/job/biz-job/src/test/kotlin/com/tencent/bkrepo/job/batch/task/clean/DeletedNodeCleanupJobTest.kt index dae2a7457a..94296fbcf2 100644 --- a/src/backend/job/biz-job/src/test/kotlin/com/tencent/bkrepo/job/batch/task/clean/DeletedNodeCleanupJobTest.kt +++ b/src/backend/job/biz-job/src/test/kotlin/com/tencent/bkrepo/job/batch/task/clean/DeletedNodeCleanupJobTest.kt @@ -1,7 +1,7 @@ package com.tencent.bkrepo.job.batch.task.clean -import com.tencent.bkrepo.common.api.pojo.Response import com.tencent.bkrepo.common.artifact.hash.sha256 +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService import com.tencent.bkrepo.common.mongo.constant.ID import com.tencent.bkrepo.common.mongo.dao.util.sharding.HashShardingUtils import com.tencent.bkrepo.common.storage.credentials.InnerCosCredentials @@ -13,7 +13,6 @@ import com.tencent.bkrepo.job.batch.JobBaseTest import com.tencent.bkrepo.job.batch.context.DeletedNodeCleanupJobContext import com.tencent.bkrepo.job.migrate.MigrateRepoStorageService import com.tencent.bkrepo.job.separation.service.SeparationTaskService -import com.tencent.bkrepo.repository.api.StorageCredentialsClient import org.bson.types.ObjectId import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertNotNull @@ -46,7 +45,7 @@ class DeletedNodeCleanupJobTest @Autowired constructor( private lateinit var migrateRepoStorageService: MigrateRepoStorageService @MockBean - private lateinit var storageCredentialsClient: StorageCredentialsClient + private lateinit var storageCredentialService: StorageCredentialService @MockBean lateinit var separationTaskService: SeparationTaskService @@ -58,11 +57,11 @@ class DeletedNodeCleanupJobTest @Autowired constructor( @BeforeEach fun beforeEach() { - whenever(storageCredentialsClient.list(anyOrNull())).thenReturn( - Response(code = 0, data = emptyList()) + whenever(storageCredentialService.list(anyOrNull())).thenReturn( + emptyList() ) - whenever(storageCredentialsClient.findByKey(anyOrNull())).thenReturn( - Response(code = 0, data = InnerCosCredentials()) + whenever(storageCredentialService.findByKey(anyOrNull())).thenReturn( + InnerCosCredentials() ) whenever(separationTaskService.repoSeparationCheck(anyString(), anyString())) .thenReturn(false) diff --git a/src/backend/job/biz-job/src/test/kotlin/com/tencent/bkrepo/job/batch/task/storage/StorageReconcileJobTest.kt b/src/backend/job/biz-job/src/test/kotlin/com/tencent/bkrepo/job/batch/task/storage/StorageReconcileJobTest.kt index d53ab3a9a2..92da6adb7c 100644 --- a/src/backend/job/biz-job/src/test/kotlin/com/tencent/bkrepo/job/batch/task/storage/StorageReconcileJobTest.kt +++ b/src/backend/job/biz-job/src/test/kotlin/com/tencent/bkrepo/job/batch/task/storage/StorageReconcileJobTest.kt @@ -3,8 +3,8 @@ package com.tencent.bkrepo.job.batch.task.storage import com.tencent.bkrepo.common.artifact.api.ArtifactFile import com.tencent.bkrepo.common.artifact.api.FileSystemArtifactFile import com.tencent.bkrepo.common.metadata.service.file.FileReferenceService -import com.tencent.bkrepo.common.service.util.ResponseBuilder -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.core.StorageService import com.tencent.bkrepo.common.storage.credentials.FileSystemCredentials import com.tencent.bkrepo.common.storage.util.toPath @@ -12,7 +12,6 @@ import com.tencent.bkrepo.job.batch.JobBaseTest import com.tencent.bkrepo.job.batch.utils.NodeCommonUtils import com.tencent.bkrepo.job.migrate.MigrateRepoStorageService import com.tencent.bkrepo.repository.api.RepositoryClient -import com.tencent.bkrepo.repository.api.StorageCredentialsClient import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach @@ -39,7 +38,7 @@ class StorageReconcileJobTest @Autowired constructor( lateinit var migrateRepoStorageService: MigrateRepoStorageService @MockBean - lateinit var storageCredentialsClient: StorageCredentialsClient + lateinit var storageCredentialService: StorageCredentialService @MockBean lateinit var fileReferenceService: FileReferenceService @@ -57,7 +56,7 @@ class StorageReconcileJobTest @Autowired constructor( @BeforeEach fun before() { - `when`(storageCredentialsClient.list(null)).thenReturn(ResponseBuilder.success(emptyList())) + `when`(storageCredentialService.list(null)).thenReturn(emptyList()) } @AfterEach diff --git a/src/backend/job/biz-job/src/test/kotlin/com/tencent/bkrepo/job/migrate/MigrateRepoStorageServiceTest.kt b/src/backend/job/biz-job/src/test/kotlin/com/tencent/bkrepo/job/migrate/MigrateRepoStorageServiceTest.kt index bbe86ec48d..48bf74b73d 100644 --- a/src/backend/job/biz-job/src/test/kotlin/com/tencent/bkrepo/job/migrate/MigrateRepoStorageServiceTest.kt +++ b/src/backend/job/biz-job/src/test/kotlin/com/tencent/bkrepo/job/migrate/MigrateRepoStorageServiceTest.kt @@ -29,9 +29,10 @@ package com.tencent.bkrepo.job.migrate import com.tencent.bkrepo.common.api.exception.ErrorCodeException import com.tencent.bkrepo.common.api.pojo.Response +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService import com.tencent.bkrepo.common.mongo.constant.ID import com.tencent.bkrepo.common.service.actuator.ActuatorConfiguration -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.credentials.FileSystemCredentials import com.tencent.bkrepo.job.UT_PROJECT_ID import com.tencent.bkrepo.job.UT_REPO_NAME @@ -51,7 +52,6 @@ import com.tencent.bkrepo.job.migrate.utils.ExecutingTaskRecorder import com.tencent.bkrepo.job.migrate.utils.MigrateTestUtils.buildRepo import com.tencent.bkrepo.job.migrate.utils.MigrateTestUtils.buildTask import com.tencent.bkrepo.repository.api.RepositoryClient -import com.tencent.bkrepo.repository.api.StorageCredentialsClient import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertFalse import org.junit.jupiter.api.Assertions.assertNotNull @@ -103,7 +103,7 @@ class MigrateRepoStorageServiceTest @Autowired constructor( private lateinit var repositoryClient: RepositoryClient @MockBean - private lateinit var storageCredentialsClient: StorageCredentialsClient + private lateinit var storageCredentialService: StorageCredentialService @MockBean(name = "migrateExecutor") private lateinit var mockMigrateExecutor: TaskExecutor @@ -223,8 +223,8 @@ class MigrateRepoStorageServiceTest @Autowired constructor( whenever(repositoryClient.getRepoDetail(anyString(), anyString(), anyOrNull())).thenReturn( Response(0, "", buildRepo()), ) - whenever(storageCredentialsClient.findByKey(anyString())) - .thenReturn(Response(0, data = FileSystemCredentials())) + whenever(storageCredentialService.findByKey(anyString())) + .thenReturn(FileSystemCredentials()) whenever(mockMigrateExecutor.execute(any())).thenReturn(MigrationContext(buildTask(), null, null)) whenever(mockCorrectExecutor.execute(any())).thenReturn(MigrationContext(buildTask(), null, null)) } diff --git a/src/backend/job/biz-job/src/test/kotlin/com/tencent/bkrepo/job/migrate/executor/ExecutorBaseTest.kt b/src/backend/job/biz-job/src/test/kotlin/com/tencent/bkrepo/job/migrate/executor/ExecutorBaseTest.kt index 5982ba4cbe..59a2c79882 100644 --- a/src/backend/job/biz-job/src/test/kotlin/com/tencent/bkrepo/job/migrate/executor/ExecutorBaseTest.kt +++ b/src/backend/job/biz-job/src/test/kotlin/com/tencent/bkrepo/job/migrate/executor/ExecutorBaseTest.kt @@ -29,8 +29,9 @@ package com.tencent.bkrepo.job.migrate.executor import com.tencent.bkrepo.common.api.pojo.Response import com.tencent.bkrepo.common.metadata.service.file.FileReferenceService +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService import com.tencent.bkrepo.common.mongo.constant.ID -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.core.StorageService import com.tencent.bkrepo.common.storage.credentials.FileSystemCredentials import com.tencent.bkrepo.job.UT_PROJECT_ID @@ -48,7 +49,6 @@ import com.tencent.bkrepo.job.migrate.pojo.MigrationContext import com.tencent.bkrepo.job.migrate.utils.ExecutingTaskRecorder import com.tencent.bkrepo.job.migrate.utils.MigrateTestUtils import com.tencent.bkrepo.repository.api.RepositoryClient -import com.tencent.bkrepo.repository.api.StorageCredentialsClient import org.junit.jupiter.api.TestInstance import org.mockito.ArgumentMatchers.anyString import org.mockito.kotlin.any @@ -105,7 +105,7 @@ open class ExecutorBaseTest { protected lateinit var repositoryClient: RepositoryClient @MockBean - protected lateinit var storageCredentialsClient: StorageCredentialsClient + protected lateinit var storageCredentialService: StorageCredentialService @MockBean protected lateinit var storageService: StorageService @@ -120,8 +120,8 @@ open class ExecutorBaseTest { whenever(repositoryClient.updateStorageCredentialsKey(anyString(), anyString(), anyString())) .thenReturn(Response(0)) whenever(repositoryClient.unsetOldStorageCredentialsKey(anyString(), anyString())).thenReturn(Response(0)) - whenever(storageCredentialsClient.findByKey(anyString())) - .thenReturn(Response(0, data = FileSystemCredentials())) + whenever(storageCredentialService.findByKey(anyString())) + .thenReturn(FileSystemCredentials()) whenever(storageService.copy(anyString(), anyOrNull(), anyOrNull())).then { Thread.sleep(1000L) } diff --git a/src/backend/job/biz-job/src/test/kotlin/com/tencent/bkrepo/job/migrate/strategy/FileNotFoundAutoFixStrategyTest.kt b/src/backend/job/biz-job/src/test/kotlin/com/tencent/bkrepo/job/migrate/strategy/FileNotFoundAutoFixStrategyTest.kt index d9cae89972..cd81e54b13 100644 --- a/src/backend/job/biz-job/src/test/kotlin/com/tencent/bkrepo/job/migrate/strategy/FileNotFoundAutoFixStrategyTest.kt +++ b/src/backend/job/biz-job/src/test/kotlin/com/tencent/bkrepo/job/migrate/strategy/FileNotFoundAutoFixStrategyTest.kt @@ -5,7 +5,8 @@ import com.tencent.bkrepo.common.api.pojo.Response import com.tencent.bkrepo.common.artifact.stream.Range import com.tencent.bkrepo.common.artifact.stream.artifactStream import com.tencent.bkrepo.common.metadata.service.file.FileReferenceService -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.core.StorageService import com.tencent.bkrepo.common.storage.credentials.FileSystemCredentials import com.tencent.bkrepo.job.batch.task.archive.NodeCompressedJob @@ -17,7 +18,6 @@ import com.tencent.bkrepo.job.migrate.utils.MigrateTestUtils.createNode import com.tencent.bkrepo.job.migrate.utils.MigrateTestUtils.insertFailedNode import com.tencent.bkrepo.job.migrate.utils.MigrateTestUtils.removeNodes import com.tencent.bkrepo.repository.api.RepositoryClient -import com.tencent.bkrepo.repository.api.StorageCredentialsClient import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertFalse import org.junit.jupiter.api.Assertions.assertTrue @@ -61,7 +61,7 @@ class FileNotFoundAutoFixStrategyTest @Autowired constructor( repositoryCommonUtils: RepositoryCommonUtils ) { @MockBean - private lateinit var storageCredentialsClient: StorageCredentialsClient + private lateinit var storageCredentialService: StorageCredentialService @MockBean private lateinit var fileReferenceService: FileReferenceService @@ -74,10 +74,10 @@ class FileNotFoundAutoFixStrategyTest @Autowired constructor( @BeforeEach fun beforeEach() { - whenever(storageCredentialsClient.list(anyOrNull())) - .thenReturn(Response(0, data = listOf(FileSystemCredentials()))) - whenever(storageCredentialsClient.findByKey(anyString())) - .thenReturn(Response(0, data = FileSystemCredentials())) + whenever(storageCredentialService.list(anyOrNull())) + .thenReturn(listOf(FileSystemCredentials())) + whenever(storageCredentialService.findByKey(anyString())) + .thenReturn(FileSystemCredentials()) whenever(fileReferenceService.increment(anyString(), anyOrNull(), any())) .thenReturn(true) whenever(repositoryClient.getRepoDetail(anyString(), anyString(), anyOrNull())) diff --git a/src/backend/media/biz-media/src/main/kotlin/com/tencent/bkrepo/media/service/StreamService.kt b/src/backend/media/biz-media/src/main/kotlin/com/tencent/bkrepo/media/service/StreamService.kt index b62d3b53ee..5fe23ae735 100644 --- a/src/backend/media/biz-media/src/main/kotlin/com/tencent/bkrepo/media/service/StreamService.kt +++ b/src/backend/media/biz-media/src/main/kotlin/com/tencent/bkrepo/media/service/StreamService.kt @@ -9,7 +9,7 @@ import com.tencent.bkrepo.common.artifact.repository.context.ArtifactContextHold import com.tencent.bkrepo.common.artifact.repository.context.ArtifactDownloadContext import com.tencent.bkrepo.common.artifact.repository.core.ArtifactService import com.tencent.bkrepo.common.artifact.resolve.file.ArtifactFileFactory -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.media.STREAM_PATH import com.tencent.bkrepo.media.artifact.MediaArtifactInfo import com.tencent.bkrepo.media.config.MediaProperties diff --git a/src/backend/npm-registry/biz-npm-registry/src/main/kotlin/com/tencent/bkrepo/npm/service/NpmPackageService.kt b/src/backend/npm-registry/biz-npm-registry/src/main/kotlin/com/tencent/bkrepo/npm/service/NpmPackageService.kt deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/backend/oci/biz-oci/src/main/kotlin/com/tencent/bkrepo/oci/service/impl/OciOperationServiceImpl.kt b/src/backend/oci/biz-oci/src/main/kotlin/com/tencent/bkrepo/oci/service/impl/OciOperationServiceImpl.kt index 9f742bb596..064ff86ad9 100644 --- a/src/backend/oci/biz-oci/src/main/kotlin/com/tencent/bkrepo/oci/service/impl/OciOperationServiceImpl.kt +++ b/src/backend/oci/biz-oci/src/main/kotlin/com/tencent/bkrepo/oci/service/impl/OciOperationServiceImpl.kt @@ -45,6 +45,7 @@ import com.tencent.bkrepo.common.artifact.repository.context.ArtifactQueryContex import com.tencent.bkrepo.common.artifact.resolve.response.ArtifactChannel import com.tencent.bkrepo.common.artifact.stream.ArtifactInputStream import com.tencent.bkrepo.common.artifact.util.PackageKeys +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService import com.tencent.bkrepo.common.query.enums.OperationType import com.tencent.bkrepo.common.security.util.SecurityUtils import com.tencent.bkrepo.common.service.util.HeaderUtils @@ -98,7 +99,6 @@ import com.tencent.bkrepo.repository.api.NodeClient import com.tencent.bkrepo.repository.api.PackageClient import com.tencent.bkrepo.repository.api.PackageMetadataClient import com.tencent.bkrepo.repository.api.RepositoryClient -import com.tencent.bkrepo.repository.api.StorageCredentialsClient import com.tencent.bkrepo.repository.constant.SYSTEM_USER import com.tencent.bkrepo.repository.pojo.metadata.MetadataModel import com.tencent.bkrepo.repository.pojo.node.NodeDetail @@ -136,7 +136,7 @@ class OciOperationServiceImpl( private val repositoryClient: RepositoryClient, private val ociProperties: OciProperties, private val ociReplicationRecordDao: OciReplicationRecordDao, - private val storageCredentialsClient: StorageCredentialsClient, + private val storageCredentialService: StorageCredentialService, private val pluginManager: PluginManager ) : OciOperationService { @@ -1027,7 +1027,7 @@ class OciOperationServiceImpl( logger.info("$manifestPath has been refreshed, ignore it") return true } - val storageCredentials = repoInfo.storageCredentialsKey?.let { storageCredentialsClient.findByKey(it).data } + val storageCredentials = repoInfo.storageCredentialsKey?.let { storageCredentialService.findByKey(it) } val manifest = loadManifest(manifestNode, storageCredentials) ?: run { logger.warn("The content of manifest.json ${manifestNode.fullPath} is null, check the mediaType.") return false diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/controller/api/BaseCacheHandler.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/controller/api/BaseCacheHandler.kt index b80430b992..f497bb4d4f 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/controller/api/BaseCacheHandler.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/controller/api/BaseCacheHandler.kt @@ -30,16 +30,16 @@ package com.tencent.bkrepo.replication.controller.api import com.google.common.cache.CacheBuilder import com.google.common.cache.CacheLoader import com.google.common.cache.LoadingCache -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.credentials.StorageCredentials -import com.tencent.bkrepo.repository.api.StorageCredentialsClient import org.springframework.stereotype.Component import java.util.concurrent.TimeUnit @Component class BaseCacheHandler( storageProperties: StorageProperties, - private val storageCredentialsClient: StorageCredentialsClient, + private val storageCredentialService: StorageCredentialService, ) { private val defaultCredentials = storageProperties.defaultStorageCredentials() @@ -54,11 +54,11 @@ class BaseCacheHandler( if (storageKey.isNullOrBlank()) { return defaultCredentials } - return storageCredentialsClient.findByKey(storageKey).data ?: defaultCredentials + return storageCredentialService.findByKey(storageKey) ?: defaultCredentials } companion object { private const val MAX_CACHE_COUNT = 10L private const val CACHE_EXPIRE_MINUTES = 5L } -} \ No newline at end of file +} diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/controller/cluster/ClusterBlobReplicaController.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/controller/cluster/ClusterBlobReplicaController.kt index 8a4075544a..04d0890d0f 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/controller/cluster/ClusterBlobReplicaController.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/controller/cluster/ClusterBlobReplicaController.kt @@ -29,12 +29,12 @@ package com.tencent.bkrepo.replication.controller.cluster import com.tencent.bkrepo.common.api.exception.NotFoundException import com.tencent.bkrepo.common.artifact.message.ArtifactMessageCode +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService import com.tencent.bkrepo.common.security.permission.Principal import com.tencent.bkrepo.common.security.permission.PrincipalType import com.tencent.bkrepo.common.storage.core.StorageService import com.tencent.bkrepo.replication.constant.BLOB_PULL_URI import com.tencent.bkrepo.replication.pojo.blob.BlobPullRequest -import com.tencent.bkrepo.repository.api.StorageCredentialsClient import org.springframework.core.io.InputStreamResource import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.PostMapping @@ -47,13 +47,13 @@ import org.springframework.web.bind.annotation.RestController @Principal(type = PrincipalType.ADMIN) class ClusterBlobReplicaController( private val storageService: StorageService, - private val storageCredentialsClient: StorageCredentialsClient + private val storageCredentialService: StorageCredentialService ) { @PostMapping(BLOB_PULL_URI) fun pull(@RequestBody request: BlobPullRequest): ResponseEntity { with(request) { - val credentials = storageCredentialsClient.findByKey(storageKey).data + val credentials = storageCredentialService.findByKey(storageKey) val inputStream = storageService.load(sha256, range, credentials) ?: throw NotFoundException(ArtifactMessageCode.ARTIFACT_DATA_NOT_FOUND) return ResponseEntity.ok(InputStreamResource(inputStream)) diff --git a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/manager/LocalDataManager.kt b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/manager/LocalDataManager.kt index 30464cc40e..a2c810acbe 100644 --- a/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/manager/LocalDataManager.kt +++ b/src/backend/replication/biz-replication/src/main/kotlin/com/tencent/bkrepo/replication/manager/LocalDataManager.kt @@ -37,9 +37,10 @@ import com.tencent.bkrepo.common.artifact.exception.RepoNotFoundException import com.tencent.bkrepo.common.artifact.exception.VersionNotFoundException import com.tencent.bkrepo.common.artifact.path.PathUtils import com.tencent.bkrepo.common.artifact.stream.Range +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService import com.tencent.bkrepo.common.mongo.dao.util.Pages import com.tencent.bkrepo.common.mongo.dao.util.sharding.HashShardingUtils -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.core.StorageService import com.tencent.bkrepo.common.storage.credentials.StorageCredentials import com.tencent.bkrepo.common.storage.pojo.FileInfo @@ -50,7 +51,6 @@ import com.tencent.bkrepo.repository.api.NodeClient import com.tencent.bkrepo.repository.api.PackageClient import com.tencent.bkrepo.repository.api.ProjectClient import com.tencent.bkrepo.repository.api.RepositoryClient -import com.tencent.bkrepo.repository.api.StorageCredentialsClient import com.tencent.bkrepo.repository.constant.SHARDING_COUNT import com.tencent.bkrepo.repository.pojo.metadata.MetadataModel import com.tencent.bkrepo.repository.pojo.node.NodeDetail @@ -82,7 +82,7 @@ class LocalDataManager( private val nodeClient: NodeClient, private val packageClient: PackageClient, private val storageService: StorageService, - private val storageCredentialsClient: StorageCredentialsClient, + private val storageCredentialService: StorageCredentialService, private val storageProperties: StorageProperties, private val mongoTemplate: MongoTemplate, ) { @@ -113,7 +113,7 @@ class LocalDataManager( sha256: String, range: Range, currentStorageCredentials: StorageCredentials? ): InputStream? { - val allCredentials = storageCredentialsClient.list().data!! + storageProperties.defaultStorageCredentials() + val allCredentials = storageCredentialService.list() + storageProperties.defaultStorageCredentials() var result: InputStream? = null for (credential in allCredentials) { val key = credential.key diff --git a/src/backend/replication/biz-replication/src/test/kotlin/com/tencent/bkrepo/replication/fdtp/FdtpAFTTest.kt b/src/backend/replication/biz-replication/src/test/kotlin/com/tencent/bkrepo/replication/fdtp/FdtpAFTTest.kt index 2dcdec5c93..8402ab5397 100644 --- a/src/backend/replication/biz-replication/src/test/kotlin/com/tencent/bkrepo/replication/fdtp/FdtpAFTTest.kt +++ b/src/backend/replication/biz-replication/src/test/kotlin/com/tencent/bkrepo/replication/fdtp/FdtpAFTTest.kt @@ -41,7 +41,7 @@ import com.tencent.bkrepo.common.security.service.ServiceAuthManager import com.tencent.bkrepo.common.security.service.ServiceAuthProperties import com.tencent.bkrepo.common.service.cluster.ClusterInfo import com.tencent.bkrepo.common.service.util.SpringContextUtils -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.monitor.StorageHealthMonitorHelper import com.tencent.bkrepo.fdtp.codec.DefaultFdtpHeaders import com.tencent.bkrepo.fdtp.codec.FdtpResponseStatus diff --git a/src/backend/repository/api-repository/src/main/kotlin/com/tencent/bkrepo/repository/api/StorageCredentialsClient.kt b/src/backend/repository/api-repository/src/main/kotlin/com/tencent/bkrepo/repository/api/StorageCredentialsClient.kt index 78a4eb0675..dd1865da51 100644 --- a/src/backend/repository/api-repository/src/main/kotlin/com/tencent/bkrepo/repository/api/StorageCredentialsClient.kt +++ b/src/backend/repository/api-repository/src/main/kotlin/com/tencent/bkrepo/repository/api/StorageCredentialsClient.kt @@ -44,6 +44,7 @@ import org.springframework.web.bind.annotation.RequestParam */ @FeignClient(REPOSITORY_SERVICE_NAME, contextId = "StorageCredentialsClient", primary = false) @RequestMapping("/service/storage/credentials") +@Deprecated("replace by StorageCredentialsService") interface StorageCredentialsClient { /** diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/service/StorageCredentialsController.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/service/StorageCredentialsController.kt index 49bf3e2512..4b95820329 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/service/StorageCredentialsController.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/service/StorageCredentialsController.kt @@ -32,11 +32,10 @@ package com.tencent.bkrepo.repository.controller.service import com.tencent.bkrepo.common.api.pojo.Response +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService import com.tencent.bkrepo.common.service.util.ResponseBuilder -import com.tencent.bkrepo.common.storage.core.StorageProperties import com.tencent.bkrepo.common.storage.credentials.StorageCredentials import com.tencent.bkrepo.repository.api.StorageCredentialsClient -import com.tencent.bkrepo.repository.service.repo.StorageCredentialService import org.springframework.context.annotation.Primary import org.springframework.web.bind.annotation.RestController @@ -47,14 +46,9 @@ import org.springframework.web.bind.annotation.RestController @Primary class StorageCredentialsController( private val storageCredentialService: StorageCredentialService, - private val storageProperties: StorageProperties ) : StorageCredentialsClient { override fun findByKey(key: String?): Response { - val credentials = if (key.isNullOrBlank()) { - storageProperties.defaultStorageCredentials() - } else { - storageCredentialService.findByKey(key) - } + val credentials = storageCredentialService.findByKey(key) return ResponseBuilder.buildTyped(credentials) } diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/user/UserStorageCredentialsController.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/user/UserStorageCredentialsController.kt index b14679a11b..c64ec60b1a 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/user/UserStorageCredentialsController.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/controller/user/UserStorageCredentialsController.kt @@ -45,7 +45,7 @@ import com.tencent.bkrepo.common.storage.credentials.StorageCredentials import com.tencent.bkrepo.repository.message.RepositoryMessageCode import com.tencent.bkrepo.repository.pojo.credendials.StorageCredentialsCreateRequest import com.tencent.bkrepo.repository.pojo.credendials.StorageCredentialsUpdateRequest -import com.tencent.bkrepo.repository.service.repo.StorageCredentialService +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService import io.swagger.annotations.Api import io.swagger.annotations.ApiOperation import org.springframework.web.bind.annotation.DeleteMapping diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/job/DeletedNodeCleanupJob.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/job/DeletedNodeCleanupJob.kt index aa1b4f72ee..d35980d804 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/job/DeletedNodeCleanupJob.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/job/DeletedNodeCleanupJob.kt @@ -34,10 +34,10 @@ package com.tencent.bkrepo.repository.job import com.tencent.bkrepo.common.service.cluster.properties.ClusterProperties import com.tencent.bkrepo.common.service.log.LoggerHolder import com.tencent.bkrepo.repository.dao.NodeDao -import com.tencent.bkrepo.repository.dao.RepositoryDao +import com.tencent.bkrepo.common.metadata.dao.repo.RepositoryDao import com.tencent.bkrepo.repository.job.base.CenterNodeJob import com.tencent.bkrepo.repository.model.TNode -import com.tencent.bkrepo.repository.model.TRepository +import com.tencent.bkrepo.common.metadata.model.TRepository import com.tencent.bkrepo.common.metadata.service.file.FileReferenceService import org.springframework.data.domain.PageRequest import org.springframework.data.mongodb.core.query.Query diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/job/PackageDownloadsMigrationJob.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/job/PackageDownloadsMigrationJob.kt index c2d72198e1..e4df1cc0f1 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/job/PackageDownloadsMigrationJob.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/job/PackageDownloadsMigrationJob.kt @@ -34,7 +34,7 @@ package com.tencent.bkrepo.repository.job import com.tencent.bkrepo.common.artifact.pojo.RepositoryCategory import com.tencent.bkrepo.common.artifact.pojo.RepositoryType import com.tencent.bkrepo.common.service.log.LoggerHolder -import com.tencent.bkrepo.repository.model.TRepository +import com.tencent.bkrepo.common.metadata.model.TRepository import com.tencent.bkrepo.repository.pojo.download.DownloadsMigrationRequest import com.tencent.bkrepo.repository.pojo.packages.PackageListOption import com.tencent.bkrepo.repository.pojo.packages.PackageSummary diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/job/PackageVersionCorrectionJob.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/job/PackageVersionCorrectionJob.kt index ebcf2cf9e5..33c8fe5c3e 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/job/PackageVersionCorrectionJob.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/job/PackageVersionCorrectionJob.kt @@ -40,7 +40,7 @@ import com.tencent.bkrepo.repository.dao.NodeDao import com.tencent.bkrepo.repository.dao.PackageDao import com.tencent.bkrepo.repository.dao.PackageVersionDao import com.tencent.bkrepo.repository.model.TPackage -import com.tencent.bkrepo.repository.model.TRepository +import com.tencent.bkrepo.common.metadata.model.TRepository import com.tencent.bkrepo.repository.service.packages.PackageService import com.tencent.bkrepo.repository.util.PackageQueryHelper import org.springframework.data.mongodb.core.MongoTemplate diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/job/RepoUsedVolumeSynJob.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/job/RepoUsedVolumeSynJob.kt index 08886709d7..85688ff31c 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/job/RepoUsedVolumeSynJob.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/job/RepoUsedVolumeSynJob.kt @@ -37,7 +37,7 @@ import com.tencent.bkrepo.common.artifact.event.repo.RepoVolumeSyncEvent import com.tencent.bkrepo.common.artifact.message.ArtifactMessageCode import com.tencent.bkrepo.common.artifact.path.PathUtils import com.tencent.bkrepo.common.service.log.LoggerHolder -import com.tencent.bkrepo.repository.model.TRepository +import com.tencent.bkrepo.common.metadata.model.TRepository import com.tencent.bkrepo.repository.service.node.impl.NodeBaseService import org.springframework.context.event.EventListener import org.springframework.data.mongodb.core.query.Query diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/NodeBaseService.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/NodeBaseService.kt index e752d964bc..80a62564e5 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/NodeBaseService.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/NodeBaseService.kt @@ -57,9 +57,9 @@ import com.tencent.bkrepo.common.stream.event.supplier.MessageSupplier import com.tencent.bkrepo.repository.config.RepositoryProperties import com.tencent.bkrepo.repository.constant.SYSTEM_USER import com.tencent.bkrepo.repository.dao.NodeDao -import com.tencent.bkrepo.repository.dao.RepositoryDao +import com.tencent.bkrepo.common.metadata.dao.repo.RepositoryDao import com.tencent.bkrepo.repository.model.TNode -import com.tencent.bkrepo.repository.model.TRepository +import com.tencent.bkrepo.common.metadata.model.TRepository import com.tencent.bkrepo.repository.pojo.metadata.MetadataModel import com.tencent.bkrepo.repository.pojo.node.NodeDetail import com.tencent.bkrepo.repository.pojo.node.NodeInfo @@ -71,7 +71,7 @@ import com.tencent.bkrepo.repository.pojo.node.service.NodeUpdateRequest import com.tencent.bkrepo.common.metadata.service.file.FileReferenceService import com.tencent.bkrepo.repository.service.node.NodeService import com.tencent.bkrepo.repository.service.repo.QuotaService -import com.tencent.bkrepo.repository.service.repo.StorageCredentialService +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService import com.tencent.bkrepo.repository.util.MetadataUtils import com.tencent.bkrepo.repository.util.NodeEventFactory.buildCreatedEvent import com.tencent.bkrepo.repository.util.NodeQueryHelper diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/NodeMoveCopySupport.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/NodeMoveCopySupport.kt index 1a648ffbd4..11af52065b 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/NodeMoveCopySupport.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/NodeMoveCopySupport.kt @@ -45,15 +45,15 @@ import com.tencent.bkrepo.common.storage.core.StorageService import com.tencent.bkrepo.common.storage.credentials.StorageCredentials import com.tencent.bkrepo.repository.constant.DEFAULT_STORAGE_CREDENTIALS_KEY import com.tencent.bkrepo.repository.dao.NodeDao -import com.tencent.bkrepo.repository.dao.RepositoryDao +import com.tencent.bkrepo.common.metadata.dao.repo.RepositoryDao import com.tencent.bkrepo.repository.model.TNode -import com.tencent.bkrepo.repository.model.TRepository +import com.tencent.bkrepo.common.metadata.model.TRepository import com.tencent.bkrepo.repository.pojo.node.NodeDetail import com.tencent.bkrepo.repository.pojo.node.NodeListOption import com.tencent.bkrepo.repository.pojo.node.service.NodeMoveCopyRequest import com.tencent.bkrepo.repository.service.node.NodeMoveCopyOperation import com.tencent.bkrepo.repository.service.repo.QuotaService -import com.tencent.bkrepo.repository.service.repo.StorageCredentialService +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService import com.tencent.bkrepo.repository.util.NodeEventFactory import com.tencent.bkrepo.repository.util.NodeQueryHelper import org.slf4j.LoggerFactory diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/NodeServiceImpl.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/NodeServiceImpl.kt index 34bd563c4d..c3915850a5 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/NodeServiceImpl.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/NodeServiceImpl.kt @@ -37,7 +37,7 @@ import com.tencent.bkrepo.common.storage.core.StorageService import com.tencent.bkrepo.common.stream.event.supplier.MessageSupplier import com.tencent.bkrepo.repository.config.RepositoryProperties import com.tencent.bkrepo.repository.dao.NodeDao -import com.tencent.bkrepo.repository.dao.RepositoryDao +import com.tencent.bkrepo.common.metadata.dao.repo.RepositoryDao import com.tencent.bkrepo.repository.pojo.node.NodeDeleteResult import com.tencent.bkrepo.repository.pojo.node.NodeDeletedPoint import com.tencent.bkrepo.repository.pojo.node.NodeDetail @@ -54,7 +54,7 @@ import com.tencent.bkrepo.repository.pojo.node.service.NodeUnCompressedRequest import com.tencent.bkrepo.repository.pojo.node.service.NodesDeleteRequest import com.tencent.bkrepo.common.metadata.service.file.FileReferenceService import com.tencent.bkrepo.repository.service.repo.QuotaService -import com.tencent.bkrepo.repository.service.repo.StorageCredentialService +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService import com.tencent.bkrepo.router.api.RouterControllerClient import org.springframework.context.annotation.Conditional import org.springframework.data.mongodb.core.query.Criteria diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/center/CommitEdgeCenterNodeServiceImpl.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/center/CommitEdgeCenterNodeServiceImpl.kt index 80785959e3..97ae6c87ba 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/center/CommitEdgeCenterNodeServiceImpl.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/center/CommitEdgeCenterNodeServiceImpl.kt @@ -43,10 +43,10 @@ import com.tencent.bkrepo.common.storage.core.StorageService import com.tencent.bkrepo.common.stream.event.supplier.MessageSupplier import com.tencent.bkrepo.repository.config.RepositoryProperties import com.tencent.bkrepo.repository.dao.NodeDao -import com.tencent.bkrepo.repository.dao.RepositoryDao +import com.tencent.bkrepo.common.metadata.dao.repo.RepositoryDao import com.tencent.bkrepo.repository.model.TMetadata import com.tencent.bkrepo.repository.model.TNode -import com.tencent.bkrepo.repository.model.TRepository +import com.tencent.bkrepo.common.metadata.model.TRepository import com.tencent.bkrepo.repository.pojo.metadata.MetadataModel import com.tencent.bkrepo.repository.pojo.node.NodeDeleteResult import com.tencent.bkrepo.repository.pojo.node.NodeDetail @@ -60,7 +60,7 @@ import com.tencent.bkrepo.common.metadata.service.file.FileReferenceService import com.tencent.bkrepo.repository.service.node.impl.NodeRestoreSupport import com.tencent.bkrepo.repository.service.node.impl.NodeServiceImpl import com.tencent.bkrepo.repository.service.repo.QuotaService -import com.tencent.bkrepo.repository.service.repo.StorageCredentialService +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService import com.tencent.bkrepo.repository.util.NodeQueryHelper import com.tencent.bkrepo.router.api.RouterControllerClient import org.slf4j.LoggerFactory diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/edge/EdgeNodeBaseService.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/edge/EdgeNodeBaseService.kt index 083e442d95..cde90cae4c 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/edge/EdgeNodeBaseService.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/edge/EdgeNodeBaseService.kt @@ -38,7 +38,7 @@ import com.tencent.bkrepo.common.stream.event.supplier.MessageSupplier import com.tencent.bkrepo.repository.api.cluster.ClusterNodeClient import com.tencent.bkrepo.repository.config.RepositoryProperties import com.tencent.bkrepo.repository.dao.NodeDao -import com.tencent.bkrepo.repository.dao.RepositoryDao +import com.tencent.bkrepo.common.metadata.dao.repo.RepositoryDao import com.tencent.bkrepo.repository.model.TNode import com.tencent.bkrepo.repository.pojo.node.NodeDetail import com.tencent.bkrepo.repository.pojo.node.service.NodeCreateRequest @@ -47,7 +47,7 @@ import com.tencent.bkrepo.repository.pojo.node.service.NodeUpdateRequest import com.tencent.bkrepo.common.metadata.service.file.FileReferenceService import com.tencent.bkrepo.repository.service.node.impl.NodeBaseService import com.tencent.bkrepo.repository.service.repo.QuotaService -import com.tencent.bkrepo.repository.service.repo.StorageCredentialService +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService import com.tencent.bkrepo.router.api.RouterControllerClient abstract class EdgeNodeBaseService( diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/edge/EdgeNodeServiceImpl.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/edge/EdgeNodeServiceImpl.kt index da8ea2361b..b49ab9af4c 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/edge/EdgeNodeServiceImpl.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/node/impl/edge/EdgeNodeServiceImpl.kt @@ -41,7 +41,7 @@ import com.tencent.bkrepo.common.storage.core.StorageService import com.tencent.bkrepo.common.stream.event.supplier.MessageSupplier import com.tencent.bkrepo.repository.config.RepositoryProperties import com.tencent.bkrepo.repository.dao.NodeDao -import com.tencent.bkrepo.repository.dao.RepositoryDao +import com.tencent.bkrepo.common.metadata.dao.repo.RepositoryDao import com.tencent.bkrepo.repository.pojo.node.NodeDeleteResult import com.tencent.bkrepo.repository.pojo.node.NodeDeletedPoint import com.tencent.bkrepo.repository.pojo.node.NodeDetail @@ -66,7 +66,7 @@ import com.tencent.bkrepo.repository.service.node.impl.NodeRenameSupport import com.tencent.bkrepo.repository.service.node.impl.NodeRestoreSupport import com.tencent.bkrepo.repository.service.node.impl.NodeStatsSupport import com.tencent.bkrepo.repository.service.repo.QuotaService -import com.tencent.bkrepo.repository.service.repo.StorageCredentialService +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService import com.tencent.bkrepo.router.api.RouterControllerClient import org.springframework.context.annotation.Conditional import org.springframework.data.mongodb.core.query.Criteria diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/PackageBaseService.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/PackageBaseService.kt index b423afbf9b..434018122b 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/PackageBaseService.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/PackageBaseService.kt @@ -31,11 +31,11 @@ import com.tencent.bkrepo.common.api.exception.ErrorCodeException import com.tencent.bkrepo.common.artifact.message.ArtifactMessageCode import com.tencent.bkrepo.common.artifact.util.version.SemVersion import com.tencent.bkrepo.repository.dao.PackageDao -import com.tencent.bkrepo.repository.dao.RepositoryDao +import com.tencent.bkrepo.common.metadata.dao.repo.RepositoryDao import com.tencent.bkrepo.repository.model.ClusterResource import com.tencent.bkrepo.repository.model.TPackage import com.tencent.bkrepo.repository.model.TPackageVersion -import com.tencent.bkrepo.repository.model.TRepository +import com.tencent.bkrepo.common.metadata.model.TRepository import com.tencent.bkrepo.repository.pojo.packages.request.PackagePopulateRequest import com.tencent.bkrepo.repository.pojo.packages.request.PackageVersionCreateRequest import com.tencent.bkrepo.repository.pojo.packages.request.PopulatedPackageVersion diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/PackageServiceImpl.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/PackageServiceImpl.kt index 12f9186952..53ba63700d 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/PackageServiceImpl.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/PackageServiceImpl.kt @@ -48,7 +48,7 @@ import com.tencent.bkrepo.common.service.util.HttpContextHolder import com.tencent.bkrepo.common.service.util.SpringContextUtils.Companion.publishEvent import com.tencent.bkrepo.repository.dao.PackageDao import com.tencent.bkrepo.repository.dao.PackageVersionDao -import com.tencent.bkrepo.repository.dao.RepositoryDao +import com.tencent.bkrepo.common.metadata.dao.repo.RepositoryDao import com.tencent.bkrepo.repository.model.TPackage import com.tencent.bkrepo.repository.model.TPackageVersion import com.tencent.bkrepo.repository.pojo.packages.PackageListOption diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/center/CommitEdgeCenterPackageServiceImpl.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/center/CommitEdgeCenterPackageServiceImpl.kt index 1c52b926d4..b2ef3ec1a9 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/center/CommitEdgeCenterPackageServiceImpl.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/center/CommitEdgeCenterPackageServiceImpl.kt @@ -35,11 +35,11 @@ import com.tencent.bkrepo.common.service.cluster.properties.ClusterProperties import com.tencent.bkrepo.common.service.cluster.condition.CommitEdgeCenterPackageCondition import com.tencent.bkrepo.repository.dao.PackageDao import com.tencent.bkrepo.repository.dao.PackageVersionDao -import com.tencent.bkrepo.repository.dao.RepositoryDao +import com.tencent.bkrepo.common.metadata.dao.repo.RepositoryDao import com.tencent.bkrepo.repository.model.ClusterResource import com.tencent.bkrepo.repository.model.TPackage import com.tencent.bkrepo.repository.model.TPackageVersion -import com.tencent.bkrepo.repository.model.TRepository +import com.tencent.bkrepo.common.metadata.model.TRepository import com.tencent.bkrepo.repository.pojo.packages.request.PackagePopulateRequest import com.tencent.bkrepo.repository.pojo.packages.request.PackageVersionCreateRequest import com.tencent.bkrepo.repository.pojo.packages.request.PopulatedPackageVersion diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/edge/EdgePackageServiceImpl.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/edge/EdgePackageServiceImpl.kt index 7dcf4039a8..1e70bf47c8 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/edge/EdgePackageServiceImpl.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/packages/impl/edge/EdgePackageServiceImpl.kt @@ -33,7 +33,7 @@ import com.tencent.bkrepo.common.service.feign.FeignClientFactory import com.tencent.bkrepo.repository.api.cluster.ClusterPackageClient import com.tencent.bkrepo.repository.dao.PackageDao import com.tencent.bkrepo.repository.dao.PackageVersionDao -import com.tencent.bkrepo.repository.dao.RepositoryDao +import com.tencent.bkrepo.common.metadata.dao.repo.RepositoryDao import com.tencent.bkrepo.repository.pojo.packages.request.PackageUpdateRequest import com.tencent.bkrepo.repository.pojo.packages.request.PackageVersionCreateRequest import com.tencent.bkrepo.repository.pojo.packages.request.PackageVersionUpdateRequest diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/ProjectServiceImpl.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/ProjectServiceImpl.kt index 945c513fb5..77f769233a 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/ProjectServiceImpl.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/ProjectServiceImpl.kt @@ -56,7 +56,7 @@ import com.tencent.bkrepo.repository.pojo.project.ProjectRangeQueryRequest import com.tencent.bkrepo.repository.pojo.project.ProjectSearchOption import com.tencent.bkrepo.repository.pojo.project.ProjectUpdateRequest import com.tencent.bkrepo.repository.service.repo.ProjectService -import com.tencent.bkrepo.repository.service.repo.StorageCredentialService +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService import com.tencent.bkrepo.repository.util.ProjectEventFactory.buildCreatedEvent import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/QuotaServiceImpl.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/QuotaServiceImpl.kt index be025fd7fe..bbdc5479ae 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/QuotaServiceImpl.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/QuotaServiceImpl.kt @@ -35,8 +35,8 @@ import com.tencent.bkrepo.common.api.exception.ErrorCodeException import com.tencent.bkrepo.common.api.util.HumanReadable import com.tencent.bkrepo.common.artifact.event.repo.RepoVolumeSyncEvent import com.tencent.bkrepo.common.artifact.message.ArtifactMessageCode -import com.tencent.bkrepo.repository.dao.RepositoryDao -import com.tencent.bkrepo.repository.model.TRepository +import com.tencent.bkrepo.common.metadata.dao.repo.RepositoryDao +import com.tencent.bkrepo.common.metadata.model.TRepository import com.tencent.bkrepo.repository.pojo.repo.RepoQuotaInfo import com.tencent.bkrepo.repository.service.repo.QuotaService import org.springframework.context.ApplicationEventPublisher diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/RepositoryServiceImpl.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/RepositoryServiceImpl.kt index 3be0f263e6..d86365a538 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/RepositoryServiceImpl.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/RepositoryServiceImpl.kt @@ -50,7 +50,10 @@ import com.tencent.bkrepo.common.artifact.pojo.configuration.local.LocalConfigur import com.tencent.bkrepo.common.artifact.pojo.configuration.remote.RemoteConfiguration import com.tencent.bkrepo.common.artifact.pojo.configuration.virtual.VirtualConfiguration import com.tencent.bkrepo.common.metadata.constant.FAKE_SHA256 +import com.tencent.bkrepo.common.metadata.dao.repo.RepositoryDao +import com.tencent.bkrepo.common.metadata.model.TRepository import com.tencent.bkrepo.common.metadata.service.repo.ProxyChannelService +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService import com.tencent.bkrepo.common.mongo.dao.AbstractMongoDao.Companion.ID import com.tencent.bkrepo.common.mongo.dao.util.Pages import com.tencent.bkrepo.common.security.util.RsaUtils @@ -60,9 +63,7 @@ import com.tencent.bkrepo.common.service.util.SpringContextUtils.Companion.publi import com.tencent.bkrepo.common.storage.credentials.StorageCredentials import com.tencent.bkrepo.common.stream.event.supplier.MessageSupplier import com.tencent.bkrepo.repository.config.RepositoryProperties -import com.tencent.bkrepo.repository.dao.RepositoryDao import com.tencent.bkrepo.repository.model.TNode -import com.tencent.bkrepo.repository.model.TRepository import com.tencent.bkrepo.repository.pojo.node.NodeSizeInfo import com.tencent.bkrepo.repository.pojo.project.RepoRangeQueryRequest import com.tencent.bkrepo.repository.pojo.proxy.ProxyChannelCreateRequest @@ -79,7 +80,6 @@ import com.tencent.bkrepo.repository.service.node.NodeService import com.tencent.bkrepo.repository.service.packages.PackageService import com.tencent.bkrepo.repository.service.repo.ProjectService import com.tencent.bkrepo.repository.service.repo.RepositoryService -import com.tencent.bkrepo.repository.service.repo.StorageCredentialService import com.tencent.bkrepo.repository.util.RepoEventFactory.buildCreatedEvent import com.tencent.bkrepo.repository.util.RepoEventFactory.buildDeletedEvent import com.tencent.bkrepo.repository.util.RepoEventFactory.buildUpdatedEvent diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/SoftwareRepositoryServiceImpl.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/SoftwareRepositoryServiceImpl.kt index ccc8279765..219d0bf9c7 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/SoftwareRepositoryServiceImpl.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/SoftwareRepositoryServiceImpl.kt @@ -6,8 +6,8 @@ import com.tencent.bkrepo.common.artifact.constant.PUBLIC_PROXY_PROJECT import com.tencent.bkrepo.common.artifact.pojo.RepositoryCategory import com.tencent.bkrepo.common.artifact.pojo.RepositoryType import com.tencent.bkrepo.common.mongo.dao.util.Pages -import com.tencent.bkrepo.repository.dao.RepositoryDao -import com.tencent.bkrepo.repository.model.TRepository +import com.tencent.bkrepo.common.metadata.dao.repo.RepositoryDao +import com.tencent.bkrepo.common.metadata.model.TRepository import com.tencent.bkrepo.repository.pojo.repo.RepositoryInfo import com.tencent.bkrepo.repository.service.repo.SoftwareRepositoryService import org.springframework.data.domain.Sort diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/center/CommitEdgeCenterProjectServiceImpl.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/center/CommitEdgeCenterProjectServiceImpl.kt index 5fd76e452b..3d692bef46 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/center/CommitEdgeCenterProjectServiceImpl.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/center/CommitEdgeCenterProjectServiceImpl.kt @@ -32,7 +32,7 @@ import com.tencent.bkrepo.auth.api.ServicePermissionClient import com.tencent.bkrepo.common.service.cluster.condition.CommitEdgeCenterCondition import com.tencent.bkrepo.repository.dao.ProjectDao import com.tencent.bkrepo.repository.dao.repository.ProjectMetricsRepository -import com.tencent.bkrepo.repository.service.repo.StorageCredentialService +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService import com.tencent.bkrepo.repository.service.repo.impl.ProjectServiceImpl import org.springframework.context.annotation.Conditional import org.springframework.stereotype.Service diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/center/CommitEdgeCenterRepositoryServiceImpl.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/center/CommitEdgeCenterRepositoryServiceImpl.kt index ad43a2816c..e93eabcbd1 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/center/CommitEdgeCenterRepositoryServiceImpl.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/center/CommitEdgeCenterRepositoryServiceImpl.kt @@ -37,7 +37,11 @@ import com.tencent.bkrepo.common.artifact.pojo.RepositoryType import com.tencent.bkrepo.common.artifact.pojo.configuration.RepositoryConfiguration import com.tencent.bkrepo.common.artifact.pojo.configuration.composite.CompositeConfiguration import com.tencent.bkrepo.common.artifact.util.ClusterUtils +import com.tencent.bkrepo.common.metadata.dao.repo.RepositoryDao +import com.tencent.bkrepo.common.metadata.model.TRepository import com.tencent.bkrepo.common.metadata.service.repo.ProxyChannelService +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService +import com.tencent.bkrepo.common.metadata.util.RepoQueryHelper import com.tencent.bkrepo.common.mongo.dao.AbstractMongoDao import com.tencent.bkrepo.common.security.util.SecurityUtils import com.tencent.bkrepo.common.service.cluster.condition.CommitEdgeCenterCondition @@ -45,14 +49,11 @@ import com.tencent.bkrepo.common.service.cluster.properties.ClusterProperties import com.tencent.bkrepo.common.service.util.SpringContextUtils import com.tencent.bkrepo.common.stream.event.supplier.MessageSupplier import com.tencent.bkrepo.repository.config.RepositoryProperties -import com.tencent.bkrepo.repository.dao.RepositoryDao -import com.tencent.bkrepo.repository.model.TRepository import com.tencent.bkrepo.repository.pojo.repo.RepoCreateRequest import com.tencent.bkrepo.repository.pojo.repo.RepoDeleteRequest import com.tencent.bkrepo.repository.pojo.repo.RepositoryDetail import com.tencent.bkrepo.repository.service.node.NodeService import com.tencent.bkrepo.repository.service.repo.ProjectService -import com.tencent.bkrepo.repository.service.repo.StorageCredentialService import com.tencent.bkrepo.repository.service.repo.impl.RepositoryServiceImpl import com.tencent.bkrepo.repository.util.RepoEventFactory import org.slf4j.LoggerFactory @@ -72,7 +73,7 @@ class CommitEdgeCenterRepositoryServiceImpl( projectService: ProjectService, storageCredentialService: StorageCredentialService, proxyChannelService: ProxyChannelService, - private val repositoryProperties: RepositoryProperties, + repositoryProperties: RepositoryProperties, messageSupplier: MessageSupplier, servicePermissionClient: ServicePermissionClient, private val clusterProperties: ClusterProperties, @@ -121,7 +122,7 @@ class CommitEdgeCenterRepositoryServiceImpl( return super.createRepo(repoCreateRequest) } - val query = repositoryDao.buildSingleQuery(projectId, name, type.name) + val query = RepoQueryHelper.buildSingleQuery(projectId, name, type.name) val clusterNames = exitRepo.clusterNames.orEmpty().toMutableSet() if (clusterNames.isEmpty()) { clusterNames.add(clusterProperties.self.name.toString()) diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/edge/EdgeProjectServiceImpl.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/edge/EdgeProjectServiceImpl.kt index ed3f680cd1..4ff4a77fe6 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/edge/EdgeProjectServiceImpl.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/edge/EdgeProjectServiceImpl.kt @@ -40,7 +40,7 @@ import com.tencent.bkrepo.repository.dao.ProjectDao import com.tencent.bkrepo.repository.dao.repository.ProjectMetricsRepository import com.tencent.bkrepo.repository.pojo.project.ProjectCreateRequest import com.tencent.bkrepo.repository.pojo.project.ProjectInfo -import com.tencent.bkrepo.repository.service.repo.StorageCredentialService +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService import com.tencent.bkrepo.repository.service.repo.impl.ProjectServiceImpl import org.springframework.context.annotation.Conditional import org.springframework.stereotype.Service diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/edge/EdgeRepositoryServiceImpl.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/edge/EdgeRepositoryServiceImpl.kt index b02de16b77..872b032ad3 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/edge/EdgeRepositoryServiceImpl.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/service/repo/impl/edge/EdgeRepositoryServiceImpl.kt @@ -30,7 +30,9 @@ package com.tencent.bkrepo.repository.service.repo.impl.edge import com.tencent.bkrepo.auth.api.ServicePermissionClient import com.tencent.bkrepo.common.artifact.message.ArtifactMessageCode import com.tencent.bkrepo.common.artifact.util.ClusterUtils.reportMetadataToCenter +import com.tencent.bkrepo.common.metadata.dao.repo.RepositoryDao import com.tencent.bkrepo.common.metadata.service.repo.ProxyChannelService +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService import com.tencent.bkrepo.common.service.cluster.condition.CommitEdgeEdgeCondition import com.tencent.bkrepo.common.service.cluster.properties.ClusterProperties import com.tencent.bkrepo.common.service.exception.RemoteErrorCodeException @@ -38,14 +40,12 @@ import com.tencent.bkrepo.common.service.feign.FeignClientFactory import com.tencent.bkrepo.common.stream.event.supplier.MessageSupplier import com.tencent.bkrepo.repository.api.cluster.ClusterRepositoryClient import com.tencent.bkrepo.repository.config.RepositoryProperties -import com.tencent.bkrepo.repository.dao.RepositoryDao import com.tencent.bkrepo.repository.pojo.repo.RepoCreateRequest import com.tencent.bkrepo.repository.pojo.repo.RepoDeleteRequest import com.tencent.bkrepo.repository.pojo.repo.RepoUpdateRequest import com.tencent.bkrepo.repository.pojo.repo.RepositoryDetail import com.tencent.bkrepo.repository.service.node.NodeService import com.tencent.bkrepo.repository.service.repo.ProjectService -import com.tencent.bkrepo.repository.service.repo.StorageCredentialService import com.tencent.bkrepo.repository.service.repo.impl.RepositoryServiceImpl import org.springframework.context.annotation.Conditional import org.springframework.stereotype.Service diff --git a/src/backend/repository/biz-repository/src/test/kotlin/com/tencent/bkrepo/repository/service/FileReferenceServiceTest.kt b/src/backend/repository/biz-repository/src/test/kotlin/com/tencent/bkrepo/repository/service/FileReferenceServiceTest.kt index da7303a01d..490d587134 100644 --- a/src/backend/repository/biz-repository/src/test/kotlin/com/tencent/bkrepo/repository/service/FileReferenceServiceTest.kt +++ b/src/backend/repository/biz-repository/src/test/kotlin/com/tencent/bkrepo/repository/service/FileReferenceServiceTest.kt @@ -46,7 +46,7 @@ import com.tencent.bkrepo.common.metadata.service.file.FileReferenceService import com.tencent.bkrepo.repository.service.node.NodeService import com.tencent.bkrepo.repository.service.repo.ProjectService import com.tencent.bkrepo.repository.service.repo.RepositoryService -import com.tencent.bkrepo.repository.service.repo.StorageCredentialService +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertFalse import org.junit.jupiter.api.Assertions.assertThrows diff --git a/src/backend/repository/biz-repository/src/test/kotlin/com/tencent/bkrepo/repository/service/ProjectServiceTest.kt b/src/backend/repository/biz-repository/src/test/kotlin/com/tencent/bkrepo/repository/service/ProjectServiceTest.kt index 60166b3cf0..97190eed52 100644 --- a/src/backend/repository/biz-repository/src/test/kotlin/com/tencent/bkrepo/repository/service/ProjectServiceTest.kt +++ b/src/backend/repository/biz-repository/src/test/kotlin/com/tencent/bkrepo/repository/service/ProjectServiceTest.kt @@ -46,7 +46,7 @@ import com.tencent.bkrepo.repository.pojo.project.ProjectMetadata import com.tencent.bkrepo.repository.pojo.project.ProjectRangeQueryRequest import com.tencent.bkrepo.repository.pojo.project.ProjectUpdateRequest import com.tencent.bkrepo.repository.service.repo.ProjectService -import com.tencent.bkrepo.repository.service.repo.StorageCredentialService +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.BeforeEach diff --git a/src/backend/repository/biz-repository/src/test/kotlin/com/tencent/bkrepo/repository/service/RepositoryServiceTest.kt b/src/backend/repository/biz-repository/src/test/kotlin/com/tencent/bkrepo/repository/service/RepositoryServiceTest.kt index 897549558f..1d083e3c0d 100644 --- a/src/backend/repository/biz-repository/src/test/kotlin/com/tencent/bkrepo/repository/service/RepositoryServiceTest.kt +++ b/src/backend/repository/biz-repository/src/test/kotlin/com/tencent/bkrepo/repository/service/RepositoryServiceTest.kt @@ -59,7 +59,7 @@ import com.tencent.bkrepo.repository.service.node.NodeService import com.tencent.bkrepo.repository.service.repo.ProjectService import com.tencent.bkrepo.common.metadata.service.repo.ProxyChannelService import com.tencent.bkrepo.repository.service.repo.RepositoryService -import com.tencent.bkrepo.repository.service.repo.StorageCredentialService +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertFalse import org.junit.jupiter.api.Assertions.assertNotNull diff --git a/src/backend/repository/biz-repository/src/test/kotlin/com/tencent/bkrepo/repository/service/ServiceBaseTest.kt b/src/backend/repository/biz-repository/src/test/kotlin/com/tencent/bkrepo/repository/service/ServiceBaseTest.kt index e395e99e2d..e25faf9d26 100644 --- a/src/backend/repository/biz-repository/src/test/kotlin/com/tencent/bkrepo/repository/service/ServiceBaseTest.kt +++ b/src/backend/repository/biz-repository/src/test/kotlin/com/tencent/bkrepo/repository/service/ServiceBaseTest.kt @@ -43,13 +43,15 @@ import com.tencent.bkrepo.common.artifact.pojo.RepositoryCategory import com.tencent.bkrepo.common.artifact.pojo.RepositoryType import com.tencent.bkrepo.common.artifact.pojo.configuration.local.LocalConfiguration import com.tencent.bkrepo.common.artifact.router.RouterControllerProperties +import com.tencent.bkrepo.common.metadata.dao.repo.RepositoryDao +import com.tencent.bkrepo.common.metadata.util.StorageCredentialHelper import com.tencent.bkrepo.common.security.http.core.HttpAuthProperties import com.tencent.bkrepo.common.security.manager.PermissionManager import com.tencent.bkrepo.common.security.manager.ci.CIPermissionManager import com.tencent.bkrepo.common.service.cluster.properties.ClusterProperties import com.tencent.bkrepo.common.service.util.ResponseBuilder import com.tencent.bkrepo.common.service.util.SpringContextUtils -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.core.StorageService import com.tencent.bkrepo.common.stream.event.supplier.MessageSupplier import com.tencent.bkrepo.repository.UT_PROJECT_ID @@ -60,7 +62,6 @@ import com.tencent.bkrepo.repository.UT_USER import com.tencent.bkrepo.repository.config.RepositoryProperties import com.tencent.bkrepo.repository.dao.NodeDao import com.tencent.bkrepo.repository.dao.ProjectDao -import com.tencent.bkrepo.repository.dao.RepositoryDao import com.tencent.bkrepo.repository.listener.ResourcePermissionListener import com.tencent.bkrepo.repository.pojo.project.ProjectCreateRequest import com.tencent.bkrepo.repository.pojo.project.ProjectInfo @@ -136,6 +137,9 @@ open class ServiceBaseTest { @MockBean lateinit var archiveClient: ArchiveClient + @Autowired + lateinit var storageCredentialHelper: StorageCredentialHelper + fun initMock() { val tracer = mockk() diff --git a/src/backend/repository/biz-repository/src/test/kotlin/com/tencent/bkrepo/repository/service/StorageCredentialServiceTest.kt b/src/backend/repository/biz-repository/src/test/kotlin/com/tencent/bkrepo/repository/service/StorageCredentialServiceTest.kt index 36e3edef8e..09152f2cf3 100644 --- a/src/backend/repository/biz-repository/src/test/kotlin/com/tencent/bkrepo/repository/service/StorageCredentialServiceTest.kt +++ b/src/backend/repository/biz-repository/src/test/kotlin/com/tencent/bkrepo/repository/service/StorageCredentialServiceTest.kt @@ -34,20 +34,19 @@ package com.tencent.bkrepo.repository.service import com.tencent.bkrepo.common.api.exception.BadRequestException import com.tencent.bkrepo.common.api.exception.ErrorCodeException import com.tencent.bkrepo.common.api.exception.NotFoundException +import com.tencent.bkrepo.common.metadata.dao.repo.StorageCredentialsDao +import com.tencent.bkrepo.common.metadata.service.repo.StorageCredentialService import com.tencent.bkrepo.common.storage.credentials.FileSystemCredentials import com.tencent.bkrepo.common.storage.credentials.InnerCosCredentials import com.tencent.bkrepo.common.storage.credentials.StorageCredentials import com.tencent.bkrepo.repository.UT_REGION import com.tencent.bkrepo.repository.UT_STORAGE_CREDENTIALS_KEY import com.tencent.bkrepo.repository.UT_USER -import com.tencent.bkrepo.common.metadata.dao.file.FileReferenceDao import com.tencent.bkrepo.repository.dao.NodeDao -import com.tencent.bkrepo.repository.dao.repository.StorageCredentialsRepository import com.tencent.bkrepo.repository.pojo.credendials.StorageCredentialsCreateRequest import com.tencent.bkrepo.repository.pojo.credendials.StorageCredentialsUpdateRequest import com.tencent.bkrepo.repository.service.repo.ProjectService import com.tencent.bkrepo.repository.service.repo.RepositoryService -import com.tencent.bkrepo.repository.service.repo.StorageCredentialService import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.BeforeEach @@ -57,21 +56,23 @@ import org.junit.jupiter.api.assertThrows import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest import org.springframework.context.annotation.Import +import org.springframework.data.mongodb.core.query.Query import java.time.Duration -@Import(NodeDao::class, FileReferenceDao::class) +@Import(NodeDao::class) @DisplayName("存储身份凭证服务测试") @DataMongoTest internal class StorageCredentialServiceTest @Autowired constructor( private val storageCredentialService: StorageCredentialService, - private val storageCredentialsRepository: StorageCredentialsRepository, + private val storageCredentialsDao: StorageCredentialsDao, private val projectService: ProjectService, - private val repositoryService: RepositoryService + private val repositoryService: RepositoryService, +// private val storageCredentialHelper: StorageCredentialHelper ) : ServiceBaseTest() { @BeforeEach fun beforeEach() { - storageCredentialsRepository.deleteAll() + storageCredentialsDao.remove(Query()) } @Test diff --git a/src/backend/s3/biz-s3/src/main/kotlin/com/tencent/bkrepo/s3/artifact/configuration/ResourceWriterConfigurer.kt b/src/backend/s3/biz-s3/src/main/kotlin/com/tencent/bkrepo/s3/artifact/configuration/ResourceWriterConfigurer.kt index c2368ec503..402419b406 100644 --- a/src/backend/s3/biz-s3/src/main/kotlin/com/tencent/bkrepo/s3/artifact/configuration/ResourceWriterConfigurer.kt +++ b/src/backend/s3/biz-s3/src/main/kotlin/com/tencent/bkrepo/s3/artifact/configuration/ResourceWriterConfigurer.kt @@ -32,7 +32,7 @@ package com.tencent.bkrepo.s3.artifact.configuration import com.tencent.bkrepo.common.artifact.resolve.response.ArtifactResourceWriter -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.s3.artifact.response.S3ArtifactResourceWriter import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration diff --git a/src/backend/s3/biz-s3/src/main/kotlin/com/tencent/bkrepo/s3/artifact/response/S3ArtifactResourceWriter.kt b/src/backend/s3/biz-s3/src/main/kotlin/com/tencent/bkrepo/s3/artifact/response/S3ArtifactResourceWriter.kt index 18ed0b19b6..7c9eec2736 100644 --- a/src/backend/s3/biz-s3/src/main/kotlin/com/tencent/bkrepo/s3/artifact/response/S3ArtifactResourceWriter.kt +++ b/src/backend/s3/biz-s3/src/main/kotlin/com/tencent/bkrepo/s3/artifact/response/S3ArtifactResourceWriter.kt @@ -39,7 +39,7 @@ import com.tencent.bkrepo.common.artifact.resolve.response.AbstractArtifactResou import com.tencent.bkrepo.common.artifact.resolve.response.ArtifactResource import com.tencent.bkrepo.common.artifact.stream.Range import com.tencent.bkrepo.common.service.util.HttpContextHolder -import com.tencent.bkrepo.common.storage.core.StorageProperties +import com.tencent.bkrepo.common.storage.config.StorageProperties import com.tencent.bkrepo.common.storage.monitor.Throughput import com.tencent.bkrepo.repository.pojo.node.NodeDetail import com.tencent.bkrepo.s3.artifact.utils.ContextUtil