feat(GODT-3172): detect missing keychain item

This commit is contained in:
Jakub
2024-01-04 08:28:17 +01:00
committed by Jakub Cuth
parent 89bb7b6389
commit 9b1daa0373
5 changed files with 41 additions and 5 deletions

View File

@ -106,8 +106,12 @@ func loadVaultKey(vaultDir string, keychains *keychain.List) ([]byte, error) {
key, err := vault.GetVaultKey(kc)
if err != nil {
logrus.WithError(err).Warn("Not possible to retrieve vault key, generating new")
return vault.NewVaultKey(kc)
if keychain.IsErrKeychainNoItem(err) {
logrus.WithError(err).Warn("no vault key found, generating new")
return vault.NewVaultKey(kc)
}
return nil, fmt.Errorf("could not check for vault key: %w", err)
}
return key, nil