Add JSON Schema for configuration

The schema is written in Python to reduce duplication. When
configuration is loaded, the validation checks if it's correct and fills
in default values.

There is a custom extension to the schema to report deprecated options.

The config dependencies are implemented as a separate pass. While it's
technically possible to express the dependencies in the schema itself,
the error messages are not very helpful and it makes the schema much
harder to read.

Phases no longer define `config_options`. New options should be added to
the schema. Since the default values are populated automatically during
validation, there is no need to duplicate them into the code.

The `pungi-config-validate` script is updated to use the schema and
report errors even for deeply nested fields.

The dependencies are updated: pungi now depends on `python-jsonschema`
(which is already available in Fedora).

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2016-08-22 16:08:25 +02:00
parent 5534fda192
commit f9a6c8418f
53 changed files with 1423 additions and 903 deletions

View file

@ -11,18 +11,7 @@ import sys
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
from pungi.phases import init
from tests.helpers import DummyCompose, PungiTestCase, touch, union
MIN_CONFIG = {
'release_short': 'Fedora',
'release_name': 'Fedora',
'release_version': 'Rawhide',
'release_is_layered': False,
'variants_file': 'does-not-exist.xml',
'sigkeys': [],
'createrepo_checksum': 'sha256',
'runroot': False,
}
from tests.helpers import DummyCompose, PungiTestCase, touch
class TestInitPhase(PungiTestCase):
@ -100,23 +89,6 @@ class TestInitPhase(PungiTestCase):
self.assertItemsEqual(write_variant.mock_calls, [])
self.assertItemsEqual(copy_comps.mock_calls, [])
def test_validate_keep_original_comps_missing(self):
compose = DummyCompose(self.topdir, MIN_CONFIG)
phase = init.InitPhase(compose)
phase.validate()
def test_validate_keep_original_comps_empty(self):
config = union(MIN_CONFIG, {'keep_original_comps': []})
compose = DummyCompose(self.topdir, config)
phase = init.InitPhase(compose)
phase.validate()
def test_validate_keep_original_comps_filled_in(self):
config = union(MIN_CONFIG, {'keep_original_comps': ['Everything']})
compose = DummyCompose(self.topdir, config)
phase = init.InitPhase(compose)
phase.validate()
class TestWriteArchComps(PungiTestCase):