Skip to content

Commit

Permalink
Vault-4279 reporting redundant/unused keys in config
Browse files Browse the repository at this point in the history
  • Loading branch information
hghaf099 committed Mar 29, 2022
1 parent 8e0f267 commit 94eef99
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions command/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ func (c *ServerCommand) parseConfig() (*server.Config, []configutil.ConfigError,
}

func (c *ServerCommand) runRecoveryMode() int {
config, _, err := c.parseConfig()
config, configErrors, err := c.parseConfig()
if err != nil {
c.UI.Error(err.Error())
return 1
Expand Down Expand Up @@ -458,6 +458,11 @@ func (c *ServerCommand) runRecoveryMode() int {
JSONFormat: logFormat == logging.JSONFormat,
})

// reporting Errors found in the config
for _, cErr := range configErrors {
c.logger.Error(cErr.String())
}

// Ensure logging is flushed if initialization fails
defer c.flushLog()

Expand Down Expand Up @@ -1071,7 +1076,7 @@ func (c *ServerCommand) Run(args []string) int {
config.Listeners[0].Telemetry.UnauthenticatedMetricsAccess = true
}

parsedConfig, _, err := c.parseConfig()
parsedConfig, configErrors, err := c.parseConfig()
if err != nil {
c.UI.Error(err.Error())
return 1
Expand Down Expand Up @@ -1116,6 +1121,11 @@ func (c *ServerCommand) Run(args []string) int {
})
}

// reporting Errors found in the config
for _, cErr := range configErrors {
c.logger.Error(cErr.String())
}

// Ensure logging is flushed if initialization fails
defer c.flushLog()

Expand Down Expand Up @@ -1539,6 +1549,7 @@ func (c *ServerCommand) Run(args []string) int {
// Check for new log level
var config *server.Config
var level hclog.Level
var configErrors []configutil.ConfigError
for _, path := range c.flagConfigs {
current, err := server.LoadConfig(path)
if err != nil {
Expand All @@ -1559,6 +1570,11 @@ func (c *ServerCommand) Run(args []string) int {
goto RUNRELOADFUNCS
}

// reporting Errors found in the config
for _, cErr := range configErrors {
c.logger.Error(cErr.String())
}

core.SetConfig(config)

// reloading custom response headers to make sure we have
Expand Down

0 comments on commit 94eef99

Please sign in to comment.