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

Function parseListRulesPaginationRequest

pkg/ruler/api.go:283–319  ·  view source on GitHub ↗
(req *http.Request)

Source from the content-addressed store, hash-verified

281}
282
283func parseListRulesPaginationRequest(req *http.Request) (listRulesPaginationRequest, error) {
284 var (
285 returnMaxRuleGroups = int32(-1)
286 )
287
288 maxGroups := req.URL.Query().Get("group_limit")
289 nextToken := req.URL.Query().Get("group_next_token")
290
291 if nextToken != "" && maxGroups == "" {
292 return listRulesPaginationRequest{
293 MaxRuleGroups: -1,
294 NextToken: "",
295 }, errors.New("group_limit needs to be present in order to paginate over the groups")
296 }
297
298 if maxGroups != "" {
299 parsedMaxGroups, err := strconv.ParseInt(maxGroups, 10, 32)
300 if err != nil {
301 return listRulesPaginationRequest{
302 MaxRuleGroups: -1,
303 NextToken: "",
304 }, errors.New("group_limit needs to be a valid number")
305 }
306 if parsedMaxGroups <= 0 {
307 return listRulesPaginationRequest{
308 MaxRuleGroups: -1,
309 NextToken: "",
310 }, errors.New("group_limit needs to be greater than 0")
311 }
312 returnMaxRuleGroups = int32(parsedMaxGroups)
313 }
314
315 return listRulesPaginationRequest{
316 MaxRuleGroups: returnMaxRuleGroups,
317 NextToken: nextToken,
318 }, nil
319}
320
321func parseExcludeAlerts(r *http.Request) (bool, error) {
322 excludeAlertsParam := strings.ToLower(r.URL.Query().Get("exclude_alerts"))

Callers 1

PrometheusRulesMethod · 0.85

Calls 2

GetMethod · 0.65
QueryMethod · 0.65

Tested by

no test coverage detected