diff options
author | Tiago Gomes <tiago.gomes@codethink.co.uk> | 2015-12-04 17:54:52 +0000 |
---|---|---|
committer | Pedro Alvarez <pedro.alvarez@codethink.co.uk> | 2016-03-24 23:54:00 +0000 |
commit | 23b363c55c755f648ae38b61f09253860bfc61d3 (patch) | |
tree | e2d1a577b0048d11329db5f794c66ae1e800ef53 /morphlib/plugins | |
parent | 48e4a7941a4c1351076a2edf23274b41b19eab19 (diff) | |
download | morph-23b363c55c755f648ae38b61f09253860bfc61d3.tar.gz |
Use jsonschema to validate the morphs
Use jsonschema to do a first stage of validation of the morphologies.
Example error messages:
ERROR: strata/core.morph: core->build-depends: 'foo' is not of type
'array'
ERROR: strata/core.morph: core: 'name' is a required property
ERROR: strata/core.morph: core: Additional properties are not allowed
('extra-field' was unexpected)
ERROR: strata/core.morph: core->chunks[0]->name: 1111 is not of type
'string'
ERROR: strata/core.morph: core->chunks[0]: 'repo' is a required property
on {'morph': 'strata/core/gdbm.morph', 'ref':
'e5faeaaf75ecfb705a9b643b3e4cb881ebb69f48', 'unpetrify-ref':
'gdbm-1.11', 'name': 'gdbm'}
ERROR: strata/core.morph: core->chunks[0]: Additional properties are not
allowed ('extra-field' was unexpected) on {'repo':
'upstream:gdbm-tarball', 'extra-field': None, 'name': 'gdbm', 'morph':
'strata/core/gdbm.morph', 'ref':
'e5faeaaf75ecfb705a9b643b3e4cb881ebb69f48', 'unpetrify-ref':
'gdbm-1.11'}
Change-Id: If9fd488e16db35130d074492a93754a447ea98e1
Diffstat (limited to 'morphlib/plugins')
-rw-r--r-- | morphlib/plugins/deploy_plugin.py | 5 | ||||
-rw-r--r-- | morphlib/plugins/diff_plugin.py | 8 |
2 files changed, 9 insertions, 4 deletions
diff --git a/morphlib/plugins/deploy_plugin.py b/morphlib/plugins/deploy_plugin.py index 18ea8d81..e925597e 100644 --- a/morphlib/plugins/deploy_plugin.py +++ b/morphlib/plugins/deploy_plugin.py @@ -340,11 +340,10 @@ class DeployPlugin(cliapp.Plugin): cluster_filename = morphlib.util.sanitise_morphology_path(args[0]) cluster_filename = definitions_repo.relative_path(cluster_filename) - loader = morphlib.morphloader.MorphologyLoader() + loader = definitions_repo.get_morphology_loader() cluster_text = definitions_repo.read_file(cluster_filename) cluster_morphology = loader.load_from_string(cluster_text, filename=cluster_filename) - if cluster_morphology['kind'] != 'cluster': raise cliapp.AppException( "Error: morph deployment commands are only supported for " @@ -357,7 +356,7 @@ class DeployPlugin(cliapp.Plugin): for system in cluster_morphology['systems']: all_deployments.update(system['deploy'].iterkeys()) if 'subsystems' in system: - all_subsystems.update(loader._get_subsystem_names(system)) + all_subsystems.update(loader.get_subsystem_names(system)) for item in args[1:]: if not item in all_deployments: break diff --git a/morphlib/plugins/diff_plugin.py b/morphlib/plugins/diff_plugin.py index de4ca0b9..5a59c95d 100644 --- a/morphlib/plugins/diff_plugin.py +++ b/morphlib/plugins/diff_plugin.py @@ -16,6 +16,7 @@ import cliapp +import morphlib from morphlib.buildcommand import BuildCommand from morphlib.cmdline_parse_utils import (definition_lists_synopsis, parse_definition_lists) @@ -23,6 +24,8 @@ from morphlib.morphologyfinder import MorphologyFinder from morphlib.morphloader import MorphologyLoader from morphlib.morphset import MorphologySet +from morphlib.definitions_version import check_version_file + class DiffPlugin(cliapp.Plugin): @@ -99,9 +102,12 @@ class DiffPlugin(cliapp.Plugin): def get_systems((reponame, ref, definitions)): 'Convert a definition path list into a list of systems' - ml = MorphologyLoader() repo = self.bc.repo_cache.get_updated_repo(reponame, ref=ref) mf = MorphologyFinder(gitdir=repo, ref=ref) + version_text = mf.read_file('VERSION') + definitons_version = check_version_file(version_text) + schemas = morphlib.util.read_schemas(definitons_version) + ml = MorphologyLoader(schemas=schemas) # We may have been given an empty set of definitions as input, in # which case we instead use every we find. if not definitions: |