From 1b5ab0ee034b1e9e20cb8354dce6ffb6fab7eea7 Mon Sep 17 00:00:00 2001 From: Simon de Vlieger Date: Thu, 7 Dec 2023 16:09:22 +0100 Subject: [PATCH] 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. --- stages/org.osbuild.kickstart | 6 +++++- stages/test/test_kickstart.py | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/stages/org.osbuild.kickstart b/stages/org.osbuild.kickstart index 4b025a72..03d30cf1 100755 --- a/stages/org.osbuild.kickstart +++ b/stages/org.osbuild.kickstart @@ -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", diff --git a/stages/test/test_kickstart.py b/stages/test/test_kickstart.py index 818d9262..d2ca7340 100644 --- a/stages/test/test_kickstart.py +++ b/stages/test/test_kickstart.py @@ -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):