Feat(inventory): remove legacy action functions

Inventory should only and always be accessed through the inventory store.
Manually reading and writing to the json file is highly insecure
This commit is contained in:
Johannes Kirschbauer
2025-05-27 17:20:04 +02:00
parent 38b83c41cf
commit 3ed3cdddc9
4 changed files with 21 additions and 219 deletions

View File

@@ -5,7 +5,7 @@ from clan_cli.tests.age_keys import SopsSetup, assert_secrets_file_recipients
from clan_cli.tests.helpers import cli
from clan_cli.tests.stdout import CaptureOutput
from clan_lib.flake import Flake
from clan_lib.inventory import load_inventory_json
from clan_lib.persist.inventory_store import InventoryStore
@pytest.mark.impure
@@ -25,7 +25,8 @@ def test_machine_subcommands(
]
)
inventory: dict = dict(load_inventory_json(Flake(str(test_flake_with_core.path))))
inventory_store = InventoryStore(Flake(str(test_flake_with_core.path)))
inventory: dict = dict(inventory_store.read())
assert "machine1" in inventory["machines"]
assert "service" not in inventory
@@ -41,7 +42,7 @@ def test_machine_subcommands(
["machines", "delete", "--flake", str(test_flake_with_core.path), "machine1"]
)
inventory_2: dict = dict(load_inventory_json(Flake(str(test_flake_with_core.path))))
inventory_2: dict = dict(inventory_store.read())
assert "machine1" not in inventory_2["machines"]
assert "service" not in inventory_2