fix(morph/test): temporary workaround for morph test

This commit is contained in:
Johannes Kirschbauer
2025-05-26 16:05:54 +02:00
parent 73d72298cc
commit 8aed51c63e
2 changed files with 32 additions and 22 deletions

View File

@@ -40,7 +40,19 @@ class CreateOptions:
@API.register
def create_machine(opts: CreateOptions, commit: bool = True) -> None:
def create_machine(
opts: CreateOptions, commit: bool = True, _persist: bool = True
) -> None:
"""
Create a new machine in the clan directory.
This function will create a new machine based on a template.
:param opts: Options for creating the machine, including clan directory, machine details, and template name.
:param commit: Whether to commit the changes to the git repository.
:param _persist: Temporary workaround for 'morph'. Whether to persist the changes to the inventory store.
"""
if not opts.clan_dir.is_local:
msg = f"Clan {opts.clan_dir} is not a local clan."
description = "Import machine only works on local clans"
@@ -91,9 +103,7 @@ def create_machine(opts: CreateOptions, commit: bool = True) -> None:
if dst.exists():
msg = f"Machine {machine_name} already exists in {clan_dir}"
description = (
"Please remove the existing machine folder"
)
description = "Please remove the existing machine folder"
raise ClanError(msg, description=description)
# TODO(@Qubasa): move this into the template handler
@@ -105,8 +115,8 @@ def create_machine(opts: CreateOptions, commit: bool = True) -> None:
# TODO(@Qubasa): move this into the template handler
copy_from_nixstore(src, dst)
if _persist:
target_host = opts.target_host
new_machine = opts.machine
new_machine["deploy"] = {"targetHost": target_host} # type: ignore

View File

@@ -74,7 +74,7 @@ def morph_machine(
machine=InventoryMachine(name=name),
clan_dir=Flake(str(flakedir)),
)
create_machine(create_opts, commit=False)
create_machine(create_opts, commit=False, _persist=False)
machine = Machine(name=name, flake=Flake(str(flakedir)))