Skip to content

Commit

Permalink
Do not do docker ref validation if docker image is on gcr.io
Browse files Browse the repository at this point in the history
  • Loading branch information
gbggrant committed Aug 12, 2015
1 parent ee67220 commit e5008fa
Showing 1 changed file with 20 additions and 13 deletions.
Expand Up @@ -70,7 +70,10 @@ class AgoraBusiness(authorizationProvider: AuthorizationProvider) {

private def validateDockerImage(task: Task) = {
if (task.runtimeAttributes.docker.isDefined) {
DockerHubClient.doesDockerImageExist(parseDockerString(task.runtimeAttributes.docker.get))
val dockerImageReference = parseDockerString(task.runtimeAttributes.docker.get)
if (dockerImageReference.isDefined) {
DockerHubClient.doesDockerImageExist(dockerImageReference.get)
}
}
}

Expand All @@ -79,18 +82,22 @@ class AgoraBusiness(authorizationProvider: AuthorizationProvider) {
*
* @param imageId docker imageId string. Looks like ubuntu:latest ggrant/joust:latest
*/
private def parseDockerString(imageId: String) = {
val splitUser = imageId.split('/')
if (splitUser.length > 2) {
throw new SyntaxError("Docker image string '" + imageId + "' is malformed")
}
val user = if (splitUser.length == 1) None else Option(splitUser(0))
val splitTag = splitUser(splitUser.length - 1).split(':')
if (splitTag.length > 2) {
throw new SyntaxError("Docker image string '" + imageId + "' is malformed")
private def parseDockerString(imageId: String) : Option[DockerImageReference] = {
if (imageId.startsWith("gcr.io")) {
None
} else {
val splitUser = imageId.split('/')
if (splitUser.length > 2) {
throw new SyntaxError("Docker image string '" + imageId + "' is malformed")
}
val user = if (splitUser.length == 1) None else Option(splitUser(0))
val splitTag = splitUser(splitUser.length - 1).split(':')
if (splitTag.length > 2) {
throw new SyntaxError("Docker image string '" + imageId + "' is malformed")
}
val repo = splitTag(0)
val tag = if (splitTag.length == 1) "latest" else splitTag(1)
Option(DockerImageReference(user, repo, tag))
}
val repo = splitTag(0)
val tag = if (splitTag.length == 1) "latest" else splitTag(1)
DockerImageReference(user, repo, tag)
}
}

0 comments on commit e5008fa

Please sign in to comment.