gui: make update machine work
Also fix error when age plugins not defined
This commit is contained in:
@@ -108,13 +108,9 @@ def update_machines(base_path: str, machines: list[InventoryMachine]) -> None:
|
|||||||
name,
|
name,
|
||||||
flake=flake,
|
flake=flake,
|
||||||
)
|
)
|
||||||
if not machine.get("deploy", {}).get("targetHost"):
|
# prefer target host set via inventory, but fallback to the one set in the machine
|
||||||
msg = f"'TargetHost' is not set for machine '{name}'"
|
if target_host := machine.get("deploy", {}).get("targetHost"):
|
||||||
raise ClanError(msg)
|
m.override_target_host = target_host
|
||||||
# Copy targetHost to machine
|
|
||||||
m.override_target_host = machine.get("deploy", {}).get("targetHost")
|
|
||||||
# Would be nice to have?
|
|
||||||
# m.override_build_host = machine.deploy.buildHost
|
|
||||||
group_machines.append(m)
|
group_machines.append(m)
|
||||||
|
|
||||||
deploy_machines(group_machines)
|
deploy_machines(group_machines)
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ from clan_lib.api import API
|
|||||||
from clan_cli.cmd import Log, RunOpts, run
|
from clan_cli.cmd import Log, RunOpts, run
|
||||||
from clan_cli.dirs import user_config_dir
|
from clan_cli.dirs import user_config_dir
|
||||||
from clan_cli.errors import ClanError
|
from clan_cli.errors import ClanError
|
||||||
from clan_cli.nix import nix_eval, nix_shell
|
from clan_cli.flake import Flake
|
||||||
|
from clan_cli.nix import nix_shell
|
||||||
|
|
||||||
from .folders import sops_users_folder
|
from .folders import sops_users_folder
|
||||||
|
|
||||||
@@ -196,26 +197,11 @@ def load_age_plugins(flake_dir: str | Path) -> list[str]:
|
|||||||
msg = "Missing flake directory"
|
msg = "Missing flake directory"
|
||||||
raise ClanError(msg)
|
raise ClanError(msg)
|
||||||
|
|
||||||
cmd = nix_eval(
|
flake = Flake(str(flake_dir))
|
||||||
[
|
result = flake.select("clanInternals.?secrets.?age.?plugins")
|
||||||
f"{flake_dir}#clanInternals.secrets.age.plugins",
|
plugins = result["secrets"]["age"]["plugins"]
|
||||||
"--json",
|
if plugins == {}:
|
||||||
]
|
plugins = []
|
||||||
)
|
|
||||||
|
|
||||||
try:
|
|
||||||
result = run(cmd)
|
|
||||||
except Exception as e:
|
|
||||||
msg = f"Failed to load age plugins {flake_dir}"
|
|
||||||
raise ClanError(msg) from e
|
|
||||||
|
|
||||||
json_str = result.stdout.strip()
|
|
||||||
|
|
||||||
try:
|
|
||||||
plugins = json.loads(json_str)
|
|
||||||
except json.JSONDecodeError as e:
|
|
||||||
msg = f"Failed to decode '{json_str}': {e}"
|
|
||||||
raise ClanError(msg) from e
|
|
||||||
|
|
||||||
if isinstance(plugins, list):
|
if isinstance(plugins, list):
|
||||||
return plugins
|
return plugins
|
||||||
|
|||||||
@@ -459,10 +459,6 @@ const MachineForm = (props: MachineDetailsProps) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const target = targetHost();
|
const target = targetHost();
|
||||||
if (!target) {
|
|
||||||
toast.error("Target host is required");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const loading_toast = toast.loading("Updating machine...");
|
const loading_toast = toast.loading("Updating machine...");
|
||||||
const r = await callApi("update_machines", {
|
const r = await callApi("update_machines", {
|
||||||
|
|||||||
Reference in New Issue
Block a user