From 7c04e1c596acf38cf8f3a5983207626c599f4cdd Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 15 Apr 2024 09:51:27 +0200 Subject: [PATCH] stages(groups): port to v2 and allow devices/mounts This will allow us to generate `bootc install to-filesystem` compatible devices/mount setups for the groups stage. --- stages/org.osbuild.groups.meta.json | 37 ++++++++++++++++++----------- stages/test/test_groups.py | 7 ++++++ 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/stages/org.osbuild.groups.meta.json b/stages/org.osbuild.groups.meta.json index 2940c4d0..939a57f5 100644 --- a/stages/org.osbuild.groups.meta.json +++ b/stages/org.osbuild.groups.meta.json @@ -6,25 +6,34 @@ "If no `gid` is given, `groupadd` will choose one.", "If the specified group name or GID is already in use, this stage will fail." ], - "schema": { - "additionalProperties": false, - "properties": { - "groups": { - "type": "object", - "additionalProperties": false, - "description": "Keys are group names, values are objects with group info", - "patternProperties": { - "^[A-Za-z0-9_][A-Za-z0-9_-]{0,31}$": { - "type": "object", - "properties": { - "gid": { - "type": "number", - "description": "GID for this group" + "schema_2": { + "options": { + "additionalProperties": false, + "properties": { + "groups": { + "type": "object", + "additionalProperties": false, + "description": "Keys are group names, values are objects with group info", + "patternProperties": { + "^[A-Za-z0-9_][A-Za-z0-9_-]{0,31}$": { + "type": "object", + "properties": { + "gid": { + "type": "number", + "description": "GID for this group" + } } } } } } + }, + "devices": { + "type": "object", + "additionalProperties": true + }, + "mounts": { + "type": "array" } } } diff --git a/stages/test/test_groups.py b/stages/test/test_groups.py index a3940a3f..2d5f7081 100644 --- a/stages/test/test_groups.py +++ b/stages/test/test_groups.py @@ -29,3 +29,10 @@ def test_schema_validation(stage_schema, test_data, expected_err): else: assert res.valid is False assert_jsonschema_error_contains(res, expected_err, expected_num_errs=1) + + +def test_schema_supports_bootc_style_mounts(stage_schema, bootc_devices_mounts_dict): + test_input = bootc_devices_mounts_dict + test_input["type"] = STAGE_NAME + res = stage_schema.validate(test_input) + assert res.valid is True, f"err: {[e.as_dict() for e in res.errors]}"