Refactor(machine/class): use frozen dataclass for class 'machine'

This commit is contained in:
Johannes Kirschbauer
2025-05-06 17:12:52 +02:00
parent 79a54616e5
commit f0d42c839b
2 changed files with 7 additions and 8 deletions

View File

@@ -96,13 +96,12 @@ def generate_machine_hardware_info(opts: HardwareGenerateOptions) -> HardwareCon
and place the resulting *.nix file in the machine's directory.
"""
machine = Machine(opts.machine, flake=opts.flake)
if opts.keyfile is not None:
machine.private_key = Path(opts.keyfile)
if opts.target_host is not None:
machine.override_target_host = opts.target_host
machine = Machine(
opts.machine,
flake=opts.flake,
private_key=Path(opts.keyfile) if opts.keyfile else None,
override_target_host=opts.target_host,
)
hw_file = opts.backend.config_path(opts.flake.path, opts.machine)
hw_file.parent.mkdir(parents=True, exist_ok=True)

View File

@@ -26,7 +26,7 @@ if TYPE_CHECKING:
from clan_cli.vars.generate import Generator
@dataclass
@dataclass(frozen=True)
class Machine:
name: str
flake: Flake