Refactor(machine/class): use frozen dataclass for class 'machine'
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.
|
||||
"""
|
||||
|
||||
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)
|
||||
|
||||
@@ -26,7 +26,7 @@ if TYPE_CHECKING:
|
||||
from clan_cli.vars.generate import Generator
|
||||
|
||||
|
||||
@dataclass
|
||||
@dataclass(frozen=True)
|
||||
class Machine:
|
||||
name: str
|
||||
flake: Flake
|
||||
|
||||
Reference in New Issue
Block a user