stages(kickstart): mutual exclusive ostree options

These options are mutually exclusive, this updates the schema and test
case to ensure this is detected at schema validation time.
This commit is contained in:
Simon de Vlieger 2023-12-07 16:09:22 +01:00 committed by Achilleas Koutsou
parent 20d8d3a9a8
commit 1b5ab0ee03
2 changed files with 22 additions and 1 deletions

View file

@ -92,7 +92,11 @@ SCHEMA = r"""
}
},
"additionalProperties": false,
"required": ["path"],
"anyOf": [
{"required": ["path", "ostree"], "not": {"required": ["ostreecontainer"]}},
{"required": ["path", "ostreecontainer"], "not": {"required": ["ostree"]}},
{"required": ["path"], "not": {"required": ["ostree", "ostreecontainer"]}}
],
"properties": {
"path": {
"type": "string",

View file

@ -342,6 +342,23 @@ def test_kickstart_valid(tmp_path, test_input, expected): # pylint: disable=unu
# ostreecontainer
({"ostreecontainer": {"url": "http://some-ostree-url.com/foo",
"transport": "not-valid"}}, "'not-valid' is not one of ["),
# not both ostreecontainer and ostree
(
{
"ostreecontainer": {
"url": "http://some-ostree-url.com/foo",
},
"ostree": {
"osname": "some-osname",
"url": "http://some-ostree-url.com/foo",
"ref": "some-ref",
"remote": "some-remote",
"gpg": True,
},
},
"is not valid under any of the given schemas",
),
],
)
def test_schema_validation_bad_apples(test_data, expected_err):