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

Method getConfigs

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

Source from the content-addressed store, hash-verified

269}
270
271func (a *API) getConfigs(w http.ResponseWriter, r *http.Request) {
272 var cfgs map[string]userconfig.View
273 var cfgErr error
274 logger := util_log.WithContext(r.Context(), util_log.Logger)
275 rawSince := r.FormValue("since")
276 if rawSince == "" {
277 cfgs, cfgErr = a.db.GetAllConfigs(r.Context())
278 } else {
279 since, err := strconv.ParseUint(rawSince, 10, 0)
280 if err != nil {
281 level.Info(logger).Log("msg", "invalid config ID", "err", err)
282 http.Error(w, err.Error(), http.StatusBadRequest)
283 return
284 }
285 cfgs, cfgErr = a.db.GetConfigs(r.Context(), userconfig.ID(since))
286 }
287
288 if cfgErr != nil {
289 // XXX: Untested
290 level.Error(logger).Log("msg", "error getting configs", "err", cfgErr)
291 http.Error(w, cfgErr.Error(), http.StatusInternalServerError)
292 return
293 }
294
295 view := ConfigsView{Configs: cfgs}
296 w.Header().Set("Content-Type", "application/json")
297 if err := json.NewEncoder(w).Encode(view); err != nil {
298 // XXX: Untested
299 http.Error(w, err.Error(), http.StatusInternalServerError)
300 return
301 }
302}
303
304func (a *API) deactivateConfig(w http.ResponseWriter, r *http.Request) {
305 userID, _, err := users.ExtractTenantIDFromHTTPRequest(r)

Callers

nothing calls this directly

Calls 9

IDTypeAlias · 0.92
GetAllConfigsMethod · 0.65
GetConfigsMethod · 0.65
SetMethod · 0.65
EncodeMethod · 0.65
ContextMethod · 0.45
LogMethod · 0.45
ErrorMethod · 0.45
HeaderMethod · 0.45

Tested by

no test coverage detected