API|CLI: Added argument 'flake_name' to all CLI and API endpoints. Tests missing.

This commit is contained in:
2023-10-13 22:29:55 +02:00
parent 740e5e2ebc
commit 06d6edbfa7
23 changed files with 195 additions and 105 deletions

View File

@@ -68,6 +68,25 @@ def clan_flake_dir() -> Path:
return path.resolve()
def get_flake_path(name: str) -> Path:
flake_dir = clan_flake_dir() / name
if not flake_dir.exists():
raise ClanError(f"Flake {name} does not exist")
return flake_dir
def machines_dir(flake_name: str) -> Path:
return get_flake_path(flake_name) / "machines"
def specific_machine_dir(flake_name: str, machine: str) -> Path:
return machines_dir(flake_name) / machine
def machine_settings_file(flake_name: str, machine: str) -> Path:
return specific_machine_dir(flake_name, machine) / "settings.json"
def module_root() -> Path:
return Path(__file__).parent