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

Method compileQueryAttributeRegexes

pkg/util/validation/limits.go:571–593  ·  view source on GitHub ↗
(queryAttributes []QueryAttribute, regexChanged bool, newCompiledRegex map[string]*regexp.Regexp)

Source from the content-addressed store, hash-verified

569}
570
571func (l *Limits) compileQueryAttributeRegexes(queryAttributes []QueryAttribute, regexChanged bool, newCompiledRegex map[string]*regexp.Regexp) error {
572 for j, attribute := range queryAttributes {
573 if regexChanged {
574 compiledRegex, err := regexp.Compile(attribute.Regex)
575 if err != nil {
576 return errors.Join(errCompilingQueryPriorityRegex, err)
577 }
578 newCompiledRegex[attribute.Regex] = compiledRegex
579 queryAttributes[j].CompiledRegex = compiledRegex
580
581 compiledUserAgentRegex, err := regexp.Compile(attribute.UserAgentRegex)
582 if err != nil {
583 return errors.Join(errCompilingQueryPriorityRegex, err)
584 }
585 newCompiledRegex[attribute.UserAgentRegex] = compiledUserAgentRegex
586 queryAttributes[j].CompiledUserAgentRegex = compiledUserAgentRegex
587 } else {
588 queryAttributes[j].CompiledRegex = l.queryAttributeCompiledRegex[attribute.Regex]
589 queryAttributes[j].CompiledUserAgentRegex = l.queryAttributeCompiledRegex[attribute.UserAgentRegex]
590 }
591 }
592 return nil
593}
594
595// When we load YAML from disk, we want the various per-customer limits
596// to default to any values specified on the command line, not default

Callers 1

Implementers 1

Overridespkg/util/validation/limits.go

Calls 1

JoinMethod · 0.80

Tested by

no test coverage detected