From 20d8d3a9a82d240e707ae0e6c755c191069b0626 Mon Sep 17 00:00:00 2001 From: Simon de Vlieger Date: Thu, 7 Dec 2023 10:21:25 +0100 Subject: [PATCH] stages(kickstart): add `ostreecontainer` Add support for the `ostreecontainer` kickstart command, see: https://pykickstart.readthedocs.io/en/latest/kickstart-docs.html#ostreecontainer --- stages/org.osbuild.kickstart | 43 +++++++++++++++++++++++++++++++++++ stages/test/test_kickstart.py | 24 +++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/stages/org.osbuild.kickstart b/stages/org.osbuild.kickstart index 9d5f5372..4b025a72 100755 --- a/stages/org.osbuild.kickstart +++ b/stages/org.osbuild.kickstart @@ -122,6 +122,31 @@ SCHEMA = r""" } } }, + "ostreecontainer": { + "type": "object", + "required": ["url"], + "additionalProperties": false, + "properties": { + "stateroot": { + "type": "string" + }, + "url": { + "type": "string" + }, + "transport": { + "type": "string", + "enum": ["registry", "oci", "oci-archive"], + "description": "Use the given transport, Anaconda's default is 'registry'" + }, + "remote": { + "type": "string" + }, + "signatureverification": { + "type": "boolean", + "default": true + } + } + }, "liveimg": { "type": "object", "required": ["url"], @@ -514,6 +539,24 @@ def main(tree, options): # pylint: disable=too-many-branches config += [cmd] + ostreecontainer = options.get("ostreecontainer") + + if ostreecontainer: + url = ostreecontainer["url"] + + cmd = f"ostreecontainer --url={url}" + + for name in ["stateroot", "transport", "remote"]: + value = ostreecontainer.get(name) + if value: + cmd += f" --{name}={value}" + + signature_verification = ostreecontainer.get("signatureverification", True) + if not signature_verification: + cmd += " --no-signature-verification" + + config += [cmd] + liveimg = options.get("liveimg") if liveimg: url = liveimg["url"] diff --git a/stages/test/test_kickstart.py b/stages/test/test_kickstart.py index 8428a266..818d9262 100644 --- a/stages/test/test_kickstart.py +++ b/stages/test/test_kickstart.py @@ -191,6 +191,27 @@ TEST_INPUT = [ # hostname can also be written as a QFDN ({"network": [{"device": "foo", "hostname": "foo.bar.com"}]}, "network --device=foo --hostname=foo.bar.com"), + # ostreecontainer + ( + { + "ostreecontainer": { + "stateroot": "some-osname", + "url": "http://some-ostree-url.com/foo", + "transport": "registry", + "remote": "some-remote", + "signatureverification": False, + }, + }, + "ostreecontainer --url=http://some-ostree-url.com/foo --stateroot=some-osname --transport=registry --remote=some-remote --no-signature-verification", + ), + ( + { + "ostreecontainer": { + "url": "http://some-ostree-url.com/foo", + }, + }, + "ostreecontainer --url=http://some-ostree-url.com/foo", + ), ] @@ -318,6 +339,9 @@ def test_kickstart_valid(tmp_path, test_input, expected): # pylint: disable=unu ".123456789012345678901234567890123456789012345678901234567890123" + ".12345678901234567890123456789012345678901234567890123456789012" }]}, " does not match "), + # ostreecontainer + ({"ostreecontainer": {"url": "http://some-ostree-url.com/foo", + "transport": "not-valid"}}, "'not-valid' is not one of ["), ], ) def test_schema_validation_bad_apples(test_data, expected_err):