Skip to content

Commit 8204628

Browse files
committed
Fix: fixing oauth pkg/deployment
1 parent a1f8459 commit 8204628

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

pkg/vault/hashicorp_vault.go

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ import (
99
"encoding/json"
1010
"errors"
1111
"fmt"
12+
"path"
13+
"strings"
14+
1215
vault "github.com/hashicorp/vault/api"
1316
kubernetesAuth "github.com/hashicorp/vault/api/auth/kubernetes"
1417
"go.uber.org/zap"
1518
"k8s.io/client-go/rest"
16-
"path"
17-
"strings"
1819
)
1920

2021
const (
@@ -410,3 +411,21 @@ func (a *HashiCorpVaultSealHandler) TryUnseal(ctx context.Context, keys []string
410411

411412
return nil
412413
}
414+
415+
// *** ADDED Health Method ***
416+
// Health checks the status of the Vault instance using the /sys/health endpoint.
417+
func (a *HashiCorpVaultSealHandler) Health(ctx context.Context) (*vault.HealthResponse, error) {
418+
if a.client == nil {
419+
// This should ideally not happen if NewHashiCorpVaultSealHandler succeeded
420+
return nil, errors.New("vault client is not initialized in SealHandler")
421+
}
422+
// Call the underlying Vault client's health check
423+
healthResp, err := a.client.Sys().Health() // Pass context
424+
if err != nil {
425+
// Log internally, return error for caller to handle
426+
a.logger.Error("Vault system health check failed", zap.Error(err))
427+
return nil, err // Return the original error
428+
}
429+
// Return the response (can be nil even without error in some edge cases, caller should check)
430+
return healthResp, nil
431+
}

0 commit comments

Comments
 (0)