expose 'storage_type' on the sys/seal-status endpoint (#7486)

* expose 'storage_type' on the sys/seal-status endpoint

* add comments

* Update vault/core.go

Co-Authored-By: Brian Kassouf <briankassouf@users.noreply.github.com>
This commit is contained in:
Matthew Irish 2019-09-18 14:07:18 -05:00 committed by GitHub
parent fdc1274c70
commit 6e4cc02f4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 0 deletions

View File

@ -77,6 +77,7 @@ type SealStatusResponse struct {
ClusterName string `json:"cluster_name,omitempty"`
ClusterID string `json:"cluster_id,omitempty"`
RecoverySeal bool `json:"recovery_seal"`
StorageType string `json:"storage_type,omitempty"`
}
type UnsealOpts struct {

View File

@ -664,6 +664,7 @@ func (c *ServerCommand) Run(args []string) int {
coreConfig := &vault.CoreConfig{
Physical: backend,
RedirectAddr: config.Storage.RedirectAddr,
StorageType: config.Storage.Type,
HAPhysical: nil,
Seal: barrierSeal,
AuditBackends: c.AuditBackends,

View File

@ -198,6 +198,7 @@ func handleSysSealStatusRaw(core *vault.Core, w http.ResponseWriter, r *http.Req
Initialized: false,
Sealed: true,
RecoverySeal: core.SealAccess().RecoveryKeySupported(),
StorageType: core.StorageType(),
})
return
}
@ -233,6 +234,7 @@ func handleSysSealStatusRaw(core *vault.Core, w http.ResponseWriter, r *http.Req
ClusterName: clusterName,
ClusterID: clusterID,
RecoverySeal: core.SealAccess().RecoveryKeySupported(),
StorageType: core.StorageType(),
})
}
@ -249,6 +251,7 @@ type SealStatusResponse struct {
ClusterName string `json:"cluster_name,omitempty"`
ClusterID string `json:"cluster_id,omitempty"`
RecoverySeal bool `json:"recovery_seal"`
StorageType string `json:"storage_type,omitempty"`
}
// Note: because we didn't provide explicit tagging in the past we can't do it

View File

@ -172,6 +172,9 @@ type Core struct {
// HABackend may be available depending on the physical backend
ha physical.HABackend
// storageType is the the storage type set in the storage configuration
storageType string
// redirectAddr is the address we advertise as leader if held
redirectAddr string
@ -474,6 +477,8 @@ type CoreConfig struct {
Physical physical.Backend `json:"physical" structs:"physical" mapstructure:"physical"`
StorageType string `json:"storage_type" structs:"storage_type" mapstructure:"storage_type"`
// May be nil, which disables HA operations
HAPhysical physical.HABackend `json:"ha_physical" structs:"ha_physical" mapstructure:"ha_physical"`
@ -546,6 +551,7 @@ func (c *CoreConfig) Clone() *CoreConfig {
DisableCache: c.DisableCache,
DisableMlock: c.DisableMlock,
CacheSize: c.CacheSize,
StorageType: c.StorageType,
RedirectAddr: c.RedirectAddr,
ClusterAddr: c.ClusterAddr,
DefaultLeaseTTL: c.DefaultLeaseTTL,
@ -613,6 +619,7 @@ func NewCore(conf *CoreConfig) (*Core, error) {
devToken: conf.DevToken,
physical: conf.Physical,
underlyingPhysical: conf.Physical,
storageType: conf.StorageType,
redirectAddr: conf.RedirectAddr,
clusterAddr: new(atomic.Value),
clusterListener: new(atomic.Value),
@ -1820,6 +1827,11 @@ func (c *Core) SealAccess() *SealAccess {
return NewSealAccess(c.seal)
}
// StorageType returns a string equal to the storage configuration's type.
func (c *Core) StorageType() string {
return c.storageType
}
func (c *Core) Logger() log.Logger {
return c.logger
}