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

@ -774,7 +774,13 @@ func (h *Hooks) LoadFromFile(path string, asTemplate bool) error {
file = buf.Bytes()
}
return yaml.Unmarshal(file, h)
toJSON, err := yaml.YAMLToJSON(file)
if err != nil {
return err
}
jsonDecoder := json.NewDecoder(bytes.NewBuffer(toJSON))
jsonDecoder.DisallowUnknownFields()
return jsonDecoder.Decode(h)
}
// Append appends hooks unless the new hooks contain a hook with an ID that already exists