mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 03:27:54 +00:00
Properly scope config objects for reloading
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
auditFile "github.com/hashicorp/vault/builtin/audit/file"
|
||||
auditSyslog "github.com/hashicorp/vault/builtin/audit/syslog"
|
||||
"github.com/hashicorp/vault/command/server"
|
||||
"github.com/hashicorp/vault/version"
|
||||
|
||||
credAppId "github.com/hashicorp/vault/builtin/credential/app-id"
|
||||
@@ -80,6 +81,7 @@ func Commands(metaPtr *command.Meta) map[string]cli.CommandFactory {
|
||||
},
|
||||
ShutdownCh: makeShutdownCh(),
|
||||
SighupCh: makeSighupCh(),
|
||||
ReloadFuncs: map[string][]server.ReloadFunc{},
|
||||
}, nil
|
||||
},
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ type ServerCommand struct {
|
||||
|
||||
Meta
|
||||
|
||||
ReloadFuncs []server.ReloadFunc
|
||||
ReloadFuncs map[string][]server.ReloadFunc
|
||||
}
|
||||
|
||||
func (c *ServerCommand) Run(args []string) int {
|
||||
@@ -302,7 +302,9 @@ func (c *ServerCommand) Run(args []string) int {
|
||||
lns = append(lns, ln)
|
||||
|
||||
if reloadFunc != nil {
|
||||
c.ReloadFuncs = append(c.ReloadFuncs, reloadFunc)
|
||||
relSlice := c.ReloadFuncs["listener|"+lnConfig.Type]
|
||||
relSlice = append(relSlice, reloadFunc)
|
||||
c.ReloadFuncs["listener|"+lnConfig.Type] = relSlice
|
||||
}
|
||||
}
|
||||
|
||||
@@ -575,9 +577,9 @@ func (c *ServerCommand) Reload(configPath []string) error {
|
||||
|
||||
var reloadErrors *multierror.Error
|
||||
// Call reload on the listeners. This will call each listener with each
|
||||
// config block, but they verify the ID.
|
||||
// config block, but they verify the address.
|
||||
for _, lnConfig := range config.Listeners {
|
||||
for _, relFunc := range c.ReloadFuncs {
|
||||
for _, relFunc := range c.ReloadFuncs["listener|"+lnConfig.Type] {
|
||||
if err := relFunc(lnConfig.Config); err != nil {
|
||||
retErr := fmt.Errorf("Error encountered reloading configuration: %s", err)
|
||||
reloadErrors = multierror.Append(retErr)
|
||||
|
||||
Reference in New Issue
Block a user