From 1019ad1b2fe12f0a2ecc352d45c78291b8c23af5 Mon Sep 17 00:00:00 2001 From: Jonathan Buch Date: Mon, 29 Jan 2024 13:14:13 +0100 Subject: [PATCH] Document configuration changes --- CHANGELOG.md | 8 ++++++++ pkg/config/rule_matching.go | 2 +- pkg/config/rule_matching_test.go | 6 +++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4589c0a..81afa25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Releases +## 1.5.0 - XXX backend mode + +* Add `alertmanager` API, e.g. `/api/alertmanager/v2/status` +* Add negative matchers: `!=` and `!~` +* Breaking configuration changes: + * To be more compatible with `alertmanager`, the `~=` is now `=~` + using regular expression matching. + ## v1.4 - 2024-01-11 light mode * Make the look of tuwat configurable via `style` property. diff --git a/pkg/config/rule_matching.go b/pkg/config/rule_matching.go index f79a44b..368eec6 100644 --- a/pkg/config/rule_matching.go +++ b/pkg/config/rule_matching.go @@ -26,7 +26,7 @@ func ParseRuleMatcher(value string) RuleMatcher { prefix := matches[1] value := matches[2] switch prefix { - case "=~": + case "=~", "~=": return regexpMatcher{regexp.MustCompile(value)} case "!~": return not(regexpMatcher{regexp.MustCompile(value)}) diff --git a/pkg/config/rule_matching_test.go b/pkg/config/rule_matching_test.go index 16dca9c..ed84059 100644 --- a/pkg/config/rule_matching_test.go +++ b/pkg/config/rule_matching_test.go @@ -18,7 +18,7 @@ func TestParseRuleMatcher(t *testing.T) { want: regexpMatcher{regexp.MustCompile("X")}, }, { name: "Regexp", - value: "~= X", + value: "=~ X", want: regexpMatcher{regexp.MustCompile("X")}, }, { name: "numeric equality matcher", @@ -84,7 +84,7 @@ func TestRuleMatching(t *testing.T) { want: true, }, { name: "regexp", - rule: "~= X", + rule: "=~ X", str: "Xavier", want: true, }, { @@ -137,7 +137,7 @@ func TestRuleMatching(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if got := ParseRuleMatcher(tt.rule); got.MatchString(tt.str) != tt.want { - t.Errorf("Matching %v ~= %v, want %v", tt.rule, tt.str, tt.want) + t.Errorf("Matching %v =~ %v, want %v", tt.rule, tt.str, tt.want) } }) }