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

Method restoreConfig

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

Source from the content-addressed store, hash-verified

324}
325
326func (a *API) restoreConfig(w http.ResponseWriter, r *http.Request) {
327 userID, _, err := users.ExtractTenantIDFromHTTPRequest(r)
328 if err != nil {
329 http.Error(w, err.Error(), http.StatusUnauthorized)
330 return
331 }
332 logger := util_log.WithContext(r.Context(), util_log.Logger)
333
334 if err := a.db.RestoreConfig(r.Context(), userID); err != nil {
335 if err == sql.ErrNoRows {
336 level.Info(logger).Log("msg", "restore config - no configuration", "userID", userID)
337 http.Error(w, "No configuration", http.StatusNotFound)
338 return
339 }
340 level.Error(logger).Log("msg", "error restoring config", "err", err)
341 http.Error(w, err.Error(), http.StatusInternalServerError)
342 return
343 }
344 level.Info(logger).Log("msg", "config restored", "userID", userID)
345 w.WriteHeader(http.StatusOK)
346}
347
348const (
349 FormatInvalid = "invalid"

Callers

nothing calls this directly

Calls 5

RestoreConfigMethod · 0.65
ErrorMethod · 0.45
ContextMethod · 0.45
LogMethod · 0.45

Tested by

no test coverage detected