clan-cli: Refactor the API to use the Flake object
This commit is contained in:
@@ -107,7 +107,7 @@ def create_clan(opts: CreateOptions) -> CreateClanResponse:
|
||||
response.flake_update = flake_update
|
||||
|
||||
if opts.initial:
|
||||
init_inventory(str(opts.dest), init=opts.initial)
|
||||
init_inventory(Flake(str(opts.dest)), init=opts.initial)
|
||||
|
||||
return response
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from clan_cli.clan_dirs import machine_gcroot
|
||||
from clan_cli.cmd import run
|
||||
from clan_cli.dirs import machine_gcroot
|
||||
from clan_cli.errors import ClanError
|
||||
from clan_cli.flake import Flake
|
||||
from clan_cli.machines.list import list_nixos_machines
|
||||
|
||||
@@ -2,20 +2,21 @@ from dataclasses import dataclass
|
||||
|
||||
from clan_lib.api import API
|
||||
|
||||
from clan_cli.flake import Flake
|
||||
from clan_cli.inventory import Inventory, Meta, load_inventory_json, set_inventory
|
||||
|
||||
|
||||
@dataclass
|
||||
class UpdateOptions:
|
||||
directory: str
|
||||
flake: Flake
|
||||
meta: Meta
|
||||
|
||||
|
||||
@API.register
|
||||
def update_clan_meta(options: UpdateOptions) -> Inventory:
|
||||
inventory = load_inventory_json(options.directory)
|
||||
inventory = load_inventory_json(options.flake)
|
||||
inventory["meta"] = options.meta
|
||||
|
||||
set_inventory(inventory, options.directory, "Update clan metadata")
|
||||
set_inventory(inventory, options.flake, "Update clan metadata")
|
||||
|
||||
return inventory
|
||||
|
||||
Reference in New Issue
Block a user