Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

renamed from defaultPublicRepository to defaultCommunityRegistry #709

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class BuildConfig {

@Nullable
@Value('${wave.build.public-repo}')
String defaultPublicRepository
String defaultCommunityRegistry

/**
* File system path there the dockerfile is save
Expand Down Expand Up @@ -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}; " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 ) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ValidationServiceTest extends Specification {
@MockBean(BuildConfig)
BuildConfig buildConfig() {
Mock(BuildConfig) {
defaultPublicRepository >> 'public.repo.io'
defaultCommunityRegistry >> 'public.repo.io'
}
}

Expand Down