API: rename set_inventory

This commit is contained in:
Johannes Kirschbauer
2024-09-13 16:09:45 +02:00
parent ba548de2bf
commit 813172119e
7 changed files with 17 additions and 14 deletions

View File

@@ -10,7 +10,7 @@ from clan_cli.inventory import (
MachineDeploy,
load_inventory_eval,
load_inventory_json,
save_inventory,
set_inventory,
)
log = logging.getLogger(__name__)
@@ -34,7 +34,7 @@ def create_machine(flake: FlakeId, machine: Machine) -> None:
print(f"Define machine {machine.name}", machine)
inventory.machines.update({machine.name: machine})
save_inventory(inventory, flake.path, f"Create machine {machine.name}")
set_inventory(inventory, flake.path, f"Create machine {machine.name}")
def create_command(args: argparse.Namespace) -> None:

View File

@@ -6,7 +6,7 @@ from clan_cli.clan_uri import FlakeId
from clan_cli.completions import add_dynamic_completer, complete_machines
from clan_cli.dirs import specific_machine_dir
from clan_cli.errors import ClanError
from clan_cli.inventory import load_inventory_json, save_inventory
from clan_cli.inventory import load_inventory_json, set_inventory
@API.register
@@ -18,7 +18,7 @@ def delete_machine(flake: FlakeId, name: str) -> None:
msg = f"Machine {name} does not exist"
raise ClanError(msg)
save_inventory(inventory, flake.path, f"Delete machine {name}")
set_inventory(inventory, flake.path, f"Delete machine {name}")
folder = specific_machine_dir(flake.path, name)
if folder.exists():

View File

@@ -8,7 +8,7 @@ from typing import Literal
from clan_cli.api import API
from clan_cli.cmd import run_no_stdout
from clan_cli.errors import ClanCmdError, ClanError
from clan_cli.inventory import Machine, load_inventory_eval, save_inventory
from clan_cli.inventory import Machine, load_inventory_eval, set_inventory
from clan_cli.nix import nix_eval, nix_shell
log = logging.getLogger(__name__)
@@ -20,7 +20,7 @@ def set_machine(flake_url: str | Path, machine_name: str, machine: Machine) -> N
inventory.machines[machine_name] = machine
save_inventory(inventory, flake_url, "machines: edit '{machine_name}'")
set_inventory(inventory, flake_url, "machines: edit '{machine_name}'")
@API.register