Attempt re-auth on failure

Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
This commit is contained in:
Marcus Noble 2022-11-16 12:58:34 +00:00
parent dcd698c60d
commit 4f0fb2a170
Signed by: AverageMarcus
GPG Key ID: B8F2DB8A7AEBAF78

12
main.go
View File

@ -92,10 +92,22 @@ func processSecret(s *apiv1.Secret) {
vault := keys["vault"] vault := keys["vault"]
item, err := opClient.GetSecret(vault, passwordID) item, err := opClient.GetSecret(vault, passwordID)
if err != nil {
if strings.Contains(err.Error(), "session expired") {
opClient, err = buildOpClient()
if err != nil {
panic(err.Error())
}
item, err = opClient.GetSecret(vault, passwordID)
if err != nil { if err != nil {
log.Println("[ERROR] Could not get secret", err) log.Println("[ERROR] Could not get secret", err)
return return
} }
} else {
log.Println("[ERROR] Could not get secret", err)
return
}
}
s.Data = make(map[string][]byte) s.Data = make(map[string][]byte)