mirror of
https://github.com/adnanh/webhook.git
synced 2025-10-05 06:01:03 +00:00
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:
parent
dab29e7267
commit
d7367bcb8b
4 changed files with 49 additions and 13 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue