1
0
Fork 0
mirror of https://github.com/Luzifer/vault-totp.git synced 2024-12-22 22:01:19 +00:00

handle key not found error (#2)

If a key is not found client.Logical().Read(k) will return (nil, nil).
Lets gracefully handle this case and tell the user what is wrong.
This commit is contained in:
Heiko Voigt 2021-02-17 10:53:06 +01:00 committed by GitHub
parent 727482166c
commit f5549f3980
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -166,6 +166,10 @@ func getSecretsFromVault() ([]token, error) {
return nil, fmt.Errorf("Unable to read from key %q: %s", k, err)
}
if data == nil {
return nil, fmt.Errorf("Key %q not found", k)
}
if data.Data[cfg.Field] == nil {
return nil, fmt.Errorf("The key %q does not have a field named %q.", k, cfg.Field)
}