add api for secret groups and decrypting secrets

This commit is contained in:
Jörg Thalheim
2023-08-09 15:06:32 +02:00
parent caa1c0dfd8
commit e103a4186c
2 changed files with 44 additions and 19 deletions

View File

@@ -183,13 +183,16 @@ def list_command(args: argparse.Namespace) -> None:
print("\n".join(lst))
def get_command(args: argparse.Namespace) -> None:
secret: str = args.secret
def decrypt_secret(secret: str) -> str:
ensure_sops_key()
secret_path = sops_secrets_folder() / secret / "secret"
if not secret_path.exists():
raise ClanError(f"Secret '{secret}' does not exist")
print(decrypt_file(secret_path), end="")
return decrypt_file(secret_path)
def get_command(args: argparse.Namespace) -> None:
print(decrypt_secret(args.secret), end="")
def set_command(args: argparse.Namespace) -> None: