mirror of
https://github.com/prometheus/alertmanager
synced 2025-01-06 05:50:10 +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)
|
||||
|
||||
// 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 {
|
||||
respondError(w, apiError{
|
||||
typ: errorBadData,
|
||||
@ -430,7 +419,7 @@ func respondError(w http.ResponseWriter, apiErr apiError, data interface{}) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
log.Errorf("api error: %v", apiErr)
|
||||
log.Errorf("api error: %s", apiErr)
|
||||
|
||||
w.Write(b)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user