Skip to content

Commit

Permalink
#36: Improve vault error message for sync (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
iignatevich authored Jun 12, 2024
1 parent 59ebcfd commit fbcf59c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package plasmactlbump

import (
"bufio"
"errors"
"fmt"
"os"
"path/filepath"
Expand Down Expand Up @@ -309,6 +310,14 @@ func (i *Inventory) loadVariablesFile(path, vaultPassword string, isVault bool)
if isVault {
sourceVault, errDecrypt := vault.DecryptFile(cleanPath, vaultPassword)
if errDecrypt != nil {
if errors.Is(errDecrypt, vault.ErrEmptyPassword) {
return data, fmt.Errorf("error decrypting vault %s, password is blank", cleanPath)
} else if errors.Is(errDecrypt, vault.ErrInvalidFormat) {
return data, fmt.Errorf("error decrypting vault %s, invalid secret format", cleanPath)
} else if errDecrypt.Error() == "invalid password" {
return data, fmt.Errorf("invalid password for vault '%s'", cleanPath)
}

return data, errDecrypt
}
rawData = []byte(sourceVault)
Expand Down

0 comments on commit fbcf59c

Please sign in to comment.