From: Daan De Meyer Date: Wed, 4 Oct 2023 16:50:07 +0000 (+0200) Subject: Add ImageId= and ImageVersion= specifiers X-Git-Tag: v18~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1efe3c6d722e0b144df897d60dd7a7c40c597cfe;p=thirdparty%2Fmkosi.git Add ImageId= and ImageVersion= specifiers Also rework the specifier tests a bit. --- diff --git a/mkosi/config.py b/mkosi/config.py index 663972687..7f1c9de5c 100644 --- a/mkosi/config.py +++ b/mkosi/config.py @@ -1204,6 +1204,7 @@ SETTINGS = ( dest="image_version", match=config_match_version, section="Output", + specifier="v", help="Set version for image", paths=("mkosi.version",), path_read_text=True, @@ -1212,6 +1213,7 @@ SETTINGS = ( dest="image_id", match=config_make_string_matcher(allow_globs=True), section="Output", + specifier="i", help="Set ID for image", ), MkosiConfigSetting( diff --git a/mkosi/resources/mkosi.md b/mkosi/resources/mkosi.md index 46e1a0e30..e0025abc2 100644 --- a/mkosi/resources/mkosi.md +++ b/mkosi/resources/mkosi.md @@ -1269,6 +1269,8 @@ use `%%`. The following specifiers are understood: | `Format=` | `%t` | | `Output=` | `%o` | | `OutputDirectory=` | `%O` | +| `ImageId=` | `%i` | +| `ImageVersion=` | `%v` | ## Supported distributions diff --git a/tests/test_config.py b/tests/test_config.py index 159aca066..e18dae7b3 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -611,19 +611,33 @@ def test_specifiers(tmp_path: Path) -> None: Architecture=arm64 [Output] + ImageId=my-image-id + ImageVersion=1.2.3 OutputDirectory=abcde Output=test - [Distribution] - ImageId=%d~%r~%a - - [Output] - CacheDirectory=%O/%o + [Content] + Environment=Distribution=%d + Release=%r + Architecture=%a + ImageId=%i + ImageVersion=%v + OutputDirectory=%O + Output=%o """ ) with chdir(d): _, [config] = parse_config() - assert config.distribution == Distribution.ubuntu - assert config.image_id == "ubuntu~lunar~arm64" - assert config.cache_dir == Path.cwd() / "abcde/test" / config.image_id + + expected = { + "Distribution": "ubuntu", + "Release": "lunar", + "Architecture": "arm64", + "ImageId": "my-image-id", + "ImageVersion": "1.2.3", + "OutputDirectory": str(Path.cwd() / "abcde"), + "Output": "test", + } + + assert {k: v for k, v in config.environment.items() if k in expected} == expected