Fix error on unrecognized configuration keys

- Error while loading configuration with unrecognized keys
- Do not start if failed to load configuration from file
This commit is contained in:
Barak Amar 2022-10-11 10:04:37 +03:00
parent dab29e7267
commit d7367bcb8b
4 changed files with 49 additions and 13 deletions

View file

@ -194,19 +194,19 @@ func main() {
err := newHooks.LoadFromFile(hooksFilePath, *asTemplate)
if err != nil {
log.Printf("couldn't load hooks from file! %+v\n", err)
} else {
log.Printf("found %d hook(s) in file\n", len(newHooks))
for _, hook := range newHooks {
if matchLoadedHook(hook.ID) != nil {
log.Fatalf("error: hook with the id %s has already been loaded!\nplease check your hooks file for duplicate hooks ids!\n", hook.ID)
}
log.Printf("\tloaded: %s\n", hook.ID)
}
loadedHooksFromFiles[hooksFilePath] = newHooks
log.Fatalf("couldn't load hooks from file! %+v\n", err)
}
log.Printf("found %d hook(s) in file\n", len(newHooks))
for _, hook := range newHooks {
if matchLoadedHook(hook.ID) != nil {
log.Fatalf("error: hook with the id %s has already been loaded!\nplease check your hooks file for duplicate hooks ids!\n", hook.ID)
}
log.Printf("\tloaded: %s\n", hook.ID)
}
loadedHooksFromFiles[hooksFilePath] = newHooks
}
newHooksFiles := hooksFiles[:0]