Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VAULT-22270] API: add enterprise field to the response from /sys/health/ endpoint #24270

Merged
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
Loading