Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog/24270.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:change
api: add the `enterprise` parameter to the `/sys/health` endpoint
```
3 changes: 3 additions & 0 deletions http/sys_health.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"time"

"github.com/hashicorp/go-secure-stdlib/parseutil"
"github.com/hashicorp/vault/helper/constants"
"github.com/hashicorp/vault/sdk/helper/consts"
"github.com/hashicorp/vault/vault"
"github.com/hashicorp/vault/version"
Expand Down Expand Up @@ -204,6 +205,7 @@ func getSysHealth(core *vault.Core, r *http.Request) (int, *HealthResponse, erro
ReplicationDRMode: replicationState.GetDRString(),
ServerTimeUTC: time.Now().UTC().Unix(),
Version: version.GetVersion().VersionNumber(),
Enterprise: constants.IsEnterprise,
ClusterName: clusterName,
ClusterID: clusterID,
}
Expand Down Expand Up @@ -245,6 +247,7 @@ type HealthResponse struct {
ReplicationDRMode string `json:"replication_dr_mode"`
ServerTimeUTC int64 `json:"server_time_utc"`
Version string `json:"version"`
Enterprise bool `json:"enterprise"`
ClusterName string `json:"cluster_name,omitempty"`
ClusterID string `json:"cluster_id,omitempty"`
LastWAL uint64 `json:"last_wal,omitempty"`
Expand Down
7 changes: 7 additions & 0 deletions http/sys_health_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"reflect"
"testing"

"github.com/hashicorp/vault/helper/constants"
"github.com/hashicorp/vault/sdk/helper/consts"
"github.com/hashicorp/vault/vault"
)
Expand All @@ -26,6 +27,7 @@ func TestSysHealth_get(t *testing.T) {

var actual map[string]interface{}
expected := map[string]interface{}{
"enterprise": constants.IsEnterprise,
"replication_performance_mode": consts.ReplicationUnknown.GetPerformanceString(),
"replication_dr_mode": consts.ReplicationUnknown.GetDRString(),
"initialized": false,
Expand Down Expand Up @@ -60,6 +62,7 @@ func TestSysHealth_get(t *testing.T) {

actual = map[string]interface{}{}
expected = map[string]interface{}{
"enterprise": constants.IsEnterprise,
"replication_performance_mode": consts.ReplicationUnknown.GetPerformanceString(),
"replication_dr_mode": consts.ReplicationUnknown.GetDRString(),
"initialized": true,
Expand Down Expand Up @@ -98,6 +101,7 @@ func TestSysHealth_get(t *testing.T) {

actual = map[string]interface{}{}
expected = map[string]interface{}{
"enterprise": constants.IsEnterprise,
"replication_performance_mode": consts.ReplicationPerformanceDisabled.GetPerformanceString(),
"replication_dr_mode": consts.ReplicationDRDisabled.GetDRString(),
"initialized": true,
Expand Down Expand Up @@ -141,6 +145,7 @@ func TestSysHealth_customcodes(t *testing.T) {

var actual map[string]interface{}
expected := map[string]interface{}{
"enterprise": constants.IsEnterprise,
"replication_performance_mode": consts.ReplicationUnknown.GetPerformanceString(),
"replication_dr_mode": consts.ReplicationUnknown.GetDRString(),
"initialized": false,
Expand Down Expand Up @@ -176,6 +181,7 @@ func TestSysHealth_customcodes(t *testing.T) {

actual = map[string]interface{}{}
expected = map[string]interface{}{
"enterprise": constants.IsEnterprise,
"replication_performance_mode": consts.ReplicationUnknown.GetPerformanceString(),
"replication_dr_mode": consts.ReplicationUnknown.GetDRString(),
"initialized": true,
Expand Down Expand Up @@ -215,6 +221,7 @@ func TestSysHealth_customcodes(t *testing.T) {

actual = map[string]interface{}{}
expected = map[string]interface{}{
"enterprise": constants.IsEnterprise,
"replication_performance_mode": consts.ReplicationPerformanceDisabled.GetPerformanceString(),
"replication_dr_mode": consts.ReplicationDRDisabled.GetDRString(),
"initialized": true,
Expand Down