Skip to content

Commit 0152bc3

Browse files
authored
Add valid hostname to DockerHubFlow (#3178) (#3182)
support "docker.io" as a valid host name for dockerhub. add tests.
1 parent 4fa75da commit 0152bc3

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

centaur/src/main/resources/standardTestCases/cacheBetweenWF/cacheBetweenWF.wdl

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ task getAverage {
88
Float average = read_float(stdout())
99
}
1010
runtime {
11-
docker: "ubuntu@sha256:71cd81252a3563a03ad8daee81047b62ab5d892ebbfbf71cf53415f29c130950"
11+
docker: "docker.io/ubuntu@sha256:71cd81252a3563a03ad8daee81047b62ab5d892ebbfbf71cf53415f29c130950"
1212
}
1313
}
1414

Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
task dockerhub {
2+
String hostname
23
command {
34
echo "hello"
45
}
56
runtime {
6-
docker: "ubuntu:precise-20161209"
7+
docker: hostname + "ubuntu:precise-20161209"
78
}
89
}
910

1011
workflow docker_hash_dockerhub {
11-
call dockerhub
12+
13+
call dockerhub as dockerWithoutHost { input: hostname = "" }
14+
15+
call dockerhub as implicitRegistryHost { input: hostname = "docker.io/" }
16+
17+
call dockerhub as defaultRegistryHost { input: hostname = "index.docker.io/" }
1218
}
19+

centaur/src/main/resources/standardTestCases/docker_hash_dockerhub.test

+6-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ files {
66
}
77

88
metadata {
9-
"calls.docker_hash_dockerhub.dockerhub.runtimeAttributes.docker": "ubuntu:precise-20161209",
10-
"calls.docker_hash_dockerhub.dockerhub.dockerImageUsed": "ubuntu@sha256:abdc090336ba4503bd72d0961a4f3d45134900d9a793d3f0c06a64d2555fbab7"
9+
"calls.docker_hash_dockerhub.dockerWithoutHost.runtimeAttributes.docker": "ubuntu:precise-20161209",
10+
"calls.docker_hash_dockerhub.dockerWithoutHost.dockerImageUsed": "ubuntu@sha256:abdc090336ba4503bd72d0961a4f3d45134900d9a793d3f0c06a64d2555fbab7",
11+
"calls.docker_hash_dockerhub.implicitRegistryHost.runtimeAttributes.docker": "docker.io/ubuntu:precise-20161209",
12+
"calls.docker_hash_dockerhub.implicitRegistryHost.dockerImageUsed": "docker.io/ubuntu@sha256:abdc090336ba4503bd72d0961a4f3d45134900d9a793d3f0c06a64d2555fbab7",
13+
"calls.docker_hash_dockerhub.defaultRegistryHost.runtimeAttributes.docker": "index.docker.io/ubuntu:precise-20161209",
14+
"calls.docker_hash_dockerhub.defaultRegistryHost.dockerImageUsed": "index.docker.io/ubuntu@sha256:abdc090336ba4503bd72d0961a4f3d45134900d9a793d3f0c06a64d2555fbab7"
1115
}

dockerHashing/src/main/scala/cromwell/docker/registryv2/flows/dockerhub/DockerHubFlow.scala

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ object DockerHubFlow {
1616
private val DockerHubDefaultRegistry = "index.docker.io"
1717
private val RegistryHostName = "registry-1.docker.io"
1818
private val AuthorizationServerHostName = "auth.docker.io"
19+
private val DockerHubImplicitRegistryHostName = "docker.io"
1920
private val ServiceName = Option("registry.docker.io")
21+
private val validDockerHubHosts = Array(DockerHubDefaultRegistry, RegistryHostName, DockerHubImplicitRegistryHostName)
2022
}
2123

2224
class DockerHubFlow(httpClientFlow: HttpDockerFlow)(implicit ec: ExecutionContext, materializer: ActorMaterializer, scheduler: Scheduler)
@@ -40,7 +42,7 @@ class DockerHubFlow(httpClientFlow: HttpDockerFlow)(implicit ec: ExecutionContex
4042
dockerImageIdentifierWithoutHash.host match {
4143
// If no host is provided, assume dockerhub
4244
case None => true
43-
case Some(host) if host == registryHostName || host == DockerHubDefaultRegistry => true
45+
case Some(host) if validDockerHubHosts.contains(host) => true
4446
case _ => false
4547
}
4648
}

0 commit comments

Comments
 (0)