Merge pull request 'sops: fix compatibility with new format' (#3242) from directory-context into main

Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/3242
This commit is contained in:
Mic92
2025-04-08 16:05:43 +00:00
2 changed files with 17 additions and 12 deletions

6
flake.lock generated
View File

@@ -36,11 +36,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1743598667, "lastModified": 1744126564,
"narHash": "sha256-ViE7NoFWytYO2uJONTAX35eGsvTYXNHjWALeHAg8OQY=", "narHash": "sha256-v1XPivS/Rvo9BBvF2Rh59HxUpucMsuOCGVrkIObF/bc=",
"owner": "nix-community", "owner": "nix-community",
"repo": "disko", "repo": "disko",
"rev": "329d3d7e8bc63dd30c39e14e6076db590a6eabe6", "rev": "8f806681d781ca250ddaafd262d6b6c89d79d9ef",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@@ -449,15 +449,20 @@ def decrypt_file(secret_path: Path) -> str:
def get_recipients(secret_path: Path) -> set[SopsKey]: def get_recipients(secret_path: Path) -> set[SopsKey]:
sops_attrs = json.loads((secret_path / "secret").read_text())["sops"] sops_attrs = json.loads((secret_path / "secret").read_text())["sops"]
return { keys = set()
SopsKey( for key_type in KeyType:
pubkey=recipient[key_type.sops_recipient_attr], recipients = sops_attrs.get(key_type.name.lower())
username="", if not recipients:
key_type=key_type, continue
) for recipient in recipients:
for key_type in KeyType keys.add(
for recipient in sops_attrs[key_type.name.lower()] or [] SopsKey(
} pubkey=recipient[key_type.sops_recipient_attr],
username="",
key_type=key_type,
)
)
return keys
def get_meta(secret_path: Path) -> dict: def get_meta(secret_path: Path) -> dict: