Skip to content

[pull] main from prometheus:main #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions model/rulefmt/rulefmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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"`
}

Expand All @@ -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"`
Expand All @@ -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"),
Expand Down
Loading