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:
Alexander Weaver 2025-03-20 17:58:32 -05:00 committed by GitHub
parent f5f22e7201
commit 3d603d1957
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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"),