mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-30 02:02:43 +00:00
Address review feedback from @jefferai
This commit is contained in:
@@ -2,6 +2,7 @@ package http
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
@@ -121,6 +122,9 @@ func getSysHealth(core *vault.Core, r *http.Request) (int, *HealthResponse, erro
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return http.StatusInternalServerError, nil, err
|
return http.StatusInternalServerError, nil, err
|
||||||
}
|
}
|
||||||
|
if cluster == nil {
|
||||||
|
return http.StatusInternalServerError, nil, fmt.Errorf("failed to fetch cluster details")
|
||||||
|
}
|
||||||
clusterName = cluster.Name
|
clusterName = cluster.Name
|
||||||
clusterID = cluster.ID
|
clusterID = cluster.ID
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -159,6 +159,10 @@ func handleSysSealStatusRaw(core *vault.Core, w http.ResponseWriter, r *http.Req
|
|||||||
respondError(w, http.StatusInternalServerError, err)
|
respondError(w, http.StatusInternalServerError, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if cluster == nil {
|
||||||
|
respondError(w, http.StatusInternalServerError, fmt.Errorf("failed to fetch cluster details"))
|
||||||
|
return
|
||||||
|
}
|
||||||
clusterName = cluster.Name
|
clusterName = cluster.Name
|
||||||
clusterID = cluster.ID
|
clusterID = cluster.ID
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,15 +23,14 @@ type Cluster struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Cluster fetches the details of either local or global cluster based on the
|
// Cluster fetches the details of either local or global cluster based on the
|
||||||
// input. This method errors out when Vault is sealed. This function never
|
// input. This method errors out when Vault is sealed.
|
||||||
// returns a nil Cluster object.
|
|
||||||
func (c *Core) Cluster() (*Cluster, error) {
|
func (c *Core) Cluster() (*Cluster, error) {
|
||||||
var cluster Cluster
|
var cluster Cluster
|
||||||
|
|
||||||
// Fetch the storage entry. This call fails when Vault is sealed.
|
// Fetch the storage entry. This call fails when Vault is sealed.
|
||||||
entry, err := c.barrier.Get(coreLocalClusterInfoPath)
|
entry, err := c.barrier.Get(coreLocalClusterInfoPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &cluster, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if entry == nil {
|
if entry == nil {
|
||||||
return &cluster, nil
|
return &cluster, nil
|
||||||
@@ -39,7 +38,7 @@ func (c *Core) Cluster() (*Cluster, error) {
|
|||||||
|
|
||||||
// Decode the cluster information
|
// Decode the cluster information
|
||||||
if err = jsonutil.DecodeJSON(entry.Value, &cluster); err != nil {
|
if err = jsonutil.DecodeJSON(entry.Value, &cluster); err != nil {
|
||||||
return &cluster, fmt.Errorf("failed to decode cluster details: %v", err)
|
return nil, fmt.Errorf("failed to decode cluster details: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set in config file
|
// Set in config file
|
||||||
|
|||||||
Reference in New Issue
Block a user