From f0a183b91dfd98083e975954adf5efd95a5c942a Mon Sep 17 00:00:00 2001 From: Tobias Wolf Date: Tue, 22 Jul 2025 14:24:57 +0200 Subject: [PATCH] Fix `Layer.lookup_media_type_for_file_name()` to match file names Signed-off-by: Tobias Wolf --- .github/actions/features_parse/action.yml | 2 +- .github/actions/flavors_parse/action.yml | 2 +- .github/actions/setup/action.yml | 2 +- pyproject.toml | 2 +- src/gardenlinux/oci/layer.py | 8 ++++---- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/actions/features_parse/action.yml b/.github/actions/features_parse/action.yml index 75636913..93ab20c3 100644 --- a/.github/actions/features_parse/action.yml +++ b/.github/actions/features_parse/action.yml @@ -11,7 +11,7 @@ outputs: runs: using: composite steps: - - uses: gardenlinux/python-gardenlinux-lib/.github/actions/setup@0.8.4 + - uses: gardenlinux/python-gardenlinux-lib/.github/actions/setup@0.8.5 - id: result shell: bash run: | diff --git a/.github/actions/flavors_parse/action.yml b/.github/actions/flavors_parse/action.yml index 4afd50e1..64281cf4 100644 --- a/.github/actions/flavors_parse/action.yml +++ b/.github/actions/flavors_parse/action.yml @@ -13,7 +13,7 @@ outputs: runs: using: composite steps: - - uses: gardenlinux/python-gardenlinux-lib/.github/actions/setup@0.8.4 + - uses: gardenlinux/python-gardenlinux-lib/.github/actions/setup@0.8.5 - id: matrix shell: bash run: | diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 2c7d471a..71c7fee0 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -3,7 +3,7 @@ description: Installs the given GardenLinux Python library inputs: version: description: GardenLinux Python library version - default: "0.8.4" + default: "0.8.5" runs: using: composite steps: diff --git a/pyproject.toml b/pyproject.toml index 35a8e511..9b4dcf62 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "gardenlinux" -version = "0.8.4" +version = "0.8.5" description = "Contains tools to work with the features directory of gardenlinux, for example deducting dependencies from feature sets or validating cnames" authors = ["Garden Linux Maintainers "] license = "Apache-2.0" diff --git a/src/gardenlinux/oci/layer.py b/src/gardenlinux/oci/layer.py index 6c4612e7..4c31316f 100644 --- a/src/gardenlinux/oci/layer.py +++ b/src/gardenlinux/oci/layer.py @@ -159,7 +159,7 @@ def generate_metadata_from_file_name(file_name: PathLike | str, arch: str) -> di @staticmethod def lookup_media_type_for_file_name(file_name: str) -> str: """ - Looks up the media type based on file extension. + Looks up the media type based on file name or extension. :param file_name: File path and name of the target layer @@ -170,9 +170,9 @@ def lookup_media_type_for_file_name(file_name: str) -> str: if not isinstance(file_name, PathLike): file_name = Path(file_name) - for suffix in GL_MEDIA_TYPES: - if file_name.match(f"*.{suffix}"): - return GL_MEDIA_TYPE_LOOKUP[suffix] + for lookup_name in GL_MEDIA_TYPES: + if file_name.match(f"*.{lookup_name}") or str(file_name) == lookup_name: + return GL_MEDIA_TYPE_LOOKUP[lookup_name] raise ValueError( f"Media type for {file_name} is not defined. You may want to add the definition to parse_features_lib"