refactor(persist/utils): rename apply_patch to 'set_value_by_path'

This commit is contained in:
Johannes Kirschbauer
2025-05-27 19:16:06 +02:00
parent ed851eddf3
commit dd9ea44770
8 changed files with 22 additions and 22 deletions

View File

@@ -4,7 +4,7 @@ from clan_lib.api import API
from clan_lib.flake import Flake
from clan_lib.nix_models.inventory import Inventory, Meta
from clan_lib.persist.inventory_store import InventoryStore
from clan_lib.persist.util import apply_patch
from clan_lib.persist.util import set_value_by_path
@dataclass
@@ -17,7 +17,7 @@ class UpdateOptions:
def update_clan_meta(options: UpdateOptions) -> Inventory:
inventory_store = InventoryStore(options.flake)
inventory = inventory_store.read()
apply_patch(inventory, "meta", options.meta)
set_value_by_path(inventory, "meta", options.meta)
inventory_store.write(inventory, message="Update clan metadata")
return inventory

View File

@@ -16,7 +16,7 @@ from clan_lib.nix_models.inventory import (
MachineDeploy,
)
from clan_lib.persist.inventory_store import InventoryStore
from clan_lib.persist.util import apply_patch
from clan_lib.persist.util import set_value_by_path
from clan_lib.templates import (
InputPrio,
TemplateName,
@@ -130,7 +130,7 @@ def create_machine(
)
raise ClanError(msg, description=description)
apply_patch(
set_value_by_path(
inventory,
f"machines.{machine_name}",
new_machine,

View File

@@ -13,7 +13,7 @@ from clan_lib.nix_models.inventory import (
MachineDeploy,
)
from clan_lib.persist.inventory_store import InventoryStore
from clan_lib.persist.util import apply_patch
from clan_lib.persist.util import set_value_by_path
if TYPE_CHECKING:
from .age_keys import KeyPair
@@ -75,7 +75,7 @@ def test_add_module_to_inventory(
inventory_store = InventoryStore(Flake(str(test_flake_with_core.path)))
inventory = inventory_store.read()
apply_patch(
set_value_by_path(
inventory,
"services",
{