clanModules: remove unused test code

This commit is contained in:
Johannes Kirschbauer
2025-08-16 11:58:55 +02:00
parent 308a10d6e6
commit 4a51aa9316
6 changed files with 6 additions and 116 deletions

View File

@@ -1,6 +1,5 @@
{ {
lib, lib,
clanLib,
}: }:
let let
baseModule = baseModule =
@@ -52,7 +51,6 @@ let
# '' # ''
evaled; evaled;
in in
{ {
evalClanModules = evalClanModulesLegacy; evalClanModules = evalClanModulesLegacy;

View File

@@ -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.<serviceName> = { ... # 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 in
{ {
imports = [ imports = [

View File

@@ -12,6 +12,9 @@
builtins.removeAttrs (clanLib.introspection.getPrios { options = config.inventory.options; }) builtins.removeAttrs (clanLib.introspection.getPrios { options = config.inventory.options; })
# tags are freeformType which is not supported yet. # tags are freeformType which is not supported yet.
# services is removed and throws an error if accessed. # services is removed and throws an error if accessed.
[ "tags" "services"]; [
"tags"
"services"
];
}; };
} }

View File

@@ -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 == {}

View File

@@ -11,7 +11,6 @@ from clan_lib.nix_models.clan import (
InventoryInstancesType, InventoryInstancesType,
InventoryMachinesType, InventoryMachinesType,
InventoryMetaType, InventoryMetaType,
InventoryServicesType,
InventoryTagsType, InventoryTagsType,
) )
@@ -106,7 +105,6 @@ class InventorySnapshot(TypedDict):
machines: NotRequired[InventoryMachinesType] machines: NotRequired[InventoryMachinesType]
instances: NotRequired[InventoryInstancesType] instances: NotRequired[InventoryInstancesType]
meta: NotRequired[InventoryMetaType] meta: NotRequired[InventoryMetaType]
services: NotRequired[InventoryServicesType]
tags: NotRequired[InventoryTagsType] tags: NotRequired[InventoryTagsType]

View File

@@ -5,7 +5,7 @@ import shutil
import sys import sys
from dataclasses import dataclass from dataclasses import dataclass
from pathlib import Path from pathlib import Path
from typing import Any, cast from typing import cast
import clan_cli.clan.create import clan_cli.clan.create
import pytest import pytest
@@ -26,7 +26,6 @@ from clan_lib.nix import nix_command
from clan_lib.nix_models.clan import ( from clan_lib.nix_models.clan import (
InventoryInstancesType, InventoryInstancesType,
InventoryMachine, InventoryMachine,
InventoryServicesType,
Unknown, Unknown,
) )
from clan_lib.nix_models.clan import InventoryMachineDeploy as MachineDeploy from clan_lib.nix_models.clan import InventoryMachineDeploy as MachineDeploy
@@ -41,7 +40,6 @@ log = logging.getLogger(__name__)
@dataclass @dataclass
class InventoryWrapper: class InventoryWrapper:
services: InventoryServicesType
instances: InventoryInstancesType 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())) ssh_keys.append(InvSSHKeyEntry(f"user_{num}", ssh_key.public.read_text()))
"""Create the base inventory structure.""" """Create the base inventory structure."""
legacy_services: dict[str, Any] = {}
instances = InventoryInstancesType( instances = InventoryInstancesType(
{ {
"admin-inst": { "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 # 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" == "clan-core/admin"
) )
set_value_by_path(inventory, "services", inventory_conf.services)
set_value_by_path(inventory, "instances", inventory_conf.instances) set_value_by_path(inventory, "instances", inventory_conf.instances)
store.write( store.write(
inventory, inventory,