clan-lib: Refactor remote host handling to function parameters

This refactoring improves the separation of concerns by moving remote host creation logic from the Machine class to the calling functions, making the code more flexible and testable.
This commit is contained in:
Qubasa
2025-06-17 12:59:53 +02:00
committed by Jörg Thalheim
parent 8941b75d48
commit 86536bae42
2 changed files with 5 additions and 7 deletions

View File

@@ -205,9 +205,7 @@ def install_command(args: argparse.Namespace) -> None:
raise ClanError(msg) raise ClanError(msg)
if not args.yes: if not args.yes:
ask = input( ask = input(f"Install {args.machine} to {target_host.target}? [y/N] ")
f"Install {args.machine} to {machine.target_host().target}? [y/N] "
)
if ask != "y": if ask != "y":
return None return None

View File

@@ -212,10 +212,6 @@ def update_command(args: argparse.Namespace) -> None:
args.machines if args.machines else list_full_machines(args.flake).keys() args.machines if args.machines else list_full_machines(args.flake).keys()
) )
if args.target_host is not None and len(args.machines) > 1:
msg = "Target Host can only be set for one machines"
raise ClanError(msg)
for machine_name in selected_machines: for machine_name in selected_machines:
machine = Machine( machine = Machine(
name=machine_name, name=machine_name,
@@ -225,6 +221,10 @@ def update_command(args: argparse.Namespace) -> None:
) )
machines.append(machine) machines.append(machine)
if args.target_host is not None and len(machines) > 1:
msg = "Target Host can only be set for one machines"
raise ClanError(msg)
def filter_machine(m: Machine) -> bool: def filter_machine(m: Machine) -> bool:
if m.deployment.get("requireExplicitUpdate", False): if m.deployment.get("requireExplicitUpdate", False):
return False return False