chore(nix_models): migrate import to use exported clan models
This commit is contained in:
@@ -9,7 +9,7 @@ from clan_lib.cmd import run
|
||||
from clan_lib.errors import ClanCmdError, ClanError
|
||||
from clan_lib.flake import Flake
|
||||
from clan_lib.nix import nix_eval
|
||||
from clan_lib.nix_models.inventory import Meta
|
||||
from clan_lib.nix_models.clan import InventoryMeta as Meta
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -2,7 +2,8 @@ from dataclasses import dataclass
|
||||
|
||||
from clan_lib.api import API
|
||||
from clan_lib.flake import Flake
|
||||
from clan_lib.nix_models.inventory import Inventory, Meta
|
||||
from clan_lib.nix_models.clan import Inventory
|
||||
from clan_lib.nix_models.clan import InventoryMeta as Meta
|
||||
from clan_lib.persist.inventory_store import InventoryStore
|
||||
from clan_lib.persist.util import set_value_by_path
|
||||
|
||||
|
||||
@@ -9,12 +9,8 @@ from clan_lib.dirs import get_clan_flake_toplevel_or_env
|
||||
from clan_lib.errors import ClanError
|
||||
from clan_lib.flake import Flake
|
||||
from clan_lib.git import commit_file
|
||||
from clan_lib.nix_models.inventory import (
|
||||
Machine as InventoryMachine,
|
||||
)
|
||||
from clan_lib.nix_models.inventory import (
|
||||
MachineDeploy,
|
||||
)
|
||||
from clan_lib.nix_models.clan import InventoryMachine
|
||||
from clan_lib.nix_models.clan import InventoryMachineDeploy as MachineDeploy
|
||||
from clan_lib.persist.inventory_store import InventoryStore
|
||||
from clan_lib.persist.util import set_value_by_path
|
||||
from clan_lib.templates import (
|
||||
|
||||
@@ -11,7 +11,7 @@ from clan_lib.errors import ClanError
|
||||
from clan_lib.flake import Flake
|
||||
from clan_lib.machines.actions import get_machine
|
||||
from clan_lib.machines.machines import Machine
|
||||
from clan_lib.nix_models.inventory import Machine as InventoryMachine
|
||||
from clan_lib.nix_models.clan import InventoryMachine
|
||||
from clan_lib.persist.inventory_store import InventoryStore
|
||||
|
||||
from clan_cli.completions import add_dynamic_completer, complete_tags
|
||||
|
||||
@@ -13,7 +13,7 @@ from clan_lib.errors import ClanError
|
||||
from clan_lib.flake import Flake
|
||||
from clan_lib.machines.machines import Machine
|
||||
from clan_lib.nix import nix_build, nix_command
|
||||
from clan_lib.nix_models.inventory import Machine as InventoryMachine
|
||||
from clan_lib.nix_models.clan import InventoryMachine
|
||||
|
||||
from clan_cli.machines.create import CreateOptions, create_machine
|
||||
from clan_cli.vars.generate import generate_vars
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
from clan_lib.nix_models.inventory import Inventory, Machine, Meta, Service
|
||||
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:
|
||||
|
||||
@@ -8,9 +8,11 @@ from clan_cli.tests.fixtures_flakes import FlakeForTest
|
||||
from clan_lib.api.modules import list_modules
|
||||
from clan_lib.flake import Flake
|
||||
from clan_lib.nix import nix_eval, run
|
||||
from clan_lib.nix_models.inventory import (
|
||||
Machine,
|
||||
MachineDeploy,
|
||||
from clan_lib.nix_models.clan import (
|
||||
InventoryMachine as Machine,
|
||||
)
|
||||
from clan_lib.nix_models.clan import (
|
||||
InventoryMachineDeploy as MachineDeploy,
|
||||
)
|
||||
from clan_lib.persist.inventory_store import InventoryStore
|
||||
from clan_lib.persist.util import set_value_by_path
|
||||
|
||||
@@ -7,7 +7,7 @@ from clan_lib.cmd import CmdOut, RunOpts, run
|
||||
from clan_lib.errors import ClanError
|
||||
from clan_lib.flake import Flake
|
||||
from clan_lib.nix import nix_command, nix_metadata, nix_shell
|
||||
from clan_lib.nix_models.inventory import Inventory
|
||||
from clan_lib.nix_models.clan import Inventory
|
||||
from clan_lib.persist.inventory_store import InventoryStore
|
||||
from clan_lib.templates import (
|
||||
InputPrio,
|
||||
|
||||
@@ -13,7 +13,7 @@ Interacting with 'clan_lib.inventory' is NOT recommended and will be removed
|
||||
|
||||
from clan_lib.api import API
|
||||
from clan_lib.flake import Flake
|
||||
from clan_lib.nix_models.inventory import Inventory
|
||||
from clan_lib.nix_models.clan import Inventory
|
||||
from clan_lib.persist.inventory_store import InventoryStore
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from clan_lib.api import API
|
||||
from clan_lib.errors import ClanError
|
||||
from clan_lib.machines.machines import Machine
|
||||
from clan_lib.nix_models.inventory import (
|
||||
Machine as InventoryMachine,
|
||||
from clan_lib.nix_models.clan import (
|
||||
InventoryMachine,
|
||||
)
|
||||
from clan_lib.persist.inventory_store import InventoryStore
|
||||
from clan_lib.persist.util import set_value_by_path
|
||||
|
||||
200
pkgs/clan-cli/clan_lib/nix_models/clan.py
Normal file
200
pkgs/clan-cli/clan_lib/nix_models/clan.py
Normal file
@@ -0,0 +1,200 @@
|
||||
# DO NOT EDIT THIS FILE MANUALLY. IT IS GENERATED.
|
||||
# This file was generated by running `pkgs/clan-cli/clan_lib.inventory/update.sh`
|
||||
#
|
||||
# ruff: noqa: N815
|
||||
# ruff: noqa: N806
|
||||
# ruff: noqa: F401
|
||||
# fmt: off
|
||||
from typing import Any, Literal, NotRequired, TypedDict
|
||||
|
||||
|
||||
# Mimic "unknown".
|
||||
# 'Any' is unsafe because it allows any operations
|
||||
# This forces the user to use type-narrowing or casting in the code
|
||||
class Unknown:
|
||||
pass
|
||||
|
||||
|
||||
InventoryInstanceModuleNameType = str
|
||||
InventoryInstanceModuleInputType = str
|
||||
|
||||
class InventoryInstanceModule(TypedDict):
|
||||
name: str
|
||||
input: NotRequired[InventoryInstanceModuleInputType]
|
||||
|
||||
|
||||
|
||||
InventoryInstanceRoleMachineSettingsType = Unknown
|
||||
|
||||
class InventoryInstanceRoleMachine(TypedDict):
|
||||
settings: NotRequired[InventoryInstanceRoleMachineSettingsType]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class InventoryInstanceRoleTag(TypedDict):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
InventoryInstanceRoleMachinesType = dict[str, InventoryInstanceRoleMachine]
|
||||
InventoryInstanceRoleSettingsType = Unknown
|
||||
InventoryInstanceRoleTagsType = dict[str, InventoryInstanceRoleTag]
|
||||
|
||||
class InventoryInstanceRole(TypedDict):
|
||||
machines: NotRequired[InventoryInstanceRoleMachinesType]
|
||||
settings: NotRequired[InventoryInstanceRoleSettingsType]
|
||||
tags: NotRequired[InventoryInstanceRoleTagsType]
|
||||
|
||||
|
||||
|
||||
InventoryInstanceModuleType = InventoryInstanceModule
|
||||
InventoryInstanceRolesType = dict[str, InventoryInstanceRole]
|
||||
|
||||
class InventoryInstance(TypedDict):
|
||||
module: NotRequired[InventoryInstanceModuleType]
|
||||
roles: NotRequired[InventoryInstanceRolesType]
|
||||
|
||||
|
||||
|
||||
InventoryMachineDeployTargethostType = str | None
|
||||
|
||||
class InventoryMachineDeploy(TypedDict):
|
||||
targetHost: NotRequired[InventoryMachineDeployTargethostType]
|
||||
|
||||
|
||||
|
||||
InventoryMachineDeployType = InventoryMachineDeploy
|
||||
InventoryMachineDescriptionType = str | None
|
||||
InventoryMachineIconType = str | None
|
||||
InventoryMachineMachineclassType = Literal["nixos", "darwin"]
|
||||
InventoryMachineNameType = str
|
||||
InventoryMachineTagsType = list[str]
|
||||
|
||||
class InventoryMachine(TypedDict):
|
||||
deploy: NotRequired[InventoryMachineDeployType]
|
||||
description: NotRequired[InventoryMachineDescriptionType]
|
||||
icon: NotRequired[InventoryMachineIconType]
|
||||
machineClass: NotRequired[InventoryMachineMachineclassType]
|
||||
name: NotRequired[InventoryMachineNameType]
|
||||
tags: NotRequired[InventoryMachineTagsType]
|
||||
|
||||
|
||||
|
||||
InventoryMetaNameType = str
|
||||
InventoryMetaDescriptionType = str | None
|
||||
InventoryMetaIconType = str | None
|
||||
|
||||
class InventoryMeta(TypedDict):
|
||||
name: str
|
||||
description: NotRequired[InventoryMetaDescriptionType]
|
||||
icon: NotRequired[InventoryMetaIconType]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class InventoryService(TypedDict):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
InventoryInstancesType = dict[str, InventoryInstance]
|
||||
InventoryMachinesType = dict[str, InventoryMachine]
|
||||
InventoryMetaType = InventoryMeta
|
||||
InventoryModulesType = dict[str, dict[str, Any] | list[Any] | bool | float | int | str | None]
|
||||
InventoryServicesType = dict[str, InventoryService]
|
||||
InventoryTagsType = dict[str, list[str]]
|
||||
|
||||
class Inventory(TypedDict):
|
||||
instances: NotRequired[InventoryInstancesType]
|
||||
machines: NotRequired[InventoryMachinesType]
|
||||
meta: NotRequired[InventoryMetaType]
|
||||
modules: NotRequired[InventoryModulesType]
|
||||
services: NotRequired[InventoryServicesType]
|
||||
tags: NotRequired[InventoryTagsType]
|
||||
|
||||
|
||||
|
||||
OutputModuleformachineType = dict[str, Unknown]
|
||||
|
||||
class Output(TypedDict):
|
||||
moduleForMachine: NotRequired[OutputModuleformachineType]
|
||||
|
||||
|
||||
|
||||
SecretAgePluginsType = list[str]
|
||||
|
||||
class SecretAge(TypedDict):
|
||||
plugins: NotRequired[SecretAgePluginsType]
|
||||
|
||||
|
||||
|
||||
SecretAgeType = SecretAge
|
||||
|
||||
class Secret(TypedDict):
|
||||
age: NotRequired[SecretAgeType]
|
||||
|
||||
|
||||
|
||||
TemplateClanPathType = str
|
||||
TemplateClanDescriptionType = str
|
||||
|
||||
class TemplateClan(TypedDict):
|
||||
path: str
|
||||
description: NotRequired[TemplateClanDescriptionType]
|
||||
|
||||
|
||||
|
||||
TemplateDiskoPathType = str
|
||||
TemplateDiskoDescriptionType = str
|
||||
|
||||
class TemplateDisko(TypedDict):
|
||||
path: str
|
||||
description: NotRequired[TemplateDiskoDescriptionType]
|
||||
|
||||
|
||||
|
||||
TemplateMachinePathType = str
|
||||
TemplateMachineDescriptionType = str
|
||||
|
||||
class TemplateMachine(TypedDict):
|
||||
path: str
|
||||
description: NotRequired[TemplateMachineDescriptionType]
|
||||
|
||||
|
||||
|
||||
TemplateClanType = dict[str, TemplateClan]
|
||||
TemplateDiskoType = dict[str, TemplateDisko]
|
||||
TemplateMachineType = dict[str, TemplateMachine]
|
||||
|
||||
class Template(TypedDict):
|
||||
clan: NotRequired[TemplateClanType]
|
||||
disko: NotRequired[TemplateDiskoType]
|
||||
machine: NotRequired[TemplateMachineType]
|
||||
|
||||
|
||||
|
||||
ClanDirectoryType = dict[str, Any] | list[Any] | bool | float | int | str
|
||||
ClanInventoryType = Inventory
|
||||
ClanMachinesType = dict[str, Unknown]
|
||||
ClanMetaType = Unknown
|
||||
ClanModulesType = dict[str, Unknown]
|
||||
ClanOutputsType = Output
|
||||
ClanSecretsType = Secret
|
||||
ClanSelfType = dict[str, Any] | list[Any] | bool | float | int | str
|
||||
ClanSpecialargsType = dict[str, dict[str, Any] | list[Any] | bool | float | int | str | None]
|
||||
ClanTemplatesType = Template
|
||||
|
||||
class Clan(TypedDict):
|
||||
directory: NotRequired[ClanDirectoryType]
|
||||
inventory: NotRequired[ClanInventoryType]
|
||||
machines: NotRequired[ClanMachinesType]
|
||||
meta: NotRequired[ClanMetaType]
|
||||
modules: NotRequired[ClanModulesType]
|
||||
outputs: NotRequired[ClanOutputsType]
|
||||
secrets: NotRequired[ClanSecretsType]
|
||||
self: NotRequired[ClanSelfType]
|
||||
specialArgs: NotRequired[ClanSpecialargsType]
|
||||
templates: NotRequired[ClanTemplatesType]
|
||||
@@ -1,111 +0,0 @@
|
||||
# DO NOT EDIT THIS FILE MANUALLY. IT IS GENERATED.
|
||||
# This file was generated by running `pkgs/clan-cli/clan_lib.inventory/update.sh`
|
||||
#
|
||||
# ruff: noqa: N815
|
||||
# ruff: noqa: N806
|
||||
# ruff: noqa: F401
|
||||
# fmt: off
|
||||
from typing import Any, Literal, NotRequired, TypedDict
|
||||
|
||||
|
||||
# Mimic "unknown".
|
||||
# 'Any' is unsafe because it allows any operations
|
||||
# This forces the user to use type-narrowing or casting in the code
|
||||
class Unknown:
|
||||
pass
|
||||
|
||||
|
||||
InstanceModuleNameType = str
|
||||
InstanceModuleInputType = str
|
||||
|
||||
class InstanceModule(TypedDict):
|
||||
name: str
|
||||
input: NotRequired[InstanceModuleInputType]
|
||||
|
||||
|
||||
|
||||
InstanceRoleMachineSettingsType = Unknown
|
||||
|
||||
class InstanceRoleMachine(TypedDict):
|
||||
settings: NotRequired[InstanceRoleMachineSettingsType]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class InstanceRoleTag(TypedDict):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
InstanceRoleMachinesType = dict[str, InstanceRoleMachine]
|
||||
InstanceRoleSettingsType = Unknown
|
||||
InstanceRoleTagsType = dict[str, InstanceRoleTag]
|
||||
|
||||
class InstanceRole(TypedDict):
|
||||
machines: NotRequired[InstanceRoleMachinesType]
|
||||
settings: NotRequired[InstanceRoleSettingsType]
|
||||
tags: NotRequired[InstanceRoleTagsType]
|
||||
|
||||
|
||||
|
||||
InstanceModuleType = InstanceModule
|
||||
InstanceRolesType = dict[str, InstanceRole]
|
||||
|
||||
class Instance(TypedDict):
|
||||
module: NotRequired[InstanceModuleType]
|
||||
roles: NotRequired[InstanceRolesType]
|
||||
|
||||
|
||||
|
||||
MachineDeployTargethostType = str
|
||||
|
||||
class MachineDeploy(TypedDict):
|
||||
targetHost: NotRequired[MachineDeployTargethostType]
|
||||
|
||||
|
||||
|
||||
MachineDeployType = MachineDeploy
|
||||
MachineDescriptionType = str
|
||||
MachineIconType = str
|
||||
MachineMachineclassType = Literal["nixos", "darwin"]
|
||||
MachineNameType = str
|
||||
MachineTagsType = list[str]
|
||||
|
||||
class Machine(TypedDict):
|
||||
deploy: NotRequired[MachineDeployType]
|
||||
description: NotRequired[MachineDescriptionType]
|
||||
icon: NotRequired[MachineIconType]
|
||||
machineClass: NotRequired[MachineMachineclassType]
|
||||
name: NotRequired[MachineNameType]
|
||||
tags: NotRequired[MachineTagsType]
|
||||
|
||||
|
||||
|
||||
MetaNameType = str
|
||||
MetaDescriptionType = str
|
||||
MetaIconType = str
|
||||
|
||||
class Meta(TypedDict):
|
||||
name: str
|
||||
description: NotRequired[MetaDescriptionType]
|
||||
icon: NotRequired[MetaIconType]
|
||||
|
||||
Service = dict[str, Any]
|
||||
|
||||
|
||||
|
||||
InventoryInstancesType = dict[str, Instance]
|
||||
InventoryMachinesType = dict[str, Machine]
|
||||
InventoryMetaType = Meta
|
||||
InventoryModulesType = dict[str, Any]
|
||||
InventoryServicesType = dict[str, Service]
|
||||
InventoryTagsType = dict[str, Any]
|
||||
|
||||
class Inventory(TypedDict):
|
||||
instances: NotRequired[InventoryInstancesType]
|
||||
machines: NotRequired[InventoryMachinesType]
|
||||
meta: NotRequired[InventoryMetaType]
|
||||
modules: NotRequired[InventoryModulesType]
|
||||
services: NotRequired[InventoryServicesType]
|
||||
tags: NotRequired[InventoryTagsType]
|
||||
@@ -5,7 +5,7 @@ from typing import Any, Protocol
|
||||
|
||||
from clan_lib.errors import ClanError
|
||||
from clan_lib.git import commit_file
|
||||
from clan_lib.nix_models.inventory import Inventory
|
||||
from clan_lib.nix_models.clan import Inventory
|
||||
|
||||
from .util import (
|
||||
calc_patches,
|
||||
|
||||
@@ -24,8 +24,8 @@ from clan_lib.errors import ClanError
|
||||
from clan_lib.flake import Flake
|
||||
from clan_lib.machines.machines import Machine
|
||||
from clan_lib.nix import nix_command
|
||||
from clan_lib.nix_models.inventory import Machine as InventoryMachine
|
||||
from clan_lib.nix_models.inventory import MachineDeploy
|
||||
from clan_lib.nix_models.clan import InventoryMachine
|
||||
from clan_lib.nix_models.clan import InventoryMachineDeploy as MachineDeploy
|
||||
from clan_lib.ssh.remote import Remote
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
Reference in New Issue
Block a user