MCPcopy Create free account
hub / github.com/cortexproject/cortex / compileQueryAttributeRegex

Method compileQueryAttributeRegex

pkg/util/validation/limits.go:533–569  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

531}
532
533func (l *Limits) compileQueryAttributeRegex() error {
534 if !l.QueryPriority.Enabled && !l.QueryRejection.Enabled {
535 return nil
536 }
537 regexChanged := l.hasQueryAttributeRegexChanged()
538 newCompiledRegex := map[string]*regexp.Regexp{}
539
540 if l.QueryPriority.Enabled {
541 prioritySet := map[int64]struct{}{}
542
543 for i, priority := range l.QueryPriority.Priorities {
544 // Check for duplicate priority entry
545 if _, exists := prioritySet[priority.Priority]; exists {
546 return errDuplicateQueryPriorities
547 }
548 prioritySet[priority.Priority] = struct{}{}
549
550 err := l.compileQueryAttributeRegexes(l.QueryPriority.Priorities[i].QueryAttributes, regexChanged, newCompiledRegex)
551 if err != nil {
552 return err
553 }
554 }
555 }
556
557 if l.QueryRejection.Enabled {
558 err := l.compileQueryAttributeRegexes(l.QueryRejection.QueryAttributes, regexChanged, newCompiledRegex)
559 if err != nil {
560 return err
561 }
562 }
563
564 if regexChanged {
565 l.queryAttributeCompiledRegex = newCompiledRegex
566 }
567
568 return nil
569}
570
571func (l *Limits) compileQueryAttributeRegexes(queryAttributes []QueryAttribute, regexChanged bool, newCompiledRegex map[string]*regexp.Regexp) error {
572 for j, attribute := range queryAttributes {

Callers 3

UnmarshalYAMLMethod · 0.95
UnmarshalJSONMethod · 0.95

Implementers 1

Overridespkg/util/validation/limits.go

Tested by 1