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:
parent
727482166c
commit
f5549f3980
1 changed files with 4 additions and 0 deletions
4
main.go
4
main.go
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue