mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 11:55:40 +01:00
Bailout unknown config (#216)
* provider now checks for undecoded config entries and returns an error if any are found * Specific error message now in server logs, more general message for user * Changes spaces to tabs for formatting consistency * Further formatting * Improved handling of undecoded TOML fields in config. * aggregator now checks for not decoded config options Co-authored-by: Jan Höfelmeyer <Jan Höfelmeyer jhoefelmeyer@intevation.de> Co-authored-by: Sascha L. Teichmann <sascha.teichmann@intevation.de>
This commit is contained in:
parent
cbb9c7a7a1
commit
46f79a9e24
3 changed files with 15 additions and 3 deletions
|
|
@ -228,10 +228,15 @@ func loadConfig(path string) (*config, error) {
|
|||
}
|
||||
|
||||
var cfg config
|
||||
if _, err := toml.DecodeFile(path, &cfg); err != nil {
|
||||
md, err := toml.DecodeFile(path, &cfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if undecoded := md.Undecoded(); len(undecoded) != 0 {
|
||||
return nil, fmt.Errorf("could not parse %q from config.toml", undecoded)
|
||||
}
|
||||
|
||||
cfg.setDefaults()
|
||||
|
||||
if err := cfg.check(); err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue