Check the Docker image name in CreateWorkerVersion
Ponos agents in both CE and EE are really not happy about getting any URL scheme within a Docker image name (ponos-agent#64). This can happen when some confused users paste a link to the Dockerfile on a Git repo instead of a Docker image name in the worker version creation modal. We can detect this early, thanks to Arkindex CE adding a dependency on docker-py.
docker.errors.InvalidRepository
is thrown by docker.auth.resolve_repository_name
, which is called by DockerClient.images.pull
.
The CreateWorkerVersion
endpoint should validate that calling resolve_repository_name
on the repository, separated from the image tag using docker.utils.parse_repository_tag
like what DockerClient.images.pull
does, does not crash. If there is an InvalidRepository
error, we can turn it into a ValidationError
.
This should not require access to a Docker socket, or creating a Docker client, as this is just some string parsing.
The worker version creation modal can already handle the usual API error in the form of {"docker_image_iid": ["..."]}
, so this can be displayed to users.