Bug 1419638 - Add schema validation to docker image transform. r=dustin
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 28 Dec 2017 15:46:14 +0900
changeset 449590 e2d65a3c816be9084064991ea82daeb7e2f74af7
parent 449589 f730c9da9c1f00d95963772e59fe6fc5dc7e01d3
child 449591 a8a58f122f88ab8103332852fe9826a5071fd01f
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdustin
bugs1419638
milestone59.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 1419638 - Add schema validation to docker image transform. r=dustin
taskcluster/taskgraph/transforms/docker_image.py
--- a/taskcluster/taskgraph/transforms/docker_image.py
+++ b/taskcluster/taskgraph/transforms/docker_image.py
@@ -1,31 +1,54 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
-"""
-Transform the upload-symbols task description template,
-  taskcluster/ci/upload-symbols/job-template.yml
-into an actual task description.
-"""
 
 from __future__ import absolute_import, print_function, unicode_literals
 
 import os
 
 from taskgraph.transforms.base import TransformSequence
 from .. import GECKO
 from taskgraph.util.docker import (
     docker_image,
     generate_context_hash,
 )
 from taskgraph.util.cached_tasks import add_optimization
+from taskgraph.util.schema import (
+    Schema,
+    validate_schema,
+)
+from voluptuous import (
+    Optional,
+    Required,
+)
 
 transforms = TransformSequence()
 
+docker_image_schema = Schema({
+    # Name of the docker image.
+    Required('name'): basestring,
+
+    # Treeherder symbol.
+    Required('symbol'): basestring,
+
+    # relative path (from config.path) to the file the docker image was defined
+    # in.
+    Optional('job-from'): basestring,
+})
+
+
+@transforms.add
+def validate(config, tasks):
+    for task in tasks:
+        yield validate_schema(
+            docker_image_schema, task,
+            "In docker image {!r}:".format(task.get('name', 'unknown')))
+
 
 @transforms.add
 def fill_template(config, tasks):
     for task in tasks:
         image_name = task.pop('name')
         job_symbol = task.pop('symbol')
 
         context_path = os.path.join('taskcluster', 'docker', image_name)