only list valid secrets/users/machines

Git often leaves empty directories behind
This commit is contained in:
Jörg Thalheim
2023-09-07 12:48:34 +02:00
parent ae3283a762
commit c3ccf68007
4 changed files with 28 additions and 8 deletions

View File

@@ -172,9 +172,15 @@ def disallow_member(group_folder: Path, name: str) -> None:
def list_secrets() -> list[str]:
return list_objects(
sops_secrets_folder(), lambda n: VALID_SECRET_NAME.match(n) is not None
)
path = sops_secrets_folder()
def validate(name: str) -> bool:
return (
VALID_SECRET_NAME.match(name) is not None
and (path / name / "secret").exists()
)
return list_objects(path, validate)
def list_command(args: argparse.Namespace) -> None: