fix: some errorhandling corrections
chore: updated versions
This commit is contained in:
parent
7ff3af5044
commit
aa77ad77e2
10 changed files with 71 additions and 29 deletions
|
|
@ -35,7 +35,10 @@ func InitializeClient(
|
|||
config.FatalLog("Vault login request failed: %s", err)
|
||||
}
|
||||
config.InfoLog("Login successful. Token received.")
|
||||
s.Client.SetToken(loginResp.Auth.ClientToken)
|
||||
err = s.Client.SetToken(loginResp.Auth.ClientToken)
|
||||
if err != nil {
|
||||
config.FatalLog("Vault login could not set token: %s", err)
|
||||
}
|
||||
|
||||
return s
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package secretsmanager
|
|||
import (
|
||||
"fmt"
|
||||
"secretsmanager/config"
|
||||
"log"
|
||||
|
||||
"github.com/hashicorp/vault-client-go"
|
||||
)
|
||||
|
|
@ -16,13 +15,11 @@ func GetSecrets(
|
|||
config.InfoLog("Attempting to read secret from mount '%s' at path '%s'", cfg.VaultSecretsManagerID, cfg.VaultPath)
|
||||
secret, err := s.Client.Secrets.KvV2Read(s.Ctx, cfg.VaultPath, vault.WithMountPath(cfg.VaultSecretsManagerID))
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to read secret from vault: %v", err)
|
||||
return nil, fmt.Errorf("failed to read secret from vault: %w", err)
|
||||
}
|
||||
|
||||
if secret == nil || secret.Data.Data == nil {
|
||||
log.Fatal("No data found at the specified secret path.")
|
||||
return []string{}, nil
|
||||
return []string{}, fmt.Errorf("no data found at the specified secret path")
|
||||
}
|
||||
|
||||
var secretsAsKeyValue []string
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue