Bug 1290531 - Move image name verification to Python; r?dustin
MozReview-Commit-ID: 8KJZH5vjANS
--- a/taskcluster/taskgraph/docker.py
+++ b/taskcluster/taskgraph/docker.py
@@ -65,16 +65,23 @@ def load_image_by_task_id(task_id):
print("Try: docker run -ti --rm {} bash".format(name))
def build_image(name):
"""Build a Docker image of specified name.
Output from image building process will be printed to stdout.
"""
+ if not name:
+ raise ValueError('must provide a Docker image name')
+
+ image_dir = os.path.join(IMAGE_DIR, name)
+ if not os.path.isdir(image_dir):
+ raise Exception('image directory does not exist: %s' % image_dir)
+
docker_bin = which.which('docker')
# Verify that Docker is working.
try:
subprocess.check_output([docker_bin, '--version'])
except subprocess.CalledProcessError:
raise Exception('Docker server is unresponsive. Run `docker ps` and '
'check that Docker is running')
--- a/testing/docker/build.sh
+++ b/testing/docker/build.sh
@@ -25,24 +25,16 @@ usage_err() {
build() {
local image_name=$1
local folder="$gecko_root/testing/docker/$image_name"
local folder_reg="$folder/REGISTRY"
local folder_ver="$folder/VERSION"
local could_deploy=false
- if [ "$image_name" == "" ];
- then
- usage
- return
- fi
-
- test -d "$folder" || usage_err "Unknown image: $image_name"
-
# Assume that if an image context directory does not contain a VERSION file then
# it is not suitable for deploying. Default to using 'latest' as the tag and
# warn the user at the end.
if [ ! -f $folder_ver ]; then
echo "This image does not contain a VERSION file. Will use 'latest' as the image version"
local tag="$image_name:latest"
else
local version=$(cat $folder_ver)