mirror of
https://github.com/prometheus/prometheus.git
synced 2025-07-01 18:21:21 +00:00
chore: Export rulefmt.ruleNode (#16252)
* Export rulefmt.ruleNode Signed-off-by: Alex Weaver <weaver.alex.d@gmail.com> * Export RuleGroupNode for consistency Signed-off-by: Alex Weaver <weaver.alex.d@gmail.com> --------- Signed-off-by: Alex Weaver <weaver.alex.d@gmail.com>
This commit is contained in:
parent
f5f22e7201
commit
3d603d1957
1 changed files with 7 additions and 7 deletions
|
@ -92,7 +92,7 @@ type RuleGroups struct {
|
|||
}
|
||||
|
||||
type ruleGroups struct {
|
||||
Groups []ruleGroupNode `yaml:"groups"`
|
||||
Groups []RuleGroupNode `yaml:"groups"`
|
||||
}
|
||||
|
||||
// Validate validates all rules in the rule groups.
|
||||
|
@ -158,14 +158,14 @@ type RuleGroup struct {
|
|||
Labels map[string]string `yaml:"labels,omitempty"`
|
||||
}
|
||||
|
||||
// ruleGroupNode adds yaml.v3 layer to support line and columns outputs for invalid rule groups.
|
||||
type ruleGroupNode struct {
|
||||
// RuleGroupNode adds yaml.v3 layer to support line and columns outputs for invalid rule groups.
|
||||
type RuleGroupNode struct {
|
||||
yaml.Node
|
||||
Name string `yaml:"name"`
|
||||
Interval model.Duration `yaml:"interval,omitempty"`
|
||||
QueryOffset *model.Duration `yaml:"query_offset,omitempty"`
|
||||
Limit int `yaml:"limit,omitempty"`
|
||||
Rules []ruleNode `yaml:"rules"`
|
||||
Rules []RuleNode `yaml:"rules"`
|
||||
Labels map[string]string `yaml:"labels,omitempty"`
|
||||
}
|
||||
|
||||
|
@ -180,8 +180,8 @@ type Rule struct {
|
|||
Annotations map[string]string `yaml:"annotations,omitempty"`
|
||||
}
|
||||
|
||||
// ruleNode adds yaml.v3 layer to support line and column outputs for invalid rules.
|
||||
type ruleNode struct {
|
||||
// RuleNode adds yaml.v3 layer to support line and column outputs for invalid rules.
|
||||
type RuleNode struct {
|
||||
Record yaml.Node `yaml:"record,omitempty"`
|
||||
Alert yaml.Node `yaml:"alert,omitempty"`
|
||||
Expr yaml.Node `yaml:"expr"`
|
||||
|
@ -192,7 +192,7 @@ type ruleNode struct {
|
|||
}
|
||||
|
||||
// Validate the rule and return a list of encountered errors.
|
||||
func (r *Rule) Validate(node ruleNode) (nodes []WrappedError) {
|
||||
func (r *Rule) Validate(node RuleNode) (nodes []WrappedError) {
|
||||
if r.Record != "" && r.Alert != "" {
|
||||
nodes = append(nodes, WrappedError{
|
||||
err: errors.New("only one of 'record' and 'alert' must be set"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue