Merge pull request 'Refactor(machine/class): use frozen dataclass for class 'machine'' (#3520) from hsjobeki/clan-core:api-cleanup-2 into main
Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/3520
This commit is contained in:
@@ -96,13 +96,12 @@ def generate_machine_hardware_info(opts: HardwareGenerateOptions) -> HardwareCon
|
|||||||
and place the resulting *.nix file in the machine's directory.
|
and place the resulting *.nix file in the machine's directory.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
machine = Machine(opts.machine, flake=opts.flake)
|
machine = Machine(
|
||||||
|
opts.machine,
|
||||||
if opts.keyfile is not None:
|
flake=opts.flake,
|
||||||
machine.private_key = Path(opts.keyfile)
|
private_key=Path(opts.keyfile) if opts.keyfile else None,
|
||||||
|
override_target_host=opts.target_host,
|
||||||
if opts.target_host is not None:
|
)
|
||||||
machine.override_target_host = opts.target_host
|
|
||||||
|
|
||||||
hw_file = opts.backend.config_path(opts.flake.path, opts.machine)
|
hw_file = opts.backend.config_path(opts.flake.path, opts.machine)
|
||||||
hw_file.parent.mkdir(parents=True, exist_ok=True)
|
hw_file.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ if TYPE_CHECKING:
|
|||||||
from clan_cli.vars.generate import Generator
|
from clan_cli.vars.generate import Generator
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass(frozen=True)
|
||||||
class Machine:
|
class Machine:
|
||||||
name: str
|
name: str
|
||||||
flake: Flake
|
flake: Flake
|
||||||
|
|||||||
Reference in New Issue
Block a user