20 lines
634 B
Python
20 lines
634 B
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
class VariableViewer:
|
|
def __init__(self, customers):
|
|
self.customers = customers
|
|
|
|
def files(self, customer: str, kind: str) -> list[Path]:
|
|
if kind not in {"group_vars", "host_vars"}:
|
|
raise ValueError("Unsupported variable directory")
|
|
root = self.customers.require(customer) / kind
|
|
if not root.exists():
|
|
return []
|
|
return sorted(p for p in root.rglob("*.yml") if p.is_file())
|
|
|
|
def relative(self, customer: str, path: Path) -> Path:
|
|
return path.relative_to(self.customers.require(customer))
|