Fix key dump in clan secrets key show

```
In [4]: str(Type.AGE)
Out[4]: Type.AGE

In [5]: Type.AGE.name.lower()
Out[5]: age
```
This commit is contained in:
Louis Opter
2024-10-01 19:41:51 -07:00
committed by Mic92
parent be5f10e241
commit 6694c2b60d
2 changed files with 8 additions and 3 deletions

View File

@@ -60,9 +60,7 @@ def show_command(args: argparse.Namespace) -> None:
if not key:
msg = "No public key found"
raise ClanError(msg)
json.dump(
{"key": key.pubkey, "type": str(key.key_type)}, sys.stdout, indent=2, sort_keys=True
)
json.dump(key.as_dict(), sys.stdout, indent=2, sort_keys=True)
def update_command(args: argparse.Namespace) -> None:

View File

@@ -37,6 +37,13 @@ class SopsKey:
username: str
key_type: KeyType
def as_dict(self) -> dict[str, str]:
return {
"publickey": self.pubkey,
"username": self.username,
"type": self.key_type.name.lower(),
}
def get_public_age_key(privkey: str) -> str:
cmd = nix_shell(["nixpkgs#age"], ["age-keygen", "-y"])