secrets: improve error messages
This commit is contained in:
parent
8ca8816d71
commit
9b3bfd6950
@ -22,9 +22,12 @@ class SopsKey:
|
|||||||
|
|
||||||
def get_public_key(privkey: str) -> str:
|
def get_public_key(privkey: str) -> str:
|
||||||
cmd = nix_shell(["age"], ["age-keygen", "-y"])
|
cmd = nix_shell(["age"], ["age-keygen", "-y"])
|
||||||
res = subprocess.run(
|
try:
|
||||||
cmd, input=privkey, check=True, stdout=subprocess.PIPE, text=True
|
res = subprocess.run(cmd, input=privkey, stdout=subprocess.PIPE, text=True)
|
||||||
)
|
except subprocess.CalledProcessError as e:
|
||||||
|
raise ClanError(
|
||||||
|
"Failed to get public key for age private key. Is the key malformed?"
|
||||||
|
) from e
|
||||||
return res.stdout.strip()
|
return res.stdout.strip()
|
||||||
|
|
||||||
|
|
||||||
@ -100,7 +103,7 @@ def ensure_sops_key() -> SopsKey:
|
|||||||
subprocess.run(cmd, check=True)
|
subprocess.run(cmd, check=True)
|
||||||
|
|
||||||
tty.info(
|
tty.info(
|
||||||
f"Generated age key at '{path}'. Please back it up on a secure location or you will lose access to your secrets."
|
f"Generated age key at '{path}' for your user. Please back it up on a secure location or you will lose access to your secrets."
|
||||||
)
|
)
|
||||||
return ensure_user(get_public_key(path.read_text()))
|
return ensure_user(get_public_key(path.read_text()))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user