Skip to content
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

fix: default alert rule not being read #151

Merged
merged 3 commits into from
Dec 12, 2023
Merged
Changes from 1 commit
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
12 changes: 4 additions & 8 deletions thousandeyes/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,21 +213,17 @@ func FixReadValues(m interface{}, name string) (interface{}, error) {
}

// Remove all alert rule fields except for rule ID. Ignore default rules.
// Remove all alert rule fields except for rule ID.
case "alert_rules":
alert_rules := m.([]interface{})
joaomper-TE marked this conversation as resolved.
Show resolved Hide resolved
// Edit the alert_rules slice in place, to return the same type.
i := 0
for i < len(alert_rules) {
rule := alert_rules[i].(map[string]interface{})
if is_default, ok := rule["default"]; ok && is_default != nil && *is_default.(*bool) {
// Remove this item from the slice
alert_rules = append(alert_rules[:i], alert_rules[i+1:]...)
} else {
alert_rules[i] = map[string]interface{}{
"rule_id": rule["rule_id"],
}
i = i + 1
alert_rules[i] = map[string]interface{}{
"rule_id": rule["rule_id"],
}
i = i + 1
}
m = alert_rules

Expand Down