MCPcopy Index your code
hub / github.com/cortexproject/cortex / validateAlertmanagerConfig

Method validateAlertmanagerConfig

pkg/configs/api/api.go:206–227  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

204}
205
206func (a *API) validateAlertmanagerConfig(w http.ResponseWriter, r *http.Request) {
207 logger := util_log.WithContext(r.Context(), util_log.Logger)
208 cfg, err := io.ReadAll(r.Body)
209 if err != nil {
210 level.Error(logger).Log("msg", "error reading request body", "err", err)
211 http.Error(w, err.Error(), http.StatusInternalServerError)
212 return
213 }
214
215 if err = validateAlertmanagerConfig(string(cfg), a.cfg.Notifications); err != nil {
216 w.WriteHeader(http.StatusBadRequest)
217 util.WriteJSONResponse(w, map[string]string{
218 "status": "error",
219 "error": err.Error(),
220 })
221 return
222 }
223
224 util.WriteJSONResponse(w, map[string]string{
225 "status": "success",
226 })
227}
228
229func validateAlertmanagerConfig(cfg string, noCfg NotificationsConfig) error {
230 amCfg, err := amconfig.Load(cfg)

Callers

nothing calls this directly

Calls 5

WriteJSONResponseFunction · 0.92
ContextMethod · 0.45
LogMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected