From: Daan De Meyer Date: Fri, 2 Sep 2022 13:32:20 +0000 (+0200) Subject: Move secure boot args initialization into argparse defaults X-Git-Tag: v14~43^2~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3c8840f56e6e08c040b4c34e0b7824f4e5486a2e;p=thirdparty%2Fmkosi.git Move secure boot args initialization into argparse defaults We want to be able to have an immutable config struct, so let's initialize these variables before creating the config. --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 0f57aa21a..3e2d28b0b 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -5170,12 +5170,14 @@ def create_parser() -> ArgumentParserMkosi: help="UEFI SecureBoot private key in PEM format", type=Path, metavar="PATH", + default=Path("./mkosi.secure-boot.key"), ) group.add_argument( "--secure-boot-certificate", help="UEFI SecureBoot certificate in X509 format", type=Path, metavar="PATH", + default=Path("./mkosi.secure-boot.crt"), ) group.add_argument( "--secure-boot-valid-days", @@ -7994,8 +7996,6 @@ def run_serve(config: MkosiConfig) -> None: def generate_secure_boot_key(config: MkosiConfig) -> NoReturn: """Generate secure boot keys using openssl""" - config.secure_boot_key = config.secure_boot_key or Path("./mkosi.secure-boot.key") - config.secure_boot_certificate = config.secure_boot_certificate or Path("./mkosi.secure-boot.crt") keylength = 2048 expiration_date = datetime.date.today() + datetime.timedelta(int(config.secure_boot_valid_days)) diff --git a/tests/test_config_parser.py b/tests/test_config_parser.py index 35028d842..6d51e3ff3 100644 --- a/tests/test_config_parser.py +++ b/tests/test_config_parser.py @@ -110,8 +110,8 @@ class MkosiConfig: "base_image": None, "root_size": None, "secure_boot": False, - "secure_boot_certificate": None, - "secure_boot_key": None, + "secure_boot_certificate": Path("mkosi.secure-boot.crt"), + "secure_boot_key": Path("mkosi.secure-boot.key"), "secure_boot_common_name": "mkosi of %u", "secure_boot_valid_days": "730", "sign": False,