Refactor(clan_lib): move nix bound classes out of the cli folder
This commit is contained in:
@@ -19,7 +19,8 @@ from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from clan_lib.api import API, dataclass_to_dict, from_dict
|
||||
from clan_lib.api import API
|
||||
from clan_lib.nix_models.inventory import Inventory
|
||||
|
||||
from clan_cli.cmd import run
|
||||
from clan_cli.errors import ClanCmdError, ClanError
|
||||
@@ -27,28 +28,6 @@ from clan_cli.flake import Flake
|
||||
from clan_cli.git import commit_file
|
||||
from clan_cli.nix import nix_eval
|
||||
|
||||
from .classes import (
|
||||
Inventory,
|
||||
# Machine classes
|
||||
Machine,
|
||||
MachineDeploy,
|
||||
# General classes
|
||||
Meta,
|
||||
Service,
|
||||
)
|
||||
|
||||
# Re export classes here
|
||||
# This allows to renaming of classes in the generated code
|
||||
__all__ = [
|
||||
"Inventory",
|
||||
"Machine",
|
||||
"MachineDeploy",
|
||||
"Meta",
|
||||
"Service",
|
||||
"dataclass_to_dict",
|
||||
"from_dict",
|
||||
]
|
||||
|
||||
|
||||
def get_inventory_path(flake: Flake) -> Path:
|
||||
"""
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
# DO NOT EDIT THIS FILE MANUALLY. IT IS GENERATED.
|
||||
# This file was generated by running `pkgs/clan-cli/clan_cli/inventory/update.sh`
|
||||
#
|
||||
# ruff: noqa: N815
|
||||
# ruff: noqa: N806
|
||||
# ruff: noqa: F401
|
||||
# fmt: off
|
||||
from typing import Any, Literal, NotRequired, TypedDict
|
||||
|
||||
|
||||
class MachineDeploy(TypedDict):
|
||||
targetHost: NotRequired[str]
|
||||
|
||||
|
||||
class Machine(TypedDict):
|
||||
deploy: NotRequired[MachineDeploy]
|
||||
description: NotRequired[str]
|
||||
icon: NotRequired[str]
|
||||
machineClass: NotRequired[Literal["nixos", "darwin"]]
|
||||
name: NotRequired[str]
|
||||
tags: NotRequired[list[str]]
|
||||
|
||||
|
||||
class Meta(TypedDict):
|
||||
name: str
|
||||
description: NotRequired[str]
|
||||
icon: NotRequired[str]
|
||||
|
||||
Service = dict[str, Any]
|
||||
|
||||
|
||||
class Inventory(TypedDict):
|
||||
machines: NotRequired[dict[str, Machine]]
|
||||
meta: NotRequired[Meta]
|
||||
modules: NotRequired[dict[str, Any]]
|
||||
services: NotRequired[dict[str, Service]]
|
||||
tags: NotRequired[dict[str, Any]]
|
||||
@@ -1,8 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
jsonSchema=$(nix build .#schemas.inventory-schema-abstract --print-out-paths)/schema.json
|
||||
SCRIPT_DIR=$(dirname "$0")
|
||||
cd "$SCRIPT_DIR"
|
||||
nix run .#classgen -- "$jsonSchema" "../../../clan-cli/clan_cli/inventory/classes.py"
|
||||
Reference in New Issue
Block a user