persistence: align some more variable names
This commit is contained in:
@@ -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": [],
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user