Skip to content

Commit 925f687

Browse files
committed
Improve container validation
Signed-off-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
1 parent 6135704 commit 925f687

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/main/groovy/io/seqera/wave/model/ContainerCoordinates.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ class ContainerCoordinates implements ContainerPath {
5353
static ContainerCoordinates parse(String path) {
5454
if( !path )
5555
throw new IllegalArgumentException("Container image name is not provided")
56-
56+
if( path.contains(' ') )
57+
throw new IllegalArgumentException("Invalid container name - offending image: '$path'")
5758
final scheme = StringUtils.getUrlProtocol(path)
5859
if( scheme ) {
5960
if( scheme!='oras') throw new IllegalArgumentException("Invalid container scheme: '$scheme' - offending image: '$path'")

src/main/groovy/io/seqera/wave/service/validation/ValidationServiceImpl.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,14 @@ class ValidationServiceImpl implements ValidationService {
6868
// check does not start with a protocol prefix
6969
final prot = StringUtils.getUrlProtocol(name)
7070
if( prot ) {
71-
return "Invalid container repository name — offending value: $name"
71+
return "Invalid container repository name — offending value: '$name'"
7272
}
7373

7474
try {
7575
ContainerCoordinates.parse(name)
7676
}
7777
catch (IllegalArgumentException e) {
78-
return "Invalid container image name — offending value: $name"
78+
return "Invalid container image name — offending value: '$name'"
7979
}
8080
return null
8181
}

src/test/groovy/io/seqera/wave/service/validation/ValidationServiceTest.groovy

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,12 @@ class ValidationServiceTest extends Specification {
8080
'quay.io:80/foo:latest' | null
8181
'localhost:8000/foo:latest' | null
8282
and:
83-
'docker:quay.io/foo:latest' | 'Invalid container image name — offending value: docker:quay.io/foo:latest'
84-
'http://quay.io/foo:latest' | 'Invalid container repository name — offending value: http://quay.io/foo:latest'
85-
'http://quay.io/foo:latest' | 'Invalid container repository name — offending value: http://quay.io/foo:latest'
83+
'docker:quay.io/foo:latest' | "Invalid container image name — offending value: 'docker:quay.io/foo:latest'"
84+
'http://quay.io/foo:latest' | "Invalid container repository name — offending value: 'http://quay.io/foo:latest'"
85+
'http://quay.io/foo:latest' | "Invalid container repository name — offending value: 'http://quay.io/foo:latest'"
86+
'ubuntu: latest' | "Invalid container image name — offending value: 'ubuntu: latest'"
87+
'ubuntu:latest ' | "Invalid container image name — offending value: 'ubuntu:latest '"
88+
' ' | "Invalid container image name — offending value: ' '"
8689
}
8790

8891
@Unroll

0 commit comments

Comments
 (0)