1
0
mirror of https://github.com/home-assistant/supervisor.git synced 2025-12-20 02:18:59 +00:00

Make platform parameter required and warn on missing platform

- Make platform a required parameter in get_manifest() and _fetch_manifest()
  since it's always provided by the calling code
- Return None and log warning when requested platform is not found in
  multi-arch manifest list, instead of falling back to first manifest
  which could be the wrong architecture

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Stefan Agner
2025-12-05 15:51:26 +01:00
parent 727d6903a2
commit 1949eb69ba

View File

@@ -182,7 +182,7 @@ class RegistryManifestFetcher:
repository: str, repository: str,
reference: str, reference: str,
token: str | None, token: str | None,
platform: str | None = None, platform: str,
) -> dict | None: ) -> dict | None:
"""Fetch manifest from registry. """Fetch manifest from registry.
@@ -221,15 +221,10 @@ class RegistryManifestFetcher:
_LOGGER.warning("Empty manifest list for %s/%s", registry, repository) _LOGGER.warning("Empty manifest list for %s/%s", registry, repository)
return None return None
# Find matching platform # Platform format is "linux/amd64", "linux/arm64", etc.
target_os = "linux" parts = platform.split("/")
target_arch = "amd64" # Default if len(parts) >= 2:
target_os, target_arch = parts[0], parts[1]
if platform:
# Platform format is "linux/amd64", "linux/arm64", etc.
parts = platform.split("/")
if len(parts) >= 2:
target_os, target_arch = parts[0], parts[1]
platform_manifest = None platform_manifest = None
for m in manifests: for m in manifests:
@@ -242,13 +237,15 @@ class RegistryManifestFetcher:
break break
if not platform_manifest: if not platform_manifest:
# Fall back to first manifest _LOGGER.warning(
_LOGGER.debug( "Platform %s/%s not found in manifest list for %s/%s, "
"Platform %s/%s not found, using first manifest", "cannot use manifest for progress tracking",
target_os, target_os,
target_arch, target_arch,
registry,
repository,
) )
platform_manifest = manifests[0] return None
# Fetch the platform-specific manifest # Fetch the platform-specific manifest
return await self._fetch_manifest( return await self._fetch_manifest(
@@ -265,7 +262,7 @@ class RegistryManifestFetcher:
self, self,
image: str, image: str,
tag: str, tag: str,
platform: str | None = None, platform: str,
) -> ImageManifest | None: ) -> ImageManifest | None:
"""Fetch manifest and extract layer sizes. """Fetch manifest and extract layer sizes.