| OLD | NEW |
| 1 # Copyright 2013 The LUCI Authors. All rights reserved. | 1 # Copyright 2013 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed under the Apache License, Version 2.0 | 2 # Use of this source code is governed under the Apache License, Version 2.0 |
| 3 # that can be found in the LICENSE file. | 3 # that can be found in the LICENSE file. |
| 4 | 4 |
| 5 """Recipe Configuration Meta DSL. | 5 """Recipe Configuration Meta DSL. |
| 6 | 6 |
| 7 This module contains, essentially, a DSL for writing composable configurations. | 7 This module contains, essentially, a DSL for writing composable configurations. |
| 8 You start by defining a schema which describes how your configuration blobs will | 8 You start by defining a schema which describes how your configuration blobs will |
| 9 be structured, and what data they can contain. For example: | 9 be structured, and what data they can contain. For example: |
| 10 | 10 |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 def schema_proto(self): | 333 def schema_proto(self): |
| 334 """Returns a doc.Doc.Schema proto message for this config type.""" | 334 """Returns a doc.Doc.Schema proto message for this config type.""" |
| 335 raise NotImplementedError | 335 raise NotImplementedError |
| 336 | 336 |
| 337 | 337 |
| 338 _SIMPLE_TYPE_LOOKUP = { | 338 _SIMPLE_TYPE_LOOKUP = { |
| 339 str: doc.Doc.Schema.STRING, | 339 str: doc.Doc.Schema.STRING, |
| 340 basestring: doc.Doc.Schema.STRING, | 340 basestring: doc.Doc.Schema.STRING, |
| 341 unicode: doc.Doc.Schema.STRING, | 341 unicode: doc.Doc.Schema.STRING, |
| 342 int: doc.Doc.Schema.NUMBER, | 342 int: doc.Doc.Schema.NUMBER, |
| 343 long: doc.Doc.Schema.NUMBER, |
| 343 float: doc.Doc.Schema.NUMBER, | 344 float: doc.Doc.Schema.NUMBER, |
| 344 bool: doc.Doc.Schema.BOOLEAN, | 345 bool: doc.Doc.Schema.BOOLEAN, |
| 345 dict: doc.Doc.Schema.OBJECT, | 346 dict: doc.Doc.Schema.OBJECT, |
| 346 list: doc.Doc.Schema.ARRAY, | 347 list: doc.Doc.Schema.ARRAY, |
| 347 type(None): doc.Doc.Schema.NULL, | 348 type(None): doc.Doc.Schema.NULL, |
| 348 } | 349 } |
| 349 | 350 |
| 350 | 351 |
| 351 def _inner_type_schema(inner_type): | 352 def _inner_type_schema(inner_type): |
| 352 ret = [] | 353 ret = [] |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 904 | 905 |
| 905 def _is_default(self): | 906 def _is_default(self): |
| 906 return self.data is None | 907 return self.data is None |
| 907 | 908 |
| 908 def schema_proto(self): | 909 def schema_proto(self): |
| 909 ret = doc.Doc.Schema() | 910 ret = doc.Doc.Schema() |
| 910 ret.enum.values_json.extend(json.dumps(self.jsonish_fn(v)) | 911 ret.enum.values_json.extend(json.dumps(self.jsonish_fn(v)) |
| 911 for v in self.values) | 912 for v in self.values) |
| 912 ret.enum.required = self.required | 913 ret.enum.required = self.required |
| 913 return ret | 914 return ret |
| OLD | NEW |