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.
This commit is contained in:
Michael Vogt 2024-04-15 09:51:27 +02:00 committed by Ondřej Budai
parent 2a0027557f
commit 7c04e1c596
2 changed files with 30 additions and 14 deletions

View file

@ -6,25 +6,34 @@
"If no `gid` is given, `groupadd` will choose one.", "If no `gid` is given, `groupadd` will choose one.",
"If the specified group name or GID is already in use, this stage will fail." "If the specified group name or GID is already in use, this stage will fail."
], ],
"schema": { "schema_2": {
"additionalProperties": false, "options": {
"properties": { "additionalProperties": false,
"groups": { "properties": {
"type": "object", "groups": {
"additionalProperties": false, "type": "object",
"description": "Keys are group names, values are objects with group info", "additionalProperties": false,
"patternProperties": { "description": "Keys are group names, values are objects with group info",
"^[A-Za-z0-9_][A-Za-z0-9_-]{0,31}$": { "patternProperties": {
"type": "object", "^[A-Za-z0-9_][A-Za-z0-9_-]{0,31}$": {
"properties": { "type": "object",
"gid": { "properties": {
"type": "number", "gid": {
"description": "GID for this group" "type": "number",
"description": "GID for this group"
}
} }
} }
} }
} }
} }
},
"devices": {
"type": "object",
"additionalProperties": true
},
"mounts": {
"type": "array"
} }
} }
} }

View file

@ -29,3 +29,10 @@ def test_schema_validation(stage_schema, test_data, expected_err):
else: else:
assert res.valid is False assert res.valid is False
assert_jsonschema_error_contains(res, expected_err, expected_num_errs=1) 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]}"