From 17c35c42596045008f5c2a696d8537a1250a4e65 Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Thu, 16 Oct 2025 13:04:24 +0200 Subject: [PATCH] persistence: align some more variable names --- pkgs/clan-cli/clan_lib/clan/get.py | 4 ++-- pkgs/clan-cli/clan_lib/machines/actions.py | 4 ++-- pkgs/clan-cli/clan_lib/machines/actions_test.py | 10 ++++++---- pkgs/clan-cli/clan_lib/persist/inventory_store.py | 10 +++++----- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/pkgs/clan-cli/clan_lib/clan/get.py b/pkgs/clan-cli/clan_lib/clan/get.py index 3ab7d4315..ba8006de0 100644 --- a/pkgs/clan-cli/clan_lib/clan/get.py +++ b/pkgs/clan-cli/clan_lib/clan/get.py @@ -51,13 +51,13 @@ def get_clan_details_schema(flake: Flake) -> dict[str, FieldSchema]: """ inventory_store = InventoryStore(flake) - write_info = inventory_store.get_attribute_props() + attribute_props = inventory_store.get_attribute_props() field_names = retrieve_typed_field_names(InventoryMeta) return { field: { - "readonly": is_readonly_key(f"meta.{field}", write_info), + "readonly": is_readonly_key(f"meta.{field}", attribute_props), # TODO: Provide a meaningful reason "reason": None, "readonly_members": [], diff --git a/pkgs/clan-cli/clan_lib/machines/actions.py b/pkgs/clan-cli/clan_lib/machines/actions.py index 1d117c553..8f2932cf3 100644 --- a/pkgs/clan-cli/clan_lib/machines/actions.py +++ b/pkgs/clan-cli/clan_lib/machines/actions.py @@ -170,7 +170,7 @@ def get_machine_fields_schema(machine: Machine) -> dict[str, FieldSchema]: """ inventory_store = InventoryStore(machine.flake) - write_info = inventory_store.get_attribute_props() + attribute_props = inventory_store.get_attribute_props() field_names = retrieve_typed_field_names(InventoryMachine) @@ -197,7 +197,7 @@ def get_machine_fields_schema(machine: Machine) -> dict[str, FieldSchema]: if field in protected_fields else is_readonly_key( f"machines.{machine.name}.{field}", - write_info, + attribute_props, ) ), # TODO: Provide a meaningful reason diff --git a/pkgs/clan-cli/clan_lib/machines/actions_test.py b/pkgs/clan-cli/clan_lib/machines/actions_test.py index c09c23392..5bbbb2254 100644 --- a/pkgs/clan-cli/clan_lib/machines/actions_test.py +++ b/pkgs/clan-cli/clan_lib/machines/actions_test.py @@ -249,13 +249,15 @@ def test_get_machine_writeability(clan_flake: Callable[..., Flake]) -> None: persisted = inventory_store._get_persisted() assert get_value_by_path(persisted, "machines.jon.tags", []) == new_tags - write_info = get_machine_fields_schema(Machine("jon", flake)) + attribute_props = get_machine_fields_schema(Machine("jon", flake)) # {'tags': {'writable': True, 'reason': None}, 'machineClass': {'writable': False, 'reason': None}, 'name': {'writable': False, 'reason': None}, 'description': {'writable': True, 'reason': None}, 'deploy.buildHost': {'writable': True, 'reason': None}, 'icon': {'writable': True, 'reason': None}, 'deploy.targetHost': {'writable': True, 'reason': None}} writeable_fields = { - field for field, info in write_info.items() if not info["readonly"] + field for field, info in attribute_props.items() if not info["readonly"] + } + read_only_fields = { + field for field, info in attribute_props.items() if info["readonly"] } - read_only_fields = {field for field, info in write_info.items() if info["readonly"]} assert writeable_fields == { "tags", @@ -267,7 +269,7 @@ def test_get_machine_writeability(clan_flake: Callable[..., Flake]) -> None: } assert read_only_fields == {"machineClass", "name"} - assert write_info["tags"]["readonly_members"] == ["nix1", "all", "nixos"] + assert attribute_props["tags"]["readonly_members"] == ["nix1", "all", "nixos"] @pytest.mark.with_core diff --git a/pkgs/clan-cli/clan_lib/persist/inventory_store.py b/pkgs/clan-cli/clan_lib/persist/inventory_store.py index de14145b8..67779929c 100644 --- a/pkgs/clan-cli/clan_lib/persist/inventory_store.py +++ b/pkgs/clan-cli/clan_lib/persist/inventory_store.py @@ -265,15 +265,15 @@ class InventoryStore: """Write the inventory to the flake directory and commit it to git with the given message """ - write_info = self._get_persistence_info() + persistence_info = self._get_persistence_info() patchset, delete_set = calc_patches( - dict(write_info.data_disk), + dict(persistence_info.data_disk), dict(update), - dict(write_info.data_eval), - write_info.attribute_props, + dict(persistence_info.data_eval), + persistence_info.attribute_props, ) - persisted = dict(write_info.data_disk) + persisted = dict(persistence_info.data_disk) for patch_path, data in patchset.items(): set_value_by_path_tuple(persisted, patch_path, data)