Facts/api: export method for getting the public store
This commit is contained in:
committed by
hsjobeki
parent
096f1b5e8a
commit
8c75051611
@@ -2,6 +2,7 @@ import argparse
|
|||||||
import importlib
|
import importlib
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
from clan_cli.completions import add_dynamic_completer, complete_machines
|
from clan_cli.completions import add_dynamic_completer, complete_machines
|
||||||
from clan_cli.machines.machines import Machine
|
from clan_cli.machines.machines import Machine
|
||||||
@@ -11,8 +12,7 @@ log = logging.getLogger(__name__)
|
|||||||
|
|
||||||
# TODO get also secret facts
|
# TODO get also secret facts
|
||||||
def get_all_facts(machine: Machine) -> dict:
|
def get_all_facts(machine: Machine) -> dict:
|
||||||
public_facts_module = importlib.import_module(machine.public_facts_module)
|
public_facts_store = get_public_facts_store(machine)
|
||||||
public_facts_store = public_facts_module.FactStore(machine=machine)
|
|
||||||
|
|
||||||
# for service in machine.secrets_data:
|
# for service in machine.secrets_data:
|
||||||
# facts[service] = {}
|
# facts[service] = {}
|
||||||
@@ -25,6 +25,12 @@ def get_all_facts(machine: Machine) -> dict:
|
|||||||
return public_facts_store.get_all()
|
return public_facts_store.get_all()
|
||||||
|
|
||||||
|
|
||||||
|
def get_public_facts_store(machine: Machine) -> Any:
|
||||||
|
public_facts_module = importlib.import_module(machine.public_facts_module)
|
||||||
|
public_facts_store = public_facts_module.FactStore(machine=machine)
|
||||||
|
return public_facts_store
|
||||||
|
|
||||||
|
|
||||||
def get_command(args: argparse.Namespace) -> None:
|
def get_command(args: argparse.Namespace) -> None:
|
||||||
machine = Machine(name=args.machine, flake=args.flake)
|
machine = Machine(name=args.machine, flake=args.flake)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user