From d3ed7b7d0dfc39805ec5a7e2eb3da9460f4cfe38 Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Mon, 21 Oct 2024 11:34:01 +0200 Subject: [PATCH] renamed from defaultPublicRepository to defaultCommunityRegistry Signed-off-by: munishchouhan --- .../auth/RegistryCredentialsProviderImpl.groovy | 4 ++-- .../seqera/wave/configuration/BuildConfig.groovy | 4 ++-- .../wave/controller/ContainerController.groovy | 16 ++++++++-------- .../validation/ValidationServiceImpl.groovy | 2 +- .../controller/ContainerControllerTest.groovy | 4 ++-- .../validation/ValidationServiceTest.groovy | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/main/groovy/io/seqera/wave/auth/RegistryCredentialsProviderImpl.groovy b/src/main/groovy/io/seqera/wave/auth/RegistryCredentialsProviderImpl.groovy index e422eceed..c67d19eeb 100644 --- a/src/main/groovy/io/seqera/wave/auth/RegistryCredentialsProviderImpl.groovy +++ b/src/main/groovy/io/seqera/wave/auth/RegistryCredentialsProviderImpl.groovy @@ -113,10 +113,10 @@ class RegistryCredentialsProviderImpl implements RegistryCredentialsProvider { throw new IllegalArgumentException("Missing required parameter userId -- Unable to retrieve credentials for container repository '$container'") // use default credentials for default repositories - // NOTE: this requires that 'defaultBuildRepository', 'defaultCacheRepository' and 'defaultPublicRepository' have a unique registry host name + // NOTE: this requires that 'defaultBuildRepository', 'defaultCacheRepository' and 'defaultCommunityRegistry' have a unique registry host name // that means that for example docker.io/some/repo should not be used otherwise wave credentials could be used in place of user credentials // for a repo having the same registry host - if( container.sameRegistry(buildConfig.defaultBuildRepository) || container.sameRegistry(buildConfig.defaultCacheRepository) || container.sameRegistry(buildConfig.defaultPublicRepository) ) + if( container.sameRegistry(buildConfig.defaultBuildRepository) || container.sameRegistry(buildConfig.defaultCacheRepository) || container.sameRegistry(buildConfig.defaultCommunityRegistry) ) return getDefaultCredentials(container) return getUserCredentials0(container.registry, identity) diff --git a/src/main/groovy/io/seqera/wave/configuration/BuildConfig.groovy b/src/main/groovy/io/seqera/wave/configuration/BuildConfig.groovy index d28da4433..6a9066b9b 100644 --- a/src/main/groovy/io/seqera/wave/configuration/BuildConfig.groovy +++ b/src/main/groovy/io/seqera/wave/configuration/BuildConfig.groovy @@ -55,7 +55,7 @@ class BuildConfig { @Nullable @Value('${wave.build.public-repo}') - String defaultPublicRepository + String defaultCommunityRegistry /** * File system path there the dockerfile is save @@ -120,7 +120,7 @@ class BuildConfig { "singularity-image-amr64=${singularityImageArm64}; " + "default-build-repository=${defaultBuildRepository}; " + "default-cache-repository=${defaultCacheRepository}; " + - "default-public-repository=${defaultPublicRepository}; " + + "default-public-repository=${defaultCommunityRegistry}; " + "build-workspace=${buildWorkspace}; " + "build-timeout=${defaultTimeout}; " + "build-trusted-timeout=${trustedTimeout}; " + diff --git a/src/main/groovy/io/seqera/wave/controller/ContainerController.groovy b/src/main/groovy/io/seqera/wave/controller/ContainerController.groovy index 713ffae89..9001ac458 100644 --- a/src/main/groovy/io/seqera/wave/controller/ContainerController.groovy +++ b/src/main/groovy/io/seqera/wave/controller/ContainerController.groovy @@ -175,7 +175,7 @@ class ContainerController { @PostConstruct private void init() { - log.info "Wave server url: $serverUrl; allowAnonymous: $allowAnonymous; tower-endpoint-url: $towerEndpointUrl; default-build-repo: $buildConfig.defaultBuildRepository; default-cache-repo: $buildConfig.defaultCacheRepository; default-public-repo: $buildConfig.defaultPublicRepository" + log.info "Wave server url: $serverUrl; allowAnonymous: $allowAnonymous; tower-endpoint-url: $towerEndpointUrl; default-build-repo: $buildConfig.defaultBuildRepository; default-cache-repo: $buildConfig.defaultCacheRepository; default-public-repo: $buildConfig.defaultCommunityRegistry" } @Deprecated @@ -248,7 +248,7 @@ class ContainerController { if( req.containerImage && req.freeze && !validationService.isCustomRepo(req.buildRepository) ) throw new BadRequestException("Attribute `buildRepository` must be specified when using freeze mode [2]") - if( v2 && req.packages && req.freeze && !validationService.isCustomRepo(req.buildRepository) && !buildConfig.defaultPublicRepository ) + if( v2 && req.packages && req.freeze && !validationService.isCustomRepo(req.buildRepository) && !buildConfig.defaultCommunityRegistry ) throw new BadRequestException("Attribute `buildRepository` must be specified when using freeze mode [3]") if( v2 && req.packages ) { @@ -294,9 +294,9 @@ class ContainerController { protected String targetRepo(String repo, ImageNameStrategy strategy) { assert repo, 'Missing default public repository setting' // ignore everything that's not a public (community) repo - if( !buildConfig.defaultPublicRepository ) + if( !buildConfig.defaultCommunityRegistry ) return repo - if( !repo.startsWith(buildConfig.defaultPublicRepository) ) + if( !repo.startsWith(buildConfig.defaultCommunityRegistry) ) return repo // check if the repository does use any reserved word @@ -332,8 +332,8 @@ class ContainerController { final condaContent = condaFileFromRequest(req) final format = req.formatSingularity() ? SINGULARITY : DOCKER final platform = ContainerPlatform.of(req.containerPlatform) - final buildRepository = targetRepo( req.buildRepository ?: (req.freeze && buildConfig.defaultPublicRepository - ? buildConfig.defaultPublicRepository + final buildRepository = targetRepo( req.buildRepository ?: (req.freeze && buildConfig.defaultCommunityRegistry + ? buildConfig.defaultCommunityRegistry : buildConfig.defaultBuildRepository), req.nameStrategy) final cacheRepository = req.cacheRepository ?: buildConfig.defaultCacheRepository final configJson = inspectService.credentialsConfigJson(containerSpec, buildRepository, cacheRepository, identity) @@ -342,8 +342,8 @@ class ContainerController { // use 'imageSuffix' strategy by default for public repo images final nameStrategy = req.nameStrategy==null && buildRepository - && buildConfig.defaultPublicRepository - && buildRepository.startsWith(buildConfig.defaultPublicRepository) ? ImageNameStrategy.imageSuffix : req.nameStrategy + && buildConfig.defaultCommunityRegistry + && buildRepository.startsWith(buildConfig.defaultCommunityRegistry) ? ImageNameStrategy.imageSuffix : req.nameStrategy checkContainerSpec(containerSpec) diff --git a/src/main/groovy/io/seqera/wave/service/validation/ValidationServiceImpl.groovy b/src/main/groovy/io/seqera/wave/service/validation/ValidationServiceImpl.groovy index 0bc3a0c80..3ba029c57 100644 --- a/src/main/groovy/io/seqera/wave/service/validation/ValidationServiceImpl.groovy +++ b/src/main/groovy/io/seqera/wave/service/validation/ValidationServiceImpl.groovy @@ -107,7 +107,7 @@ class ValidationServiceImpl implements ValidationService { boolean isCustomRepo(String repo) { if( !repo ) return false - if( buildConfig.defaultPublicRepository && repo.startsWith(buildConfig.defaultPublicRepository) ) + if( buildConfig.defaultCommunityRegistry && repo.startsWith(buildConfig.defaultCommunityRegistry) ) return false if( buildConfig.defaultBuildRepository && repo.startsWith(buildConfig.defaultBuildRepository) ) return false diff --git a/src/test/groovy/io/seqera/wave/controller/ContainerControllerTest.groovy b/src/test/groovy/io/seqera/wave/controller/ContainerControllerTest.groovy index 1a4658f62..766f13ec2 100644 --- a/src/test/groovy/io/seqera/wave/controller/ContainerControllerTest.groovy +++ b/src/test/groovy/io/seqera/wave/controller/ContainerControllerTest.groovy @@ -627,7 +627,7 @@ class ContainerControllerTest extends Specification { @Unroll def 'should normalise community repo' () { given: - def config = new BuildConfig(defaultPublicRepository: PUBLIC, reservedWords: ['build','library'] as Set) + def config = new BuildConfig(defaultCommunityRegistry: PUBLIC, reservedWords: ['build','library'] as Set) def controller = new ContainerController(buildConfig: config) expect: controller.targetRepo(REPO, STRATEGY) == EXPECTED @@ -656,7 +656,7 @@ class ContainerControllerTest extends Specification { def 'should not allow reserved words' () { given: - def config = new BuildConfig(defaultPublicRepository: 'foo.com', reservedWords: ['build','library'] as Set) + def config = new BuildConfig(defaultCommunityRegistry: 'foo.com', reservedWords: ['build','library'] as Set) def controller = new ContainerController(buildConfig: config) when: diff --git a/src/test/groovy/io/seqera/wave/service/validation/ValidationServiceTest.groovy b/src/test/groovy/io/seqera/wave/service/validation/ValidationServiceTest.groovy index 12ba6c1e1..25c26d944 100644 --- a/src/test/groovy/io/seqera/wave/service/validation/ValidationServiceTest.groovy +++ b/src/test/groovy/io/seqera/wave/service/validation/ValidationServiceTest.groovy @@ -38,7 +38,7 @@ class ValidationServiceTest extends Specification { @MockBean(BuildConfig) BuildConfig buildConfig() { Mock(BuildConfig) { - defaultPublicRepository >> 'public.repo.io' + defaultCommunityRegistry >> 'public.repo.io' } }