inventoryStore: align class names and methods

This commit is contained in:
Johannes Kirschbauer
2025-10-16 12:50:54 +02:00
parent 3d436b3c6b
commit 5eb6b703f0
4 changed files with 15 additions and 15 deletions

View File

@@ -51,7 +51,7 @@ def get_clan_details_schema(flake: Flake) -> dict[str, FieldSchema]:
"""
inventory_store = InventoryStore(flake)
write_info = inventory_store.get_write_map()
write_info = inventory_store.get_attribute_props()
field_names = retrieve_typed_field_names(InventoryMeta)

View File

@@ -170,7 +170,7 @@ def get_machine_fields_schema(machine: Machine) -> dict[str, FieldSchema]:
"""
inventory_store = InventoryStore(machine.flake)
write_info = inventory_store.get_write_map()
write_info = inventory_store.get_attribute_props()
field_names = retrieve_typed_field_names(InventoryMachine)

View File

@@ -77,8 +77,8 @@ def sanitize(data: Any, whitelist_paths: list[str], current_path: list[str]) ->
@dataclass
class WriteInfo:
writeables: AttributeMap
class PersistenceInfo:
attribute_props: AttributeMap
data_eval: "InventorySnapshot"
data_disk: "InventorySnapshot"
@@ -184,7 +184,7 @@ class InventoryStore:
return inventory
def _get_inventory_current_priority(self) -> dict:
def _get_introspection(self) -> dict:
"""Returns the current priority of the inventory values
machines = {
@@ -203,33 +203,33 @@ class InventoryStore:
"""
return self._flake.select("clanInternals.inventoryClass.introspection")
def _write_map(self) -> WriteInfo:
def _get_persistence_info(self) -> PersistenceInfo:
"""Get the paths of the writeable keys in the inventory
Load the inventory and determine the writeable keys
Performs 2 nix evaluations to get the current priority and the inventory
"""
current_priority = self._get_inventory_current_priority()
current_priority = self._get_introspection()
data_eval: InventorySnapshot = self._load_merged_inventory()
data_disk: InventorySnapshot = self._get_persisted()
write_map = compute_attribute_persistence(
attribute_props = compute_attribute_persistence(
current_priority,
dict(data_eval),
dict(data_disk),
inventory_file_name=self.inventory_file.name,
)
return WriteInfo(write_map, data_eval, data_disk)
return PersistenceInfo(attribute_props, data_eval, data_disk)
def get_write_map(self) -> Any:
def get_attribute_props(self) -> Any:
"""Get the writeability of the inventory
:return: A dictionary with the writeability of all paths
"""
write_info = self._write_map()
return write_info.writeables
persistence_info = self._get_persistence_info()
return persistence_info.attribute_props
def read(self) -> InventorySnapshot:
"""Accessor to the merged inventory
@@ -265,12 +265,12 @@ class InventoryStore:
"""Write the inventory to the flake directory
and commit it to git with the given message
"""
write_info = self._write_map()
write_info = self._get_persistence_info()
patchset, delete_set = calc_patches(
dict(write_info.data_disk),
dict(update),
dict(write_info.data_eval),
write_info.writeables,
write_info.attribute_props,
)
persisted = dict(write_info.data_disk)

View File

@@ -153,7 +153,7 @@ def test_simple_deferred(setup_test_files: Path) -> None:
_keys={"foo"}, # disable toplevel filtering
)
attribute_props = store._write_map().writeables
attribute_props = store._get_persistence_info().attribute_props
assert attribute_props == {
("foo",): {PersistenceAttribute.WRITE},
("foo", "a"): {PersistenceAttribute.WRITE, PersistenceAttribute.DELETE},