From 4a51aa931666a26b1f9b01f2db609cd3740338f9 Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Sat, 16 Aug 2025 11:58:55 +0200 Subject: [PATCH] clanModules: remove unused test code --- .../inventory/eval-clan-modules/default.nix | 2 - lib/modules/inventoryClass/interface.nix | 60 ------------------- .../inventory-introspection.nix | 5 +- .../clan-cli/clan_cli/tests/test_inventory.py | 44 -------------- .../clan_lib/persist/inventory_store.py | 2 - pkgs/clan-cli/clan_lib/tests/test_create.py | 9 +-- 6 files changed, 6 insertions(+), 116 deletions(-) delete mode 100644 pkgs/clan-cli/clan_cli/tests/test_inventory.py diff --git a/lib/modules/inventory/eval-clan-modules/default.nix b/lib/modules/inventory/eval-clan-modules/default.nix index f356ddc98..c13785615 100644 --- a/lib/modules/inventory/eval-clan-modules/default.nix +++ b/lib/modules/inventory/eval-clan-modules/default.nix @@ -1,6 +1,5 @@ { lib, - clanLib, }: let baseModule = @@ -52,7 +51,6 @@ let # '' evaled; - in { evalClanModules = evalClanModulesLegacy; diff --git a/lib/modules/inventoryClass/interface.nix b/lib/modules/inventoryClass/interface.nix index 25fd4a08e..4beba0381 100644 --- a/lib/modules/inventoryClass/interface.nix +++ b/lib/modules/inventoryClass/interface.nix @@ -31,66 +31,6 @@ let ''; }; }; - - moduleConfig = lib.mkOption { - default = { }; - # TODO: use types.deferredModule - # clan.borgbackup MUST be defined as submodule - type = types.attrsOf types.anything; - description = '' - Configuration of the specific clanModule. - - !!! Note - Configuration is passed to the nixos configuration scoped to the module. - - ```nix - clan. = { ... # Config } - ``` - ''; - }; - - extraModulesOption = lib.mkOption { - description = '' - List of additionally imported `.nix` expressions. - - Supported types: - - - **Strings**: Interpreted relative to the 'directory' passed to `lib.clan`. - - **Paths**: should be relative to the current file. - - **Any**: Nix expression must be serializable to JSON. - - !!! Note - **The import only happens if the machine is part of the service or role.** - - Other types are passed through to the nixos configuration. - - ???+ Example - To import the `special.nix` file - - ``` - . Clan Directory - ├── flake.nix - ... - └── modules - ├── special.nix - └── ... - ``` - - ```nix - { - extraModules = [ "modules/special.nix" ]; - } - ``` - ''; - apply = value: if lib.isString value then value else builtins.seq (builtins.toJSON value) value; - default = [ ]; - type = types.listOf ( - types.oneOf [ - types.str - types.anything - ] - ); - }; in { imports = [ diff --git a/lib/modules/inventoryClass/inventory-introspection.nix b/lib/modules/inventoryClass/inventory-introspection.nix index a9b77bd32..29ab52eec 100644 --- a/lib/modules/inventoryClass/inventory-introspection.nix +++ b/lib/modules/inventoryClass/inventory-introspection.nix @@ -12,6 +12,9 @@ builtins.removeAttrs (clanLib.introspection.getPrios { options = config.inventory.options; }) # tags are freeformType which is not supported yet. # services is removed and throws an error if accessed. - [ "tags" "services"]; + [ + "tags" + "services" + ]; }; } diff --git a/pkgs/clan-cli/clan_cli/tests/test_inventory.py b/pkgs/clan-cli/clan_cli/tests/test_inventory.py deleted file mode 100644 index d91939e6f..000000000 --- a/pkgs/clan-cli/clan_cli/tests/test_inventory.py +++ /dev/null @@ -1,44 +0,0 @@ -from clan_lib.nix_models.clan import Inventory -from clan_lib.nix_models.clan import InventoryMachine as Machine -from clan_lib.nix_models.clan import InventoryMeta as Meta -from clan_lib.nix_models.clan import InventoryService as Service - - -def test_make_meta_minimal() -> None: - # Name is required - res = Meta( - { - "name": "foo", - } - ) - - assert res == {"name": "foo"} - - -def test_make_inventory_minimal() -> None: - # Meta is required - res = Inventory( - { - "meta": Meta( - { - "name": "foo", - } - ), - } - ) - - assert res == {"meta": {"name": "foo"}} - - -def test_make_machine_minimal() -> None: - # Empty is valid - res = Machine({}) - - assert res == {} - - -def test_make_service_minimal() -> None: - # Empty is valid - res = Service({}) - - assert res == {} diff --git a/pkgs/clan-cli/clan_lib/persist/inventory_store.py b/pkgs/clan-cli/clan_lib/persist/inventory_store.py index c85ed0c83..7b564df21 100644 --- a/pkgs/clan-cli/clan_lib/persist/inventory_store.py +++ b/pkgs/clan-cli/clan_lib/persist/inventory_store.py @@ -11,7 +11,6 @@ from clan_lib.nix_models.clan import ( InventoryInstancesType, InventoryMachinesType, InventoryMetaType, - InventoryServicesType, InventoryTagsType, ) @@ -106,7 +105,6 @@ class InventorySnapshot(TypedDict): machines: NotRequired[InventoryMachinesType] instances: NotRequired[InventoryInstancesType] meta: NotRequired[InventoryMetaType] - services: NotRequired[InventoryServicesType] tags: NotRequired[InventoryTagsType] diff --git a/pkgs/clan-cli/clan_lib/tests/test_create.py b/pkgs/clan-cli/clan_lib/tests/test_create.py index b1508367f..66497d17a 100644 --- a/pkgs/clan-cli/clan_lib/tests/test_create.py +++ b/pkgs/clan-cli/clan_lib/tests/test_create.py @@ -5,7 +5,7 @@ import shutil import sys from dataclasses import dataclass from pathlib import Path -from typing import Any, cast +from typing import cast import clan_cli.clan.create import pytest @@ -26,7 +26,6 @@ from clan_lib.nix import nix_command from clan_lib.nix_models.clan import ( InventoryInstancesType, InventoryMachine, - InventoryServicesType, Unknown, ) from clan_lib.nix_models.clan import InventoryMachineDeploy as MachineDeploy @@ -41,7 +40,6 @@ log = logging.getLogger(__name__) @dataclass class InventoryWrapper: - services: InventoryServicesType instances: InventoryInstancesType @@ -65,8 +63,6 @@ def create_base_inventory(ssh_keys_pairs: list[SSHKeyPair]) -> InventoryWrapper: ssh_keys.append(InvSSHKeyEntry(f"user_{num}", ssh_key.public.read_text())) """Create the base inventory structure.""" - legacy_services: dict[str, Any] = {} - instances = InventoryInstancesType( { "admin-inst": { @@ -88,7 +84,7 @@ def create_base_inventory(ssh_keys_pairs: list[SSHKeyPair]) -> InventoryWrapper: } ) - return InventoryWrapper(services=legacy_services, instances=instances) + return InventoryWrapper(instances=instances) # TODO: We need a way to calculate the narHash of the current clan-core @@ -212,7 +208,6 @@ def test_clan_create_api( == "clan-core/admin" ) - set_value_by_path(inventory, "services", inventory_conf.services) set_value_by_path(inventory, "instances", inventory_conf.instances) store.write( inventory,