Encapsulate UEFI-only flag in Bootloader enum

Replace module-level _UEFI_ONLY_BOOTLOADERS tuple with an
is_uefi_only() method on the Bootloader enum, mirroring the
existing has_uki_support() / has_removable_support() pattern.
This commit is contained in:
Softer 2026-04-26 11:46:32 +03:00
parent da19fcdff7
commit 6818f35ebb
2 changed files with 8 additions and 4 deletions

View File

@ -19,9 +19,6 @@ class BootloaderValidationFailure:
description: str
_UEFI_ONLY_BOOTLOADERS = (Bootloader.Systemd, Bootloader.Efistub, Bootloader.Refind)
def validate_bootloader_layout(
bootloader_config: BootloaderConfiguration | None,
disk_config: DiskLayoutConfiguration | None,
@ -40,7 +37,7 @@ def validate_bootloader_layout(
if bootloader == Bootloader.NO_BOOTLOADER:
return None
if bootloader in _UEFI_ONLY_BOOTLOADERS and not is_uefi:
if bootloader.is_uefi_only() and not is_uefi:
return BootloaderValidationFailure(
kind=BootloaderValidationFailureKind.BootloaderRequiresUefi,
description=f'{bootloader.value} requires a UEFI system.',

View File

@ -25,6 +25,13 @@ class Bootloader(Enum):
case _:
return False
def is_uefi_only(self) -> bool:
match self:
case Bootloader.Systemd | Bootloader.Efistub | Bootloader.Refind:
return True
case _:
return False
def json(self) -> str:
return self.value