From be85b2342c8f8ac855cfaf012f90641c2554916d Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 9 Nov 2023 14:57:28 +0100 Subject: [PATCH] stages(kickstart): ensure clearpart dict always has an option set --- stages/org.osbuild.kickstart | 7 +++++++ stages/test/test_kickstart.py | 3 +-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/stages/org.osbuild.kickstart b/stages/org.osbuild.kickstart index 5e13f6e0..3994aa04 100755 --- a/stages/org.osbuild.kickstart +++ b/stages/org.osbuild.kickstart @@ -139,6 +139,13 @@ SCHEMA = r""" "clearpart": { "description": "Removes partitions from the system, prior to creation of new partitions", "type": "object", + "anyOf": [ + {"required": ["all"]}, + {"required": ["drives"]}, + {"required": ["list"]}, + {"required": ["disklabel"]}, + {"required": ["linux"]} + ], "properties": { "all": { "description": "Erases all partitions from the system", diff --git a/stages/test/test_kickstart.py b/stages/test/test_kickstart.py index 6a882e57..c149e54e 100644 --- a/stages/test/test_kickstart.py +++ b/stages/test/test_kickstart.py @@ -55,8 +55,6 @@ from osbuild.testutil.imports import import_module_from_path 'sshkey --username someusr "ssh-rsa not-really-a-real-key"' ), ({"zerombr": "true"}, "zerombr"), - # no clearpart for an empty dict (will not do anything with options anyway) - ({"clearpart": {}}, ""), ({"clearpart": {"all": True}}, "clearpart --all"), ({"clearpart": {"drives": ["hda", "hdb"]}}, "clearpart --drives=hda,hdb",), ({"clearpart": {"drives": ["hda"]}}, "clearpart --drives=hda"), @@ -120,6 +118,7 @@ def test_kickstart(tmp_path, test_input, expected): @pytest.mark.parametrize("test_data,expected_err", [ # BAD pattern, ensure some obvious ways to write arbitrary # kickstart files will not work + ({"clearpart": {}}, "{} is not valid "), ({"clearpart": {"disklabel": r"\n%pre\necho p0wnd"}}, r"p0wnd' does not match"), ({"clearpart": {"drives": [" --spaces-dashes-not-allowed"]}}, "' --spaces-dashes-not-allowed' does not match"), ({"clearpart": {"drives": ["\n%pre not allowed"]}}, "not allowed' does not match"),