Add --schema-override to pungi-config-validate script

Some composes might need extra validation to ensure they are following
certain strict rules - for example containing only signed packages or
packages only from particular Koji tag.

There is currently no way how to check that Pungi configuration fulfills
these extra requirements.

This commit adds new `--schema-override` option to
`pungi-config-validate` script which allows caller to specify path to
JSON schema overriding the default JSON schema and therefore limitting
it further.

For exmaple, to limit the `pkgset_source` to `koji`, one can use
following JSON schema override:

```
{
    "properties": {
        "pkgset_source": {
            "enum": ["koji"]
        }
    }
}
```

It is possible to use `--schema-override` multiple times to apply
multiple schema overrides.

Merges: https://pagure.io/pungi/pull-request/1341
Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
This commit is contained in:
Jan Kaluza 2020-02-03 12:43:27 +01:00 committed by Lubomír Sedlář
parent 6f23c7b8ba
commit ef33d00f5b
5 changed files with 86 additions and 5 deletions

View file

@ -542,6 +542,31 @@ class TestSchemaValidator(unittest.TestCase):
self.assertEqual(config["foo"], "git://example.com/repo.git#HEAD")
self.assertEqual(resolve_git_url.call_args_list, [])
def test_update_schema(self):
schema = checks.make_schema()
schema_override = {
"definitions": {
"scm_dict": {
"properties": {
"scm": {
"enum": ["git"]
},
"repo": {
"enum": ["git://localhost/pungi-fedora.git"]
},
}
}
}
}
schema = checks.update_schema(schema, schema_override)
scm_dict_properties = schema["definitions"]["scm_dict"]["properties"]
self.assertEqual(
scm_dict_properties["scm"],
{'enum': ['git'], 'type': 'string'})
self.assertEqual(
scm_dict_properties["repo"],
{'enum': ['git://localhost/pungi-fedora.git'], 'type': 'string'})
self.assertEqual(scm_dict_properties["file"], {"type": "string"})
class TestUmask(unittest.TestCase):
def setUp(self):