| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import json | 5 import json |
| 6 import re | 6 import re |
| 7 | 7 |
| 8 from proto import project_config_pb2 | 8 from proto import project_config_pb2 |
| 9 | 9 |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 | 24 |
| 25 def validate_dimensions(field_name, dimensions, ctx): | 25 def validate_dimensions(field_name, dimensions, ctx): |
| 26 known_keys = set() | 26 known_keys = set() |
| 27 for i, dim in enumerate(dimensions): | 27 for i, dim in enumerate(dimensions): |
| 28 with ctx.prefix('%s #%d: ', field_name, i + 1): | 28 with ctx.prefix('%s #%d: ', field_name, i + 1): |
| 29 components = dim.split(':', 1) | 29 components = dim.split(':', 1) |
| 30 if len(components) != 2: | 30 if len(components) != 2: |
| 31 ctx.error('does not have ":"') | 31 ctx.error('does not have ":"') |
| 32 continue | 32 continue |
| 33 key, value = components | 33 key, _ = components |
| 34 if not key: | 34 if not key: |
| 35 ctx.error('no key') | 35 ctx.error('no key') |
| 36 else: | 36 else: |
| 37 if not DIMENSION_KEY_RGX.match(key): | 37 if not DIMENSION_KEY_RGX.match(key): |
| 38 ctx.error( | 38 ctx.error( |
| 39 'key "%s" does not match pattern "%s"', | 39 'key "%s" does not match pattern "%s"', |
| 40 key, DIMENSION_KEY_RGX.pattern) | 40 key, DIMENSION_KEY_RGX.pattern) |
| 41 if key in known_keys: | 41 if key in known_keys: |
| 42 ctx.error('duplicate key %s', key) | 42 ctx.error('duplicate key %s', key) |
| 43 else: | 43 else: |
| 44 known_keys.add(key) | 44 known_keys.add(key) |
| 45 if not value: | |
| 46 ctx.error('no value') | |
| 47 | 45 |
| 48 | 46 |
| 49 def validate_recipe_cfg(recipe, common_recipe, ctx): | 47 def validate_recipe_cfg(recipe, common_recipe, ctx): |
| 50 common_recipe = common_recipe or project_config_pb2.Swarming.Recipe() | 48 common_recipe = common_recipe or project_config_pb2.Swarming.Recipe() |
| 51 if not (recipe.name or common_recipe.name): | 49 if not (recipe.name or common_recipe.name): |
| 52 ctx.error('name unspecified') | 50 ctx.error('name unspecified') |
| 53 if not (recipe.repository or common_recipe.repository): | 51 if not (recipe.repository or common_recipe.repository): |
| 54 ctx.error('repository unspecified') | 52 ctx.error('repository unspecified') |
| 55 validate_recipe_properties(recipe.properties, recipe.properties_j, ctx) | 53 validate_recipe_properties(recipe.properties, recipe.properties_j, ctx) |
| 56 | 54 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 validate_recipe_properties( | 130 validate_recipe_properties( |
| 133 swarming.common_recipe.properties, | 131 swarming.common_recipe.properties, |
| 134 swarming.common_recipe.properties_j, ctx) | 132 swarming.common_recipe.properties_j, ctx) |
| 135 | 133 |
| 136 for i, b in enumerate(swarming.builders): | 134 for i, b in enumerate(swarming.builders): |
| 137 with ctx.prefix('builder %s: ' % (b.name or '#%s' % (i + 1))): | 135 with ctx.prefix('builder %s: ' % (b.name or '#%s' % (i + 1))): |
| 138 validate_builder_cfg( | 136 validate_builder_cfg( |
| 139 b, ctx, bucket_has_pool_dim=has_pool_dim, | 137 b, ctx, bucket_has_pool_dim=has_pool_dim, |
| 140 common_recipe=common_recipe) | 138 common_recipe=common_recipe) |
| 141 | 139 |
| 140 |
| 142 def has_pool_dimension(dimensions): | 141 def has_pool_dimension(dimensions): |
| 143 return any(d.startswith('pool:') for d in dimensions) | 142 return any(d.startswith('pool:') for d in dimensions) |
| OLD | NEW |