secrets: add has_machine and has_secret function

This commit is contained in:
Jörg Thalheim
2023-09-19 20:30:36 +02:00
committed by lassulus
parent dc51ca5803
commit ead5c6e6a8
2 changed files with 10 additions and 5 deletions

View File

@@ -171,14 +171,15 @@ def disallow_member(group_folder: Path, name: str) -> None:
)
def has_secret(secret: str) -> bool:
return (sops_secrets_folder() / secret / "secret").exists()
def list_secrets() -> list[str]:
path = sops_secrets_folder()
def validate(name: str) -> bool:
return (
VALID_SECRET_NAME.match(name) is not None
and (path / name / "secret").exists()
)
return VALID_SECRET_NAME.match(name) is not None and has_secret(name)
return list_objects(path, validate)