From 64e3d84cab27cc5f8a371ed9762c36ab6938265c Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Fri, 16 May 2025 17:44:22 +0200 Subject: [PATCH] Refactor(cli): name set_inv_machine back to set_machine We don't want to leak information about our internals Such as 'inv' meaning 'inventory' this is not important from the outside --- pkgs/clan-app/ui/src/routes/machines/details.tsx | 2 +- pkgs/clan-cli/clan_cli/machines/inventory.py | 4 ++-- pkgs/clan-cli/clan_cli/machines/list.py | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkgs/clan-app/ui/src/routes/machines/details.tsx b/pkgs/clan-app/ui/src/routes/machines/details.tsx index fd7fbe8ba..74b1b389f 100644 --- a/pkgs/clan-app/ui/src/routes/machines/details.tsx +++ b/pkgs/clan-app/ui/src/routes/machines/details.tsx @@ -391,7 +391,7 @@ const MachineForm = (props: MachineDetailsProps) => { return; } - const machine_response = await callApi("set_inv_machine", { + const machine_response = await callApi("update_machine", { machine: { name: props.initialData.machine.name || "My machine", flake: { diff --git a/pkgs/clan-cli/clan_cli/machines/inventory.py b/pkgs/clan-cli/clan_cli/machines/inventory.py index 8ba46415d..918e3f1a2 100644 --- a/pkgs/clan-cli/clan_cli/machines/inventory.py +++ b/pkgs/clan-cli/clan_cli/machines/inventory.py @@ -10,7 +10,7 @@ from clan_cli.machines.machines import Machine @API.register -def get_inv_machine(machine: Machine) -> InventoryMachine: +def get_machine(machine: Machine) -> InventoryMachine: inventory_store = InventoryStore(flake=machine.flake) inventory = inventory_store.read() @@ -23,7 +23,7 @@ def get_inv_machine(machine: Machine) -> InventoryMachine: @API.register -def set_inv_machine(machine: Machine, update: InventoryMachine) -> None: +def update_machine(machine: Machine, update: InventoryMachine) -> None: assert machine.name == update.get("name", machine.name), "Machine name mismatch" inventory_store = InventoryStore(flake=machine.flake) inventory = inventory_store.read() diff --git a/pkgs/clan-cli/clan_cli/machines/list.py b/pkgs/clan-cli/clan_cli/machines/list.py index 85b6ed94e..9ce712011 100644 --- a/pkgs/clan-cli/clan_cli/machines/list.py +++ b/pkgs/clan-cli/clan_cli/machines/list.py @@ -13,7 +13,7 @@ from clan_lib.persist.inventory_store import InventoryStore from clan_cli.completions import add_dynamic_completer, complete_tags from clan_cli.dirs import specific_machine_dir from clan_cli.machines.hardware import HardwareConfig -from clan_cli.machines.inventory import get_inv_machine +from clan_cli.machines.inventory import get_machine from clan_cli.machines.machines import Machine log = logging.getLogger(__name__) @@ -61,7 +61,7 @@ def query_machines_by_tags(flake: Flake, tags: list[str]) -> dict[str, Machine]: filtered_machines = {} for machine in machines.values(): - inv_machine = get_inv_machine(machine) + inv_machine = get_machine(machine) if all(tag in inv_machine["tags"] for tag in tags): filtered_machines[machine.name] = machine @@ -88,7 +88,7 @@ def extract_header(c: str) -> str: @API.register def get_machine_details(machine: Machine) -> MachineDetails: - machine_inv = get_inv_machine(machine) + machine_inv = get_machine(machine) hw_config = HardwareConfig.detect_type(machine) machine_dir = specific_machine_dir(machine)