Bug 1290531 - Move image name verification to Python; r=dustin
authorGregory Szorc <gps@mozilla.com>
Fri, 29 Jul 2016 12:59:46 -0700
changeset 307533 a1f4555494b7aa5ebc6dcdae45315e1ac2ab0bb4
parent 307532 95aeafbfec097edaa2ce746811cb1d1de63a7d40
child 307534 e20bc9e7b3887a48d32e7fb242e94986555c31f6
push id30514
push usercbook@mozilla.com
push dateTue, 02 Aug 2016 15:04:11 +0000
treeherdermozilla-central@ea6e87bbd03e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdustin
bugs1290531
milestone50.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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)