-
Notifications
You must be signed in to change notification settings - Fork 455
/
custom.go
26 lines (21 loc) · 861 Bytes
/
custom.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// SPDX-License-Identifier: AGPL-3.0-only
// Provenance-includes-location: https://github.com/cortexproject/cortex/blob/master/pkg/ruler/rulespb/custom.go
// Provenance-includes-license: Apache-2.0
// Provenance-includes-copyright: The Cortex Authors.
package rulespb
import "github.com/prometheus/prometheus/model/rulefmt"
// RuleGroupList contains a set of rule groups
type RuleGroupList []*RuleGroupDesc
// Formatted returns the rule group list as a set of formatted rule groups mapped
// by namespace
func (l RuleGroupList) Formatted() map[string][]rulefmt.RuleGroup {
ruleMap := map[string][]rulefmt.RuleGroup{}
for _, g := range l {
if _, exists := ruleMap[g.Namespace]; !exists {
ruleMap[g.Namespace] = []rulefmt.RuleGroup{FromProto(g)}
continue
}
ruleMap[g.Namespace] = append(ruleMap[g.Namespace], FromProto(g))
}
return ruleMap
}