Skip to content

Commit

Permalink
Fix repository creds check (#665)
Browse files Browse the repository at this point in the history
Signed-off-by: Paolo Di Tommaso <[email protected]>
  • Loading branch information
pditommaso authored Oct 2, 2024
1 parent 8f3de2a commit c77d49d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,16 @@ class ContainerInspectServiceImpl implements ContainerInspectService {
repos.add(cacheRepo)
final result = credsJson(repos, identity)
if( buildRepo && result && !result.contains(host0(buildRepo)) )
throw new BadRequestException("Missing credentials for target build repository: $buildRepo")
throw new BadRequestException("Missing credentials for container repository: $buildRepo")
if( cacheRepo && result && !result.contains(host0(cacheRepo)) )
throw new BadRequestException("Missing credentials for target cache repository: $buildRepo")
throw new BadRequestException("Missing credentials for container repository: $cacheRepo")
return result
}

static protected String host0(String repo) {
repo.tokenize('/')[0]
ContainerCoordinates
.parse(repo)
.registry
}

protected String credsJson(Set<String> repositories, PlatformId identity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,11 @@ class ContainerBuildServiceTest extends Specification {
expect:
ContainerInspectServiceImpl.host0(CONTAINER) == EXPECTED
where:
CONTAINER | EXPECTED
'docker.io' | 'docker.io'
'docker.io/foo/'| 'docker.io'
CONTAINER | EXPECTED
'docker.io' | 'docker.io'
'docker.io/foo/' | 'docker.io'
'foo/bar' | 'docker.io'
'quay.io/foo/bar' | 'quay.io'
}

def 'should handle job completion event and update build store'() {
Expand Down

0 comments on commit c77d49d

Please sign in to comment.