vars/list: doogfood get_machines into cli
This is important otherwise cli diverges from api
This commit is contained in:
@@ -1,23 +1,27 @@
|
||||
import argparse
|
||||
import logging
|
||||
from pathlib import Path
|
||||
|
||||
from clan_cli.completions import add_dynamic_completer, complete_machines
|
||||
from clan_lib.flake import Flake, require_flake
|
||||
from clan_lib.machines.machines import Machine
|
||||
|
||||
from .generate import Var
|
||||
from .generate import Var, get_generators
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def get_machine_vars(base_dir: str, machine_name: str) -> list[Var]:
|
||||
# TODO: We dont have machine level store / this granularity yet
|
||||
# We should move the store definition to the flake, as there can be only one store per clan
|
||||
machine = Machine(name=machine_name, flake=Flake(base_dir))
|
||||
pub_store = machine.public_vars_store
|
||||
sec_store = machine.secret_vars_store
|
||||
from clan_cli.vars.generate import Generator
|
||||
|
||||
all_vars = []
|
||||
for generator in Generator.generators_from_flake(machine_name, machine.flake):
|
||||
|
||||
generators = get_generators(base_dir=Path(base_dir), machine_name=machine_name)
|
||||
for generator in generators:
|
||||
for var in generator.files:
|
||||
if var.secret:
|
||||
var.store(sec_store)
|
||||
|
||||
Reference in New Issue
Block a user