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,
|
||||
flake=flake,
|
||||
)
|
||||
if not machine.get("deploy", {}).get("targetHost"):
|
||||
msg = f"'TargetHost' is not set for machine '{name}'"
|
||||
raise ClanError(msg)
|
||||
# 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
|
||||
# prefer target host set via inventory, but fallback to the one set in the machine
|
||||
if target_host := machine.get("deploy", {}).get("targetHost"):
|
||||
m.override_target_host = target_host
|
||||
group_machines.append(m)
|
||||
|
||||
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.dirs import user_config_dir
|
||||
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
|
||||
|
||||
@@ -196,26 +197,11 @@ def load_age_plugins(flake_dir: str | Path) -> list[str]:
|
||||
msg = "Missing flake directory"
|
||||
raise ClanError(msg)
|
||||
|
||||
cmd = nix_eval(
|
||||
[
|
||||
f"{flake_dir}#clanInternals.secrets.age.plugins",
|
||||
"--json",
|
||||
]
|
||||
)
|
||||
|
||||
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
|
||||
flake = Flake(str(flake_dir))
|
||||
result = flake.select("clanInternals.?secrets.?age.?plugins")
|
||||
plugins = result["secrets"]["age"]["plugins"]
|
||||
if plugins == {}:
|
||||
plugins = []
|
||||
|
||||
if isinstance(plugins, list):
|
||||
return plugins
|
||||
|
||||
@@ -459,10 +459,6 @@ const MachineForm = (props: MachineDetailsProps) => {
|
||||
}
|
||||
|
||||
const target = targetHost();
|
||||
if (!target) {
|
||||
toast.error("Target host is required");
|
||||
return;
|
||||
}
|
||||
|
||||
const loading_toast = toast.loading("Updating machine...");
|
||||
const r = await callApi("update_machines", {
|
||||
|
||||
Reference in New Issue
Block a user