Bug 1290531 - Move image name verification to Python; r?dustin draft
authorGregory Szorc <gps@mozilla.com>
Fri, 29 Jul 2016 12:59:46 -0700
changeset 395034 d56e5fb1b16db4f8e6d9943f8e66314d1ac9cdb0
parent 395033 c2c37d6888c4acfb0a0204118cbb42d58efd5088
child 395035 79f38d98e9e731d66cd40448e340c8b7a3823912
push id24705
push userbmo:gps@mozilla.com
push dateMon, 01 Aug 2016 18:26:57 +0000
reviewersdustin
bugs1290531
milestone50.0a1
Bug 1290531 - Move image name verification to Python; r?dustin MozReview-Commit-ID: 8KJZH5vjANS
taskcluster/taskgraph/docker.py
testing/docker/build.sh
--- 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)