mirror of
https://github.com/prometheus/alertmanager
synced 2025-01-07 22:39:54 +00:00
api: push silence validation into provider
This commit is contained in:
parent
6ad866dd27
commit
00b1a396af
13
api.go
13
api.go
@ -293,17 +293,6 @@ func (api *API) addSilence(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
sil := types.NewSilence(&msil)
|
sil := types.NewSilence(&msil)
|
||||||
|
|
||||||
// if sil.CreatedAt.IsZero() {
|
|
||||||
// sil.CreatedAt = time.Now()
|
|
||||||
// }
|
|
||||||
|
|
||||||
if err := sil.Validate(); err != nil {
|
|
||||||
respondError(w, apiError{
|
|
||||||
typ: errorBadData,
|
|
||||||
err: err,
|
|
||||||
}, nil)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err := sil.Init(); err != nil {
|
if err := sil.Init(); err != nil {
|
||||||
respondError(w, apiError{
|
respondError(w, apiError{
|
||||||
typ: errorBadData,
|
typ: errorBadData,
|
||||||
@ -430,7 +419,7 @@ func respondError(w http.ResponseWriter, apiErr apiError, data interface{}) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Errorf("api error: %v", apiErr)
|
log.Errorf("api error: %s", apiErr)
|
||||||
|
|
||||||
w.Write(b)
|
w.Write(b)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user