| basic: | |
| type: object | |
| properties: | |
| packages: | |
| type: array | |
| description: apt-packages to install | |
| django: | |
| type: object | |
| properties: | |
| install-path: | |
| type: string | |
| default: "/opt" | |
| description: server install path | |
| code: | |
| type: string | |
| default: "yarg" | |
| description: source of django application |
| includes: ['layer:basic', 'layer:django'] | |
| options: | |
| basic: | |
| packages: | |
| - python-dev | |
| - obama | |
| django: | |
| install-path: "/srv" |
| import yaml | |
| import jsonschema | |
| with open('layer.yaml') as f: | |
| layer = yaml.safe_load(f.read()) | |
| with open('.layer.schema') as f: | |
| schema = yaml.safe_load(f.read()) | |
| options = layer.get('options', {}) | |
| jsonschema.validate(options, schema) |
| PyYAML==3.11 | |
| argparse==1.2.1 | |
| functools32==3.2.3-2 | |
| jsonschema==2.5.1 | |
| wsgiref==0.1.2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
marcoceppi commentedNov 30, 2015
Given https://gist.github.com/marcoceppi/ca36655cb917b16d0681 when
charm buildwas run on ubucon it would produce a few artifacts. The first being a.layer.schemafile which contains the namespaced schema for each layer'sdefines(if provided).Then
layer.yamlwould be the computed merge of all layer.yaml files from each layer, with each layer overwriting the previous key (or merging, where applicable). Finally schema validation would be performed against the final build to let the user know if the options are all valid.Ideally reactive would provide a tool to get the option values as a command to avoid needless parsing of layer.yaml by the user.
Alternatively, instead of stacking everything in layer.yaml an options.yaml file could be created (or .options.yaml to keep safe namespacing) where the options data would be held.
Finally,
defaultkey is ignored in jsonschema module. The reasoning makes sense but we'll need to make a clever parser to set defaults for values not defined by an author. All the more reason to have a reactive helper for this.