From 52eb1fc4aa84d24fab9cb61cc4af57aeb773b6f9 Mon Sep 17 00:00:00 2001 From: George Robinson Date: Fri, 21 Jun 2024 15:17:27 +0100 Subject: [PATCH] Rename matchers package to matcher singular (#3777) * Rename matchers package to matcher singular I realized that we had named the package plural "matchers" when its idiomatic in Go to use singular package names. --------- Signed-off-by: George Robinson --- api/v2/api.go | 2 +- cli/alert_add.go | 2 +- cli/alert_query.go | 2 +- cli/root.go | 2 +- cli/silence_add.go | 2 +- cli/silence_query.go | 2 +- cli/test_routing.go | 2 +- cmd/alertmanager/main.go | 2 +- config/config.go | 2 +- {matchers => matcher}/compat/parse.go | 16 ++++++++-------- {matchers => matcher}/compat/parse_test.go | 0 .../compliance/compliance_test.go | 2 +- {matchers => matcher}/parse/bench_test.go | 0 {matchers => matcher}/parse/fuzz_test.go | 0 {matchers => matcher}/parse/lexer.go | 0 {matchers => matcher}/parse/lexer_test.go | 0 {matchers => matcher}/parse/parse.go | 0 {matchers => matcher}/parse/parse_test.go | 0 {matchers => matcher}/parse/token.go | 0 pkg/labels/matcher.go | 2 +- silence/silence.go | 2 +- silence/silence_test.go | 2 +- types/types.go | 2 +- types/types_test.go | 2 +- 24 files changed, 23 insertions(+), 23 deletions(-) rename {matchers => matcher}/compat/parse.go (95%) rename {matchers => matcher}/compat/parse_test.go (100%) rename {matchers => matcher}/compliance/compliance_test.go (99%) rename {matchers => matcher}/parse/bench_test.go (100%) rename {matchers => matcher}/parse/fuzz_test.go (100%) rename {matchers => matcher}/parse/lexer.go (100%) rename {matchers => matcher}/parse/lexer_test.go (100%) rename {matchers => matcher}/parse/parse.go (100%) rename {matchers => matcher}/parse/parse_test.go (100%) rename {matchers => matcher}/parse/token.go (100%) diff --git a/api/v2/api.go b/api/v2/api.go index b279b619..aa6c8a72 100644 --- a/api/v2/api.go +++ b/api/v2/api.go @@ -45,7 +45,7 @@ import ( "github.com/prometheus/alertmanager/cluster" "github.com/prometheus/alertmanager/config" "github.com/prometheus/alertmanager/dispatch" - "github.com/prometheus/alertmanager/matchers/compat" + "github.com/prometheus/alertmanager/matcher/compat" "github.com/prometheus/alertmanager/pkg/labels" "github.com/prometheus/alertmanager/provider" "github.com/prometheus/alertmanager/silence" diff --git a/cli/alert_add.go b/cli/alert_add.go index 4e7eae7e..2890946c 100644 --- a/cli/alert_add.go +++ b/cli/alert_add.go @@ -25,7 +25,7 @@ import ( "github.com/prometheus/alertmanager/api/v2/client/alert" "github.com/prometheus/alertmanager/api/v2/models" - "github.com/prometheus/alertmanager/matchers/compat" + "github.com/prometheus/alertmanager/matcher/compat" "github.com/prometheus/alertmanager/pkg/labels" ) diff --git a/cli/alert_query.go b/cli/alert_query.go index e4bddaa6..de42ed0f 100644 --- a/cli/alert_query.go +++ b/cli/alert_query.go @@ -23,7 +23,7 @@ import ( "github.com/prometheus/alertmanager/api/v2/client/alert" "github.com/prometheus/alertmanager/cli/format" - "github.com/prometheus/alertmanager/matchers/compat" + "github.com/prometheus/alertmanager/matcher/compat" ) type alertQueryCmd struct { diff --git a/cli/root.go b/cli/root.go index fe02fb82..1e63cfe8 100644 --- a/cli/root.go +++ b/cli/root.go @@ -34,7 +34,7 @@ import ( "github.com/prometheus/alertmanager/cli/config" "github.com/prometheus/alertmanager/cli/format" "github.com/prometheus/alertmanager/featurecontrol" - "github.com/prometheus/alertmanager/matchers/compat" + "github.com/prometheus/alertmanager/matcher/compat" ) var ( diff --git a/cli/silence_add.go b/cli/silence_add.go index 4456ddec..e23d1fcc 100644 --- a/cli/silence_add.go +++ b/cli/silence_add.go @@ -27,7 +27,7 @@ import ( "github.com/prometheus/alertmanager/api/v2/client/silence" "github.com/prometheus/alertmanager/api/v2/models" - "github.com/prometheus/alertmanager/matchers/compat" + "github.com/prometheus/alertmanager/matcher/compat" "github.com/prometheus/alertmanager/pkg/labels" ) diff --git a/cli/silence_query.go b/cli/silence_query.go index 5eb33a27..ba5f01e1 100644 --- a/cli/silence_query.go +++ b/cli/silence_query.go @@ -25,7 +25,7 @@ import ( "github.com/prometheus/alertmanager/api/v2/client/silence" "github.com/prometheus/alertmanager/api/v2/models" "github.com/prometheus/alertmanager/cli/format" - "github.com/prometheus/alertmanager/matchers/compat" + "github.com/prometheus/alertmanager/matcher/compat" ) type silenceQueryCmd struct { diff --git a/cli/test_routing.go b/cli/test_routing.go index 589a2e8c..163dce39 100644 --- a/cli/test_routing.go +++ b/cli/test_routing.go @@ -24,7 +24,7 @@ import ( "github.com/prometheus/alertmanager/api/v2/models" "github.com/prometheus/alertmanager/dispatch" - "github.com/prometheus/alertmanager/matchers/compat" + "github.com/prometheus/alertmanager/matcher/compat" "github.com/prometheus/alertmanager/pkg/labels" ) diff --git a/cmd/alertmanager/main.go b/cmd/alertmanager/main.go index 49b515c1..d44d58a8 100644 --- a/cmd/alertmanager/main.go +++ b/cmd/alertmanager/main.go @@ -50,7 +50,7 @@ import ( "github.com/prometheus/alertmanager/dispatch" "github.com/prometheus/alertmanager/featurecontrol" "github.com/prometheus/alertmanager/inhibit" - "github.com/prometheus/alertmanager/matchers/compat" + "github.com/prometheus/alertmanager/matcher/compat" "github.com/prometheus/alertmanager/nflog" "github.com/prometheus/alertmanager/notify" "github.com/prometheus/alertmanager/provider/mem" diff --git a/config/config.go b/config/config.go index b1760ea6..cdc83e37 100644 --- a/config/config.go +++ b/config/config.go @@ -30,7 +30,7 @@ import ( "github.com/prometheus/common/model" "gopkg.in/yaml.v2" - "github.com/prometheus/alertmanager/matchers/compat" + "github.com/prometheus/alertmanager/matcher/compat" "github.com/prometheus/alertmanager/pkg/labels" "github.com/prometheus/alertmanager/timeinterval" ) diff --git a/matchers/compat/parse.go b/matcher/compat/parse.go similarity index 95% rename from matchers/compat/parse.go rename to matcher/compat/parse.go index 0c0dfffb..14aeb5a2 100644 --- a/matchers/compat/parse.go +++ b/matcher/compat/parse.go @@ -24,7 +24,7 @@ import ( "github.com/prometheus/common/model" "github.com/prometheus/alertmanager/featurecontrol" - "github.com/prometheus/alertmanager/matchers/parse" + "github.com/prometheus/alertmanager/matcher/parse" "github.com/prometheus/alertmanager/pkg/labels" ) @@ -90,7 +90,7 @@ func ClassicMatchersParser(l log.Logger) ParseMatchers { } } -// UTF8MatcherParser uses the new matchers/parse parser to parse the matcher +// UTF8MatcherParser uses the new matcher/parse parser to parse the matcher // in the input string. If this fails it does not revert to the pkg/labels parser. func UTF8MatcherParser(l log.Logger) ParseMatcher { return func(input, origin string) (matcher *labels.Matcher, err error) { @@ -102,7 +102,7 @@ func UTF8MatcherParser(l log.Logger) ParseMatcher { } } -// UTF8MatchersParser uses the new matchers/parse parser to parse zero or more +// UTF8MatchersParser uses the new matcher/parse parser to parse zero or more // matchers in the input string. If this fails it does not revert to the // pkg/labels parser. func UTF8MatchersParser(l log.Logger) ParseMatchers { @@ -112,7 +112,7 @@ func UTF8MatchersParser(l log.Logger) ParseMatchers { } } -// FallbackMatcherParser uses the new matchers/parse parser to parse zero or more +// FallbackMatcherParser uses the new matcher/parse parser to parse zero or more // matchers in the string. If this fails it reverts to the pkg/labels parser and // emits a warning log line. func FallbackMatcherParser(l log.Logger) ParseMatcher { @@ -130,7 +130,7 @@ func FallbackMatcherParser(l log.Logger) ParseMatcher { if cErr != nil { return nil, cErr } - // The input is valid in the pkg/labels parser, but not the matchers/parse + // The input is valid in the pkg/labels parser, but not the matcher/parse // parser. This means the input is not forwards compatible. suggestion := cMatcher.String() level.Warn(l).Log("msg", "Alertmanager is moving to a new parser for labels and matchers, and this input is incompatible. Alertmanager has instead parsed the input using the classic matchers parser as a fallback. To make this input compatible with the UTF-8 matchers parser please make sure all regular expressions and values are double-quoted. If you are still seeing this message please open an issue.", "input", input, "origin", origin, "err", nErr, "suggestion", suggestion) @@ -146,7 +146,7 @@ func FallbackMatcherParser(l log.Logger) ParseMatcher { } } -// FallbackMatchersParser uses the new matchers/parse parser to parse the +// FallbackMatchersParser uses the new matcher/parse parser to parse the // matcher in the input string. If this fails it falls back to the pkg/labels // parser and emits a warning log line. func FallbackMatchersParser(l log.Logger) ParseMatchers { @@ -161,7 +161,7 @@ func FallbackMatchersParser(l log.Logger) ParseMatchers { if cErr != nil { return nil, cErr } - // The input is valid in the pkg/labels parser, but not the matchers/parse + // The input is valid in the pkg/labels parser, but not the matcher/parse // parser. This means the input is not forwards compatible. var sb strings.Builder for i, n := range cMatchers { @@ -172,7 +172,7 @@ func FallbackMatchersParser(l log.Logger) ParseMatchers { } suggestion := sb.String() // The input is valid in the pkg/labels parser, but not the - // new matchers/parse parser. + // new matcher/parse parser. level.Warn(l).Log("msg", "Alertmanager is moving to a new parser for labels and matchers, and this input is incompatible. Alertmanager has instead parsed the input using the classic matchers parser as a fallback. To make this input compatible with the UTF-8 matchers parser please make sure all regular expressions and values are double-quoted. If you are still seeing this message please open an issue.", "input", input, "origin", origin, "err", nErr, "suggestion", suggestion) return cMatchers, nil } diff --git a/matchers/compat/parse_test.go b/matcher/compat/parse_test.go similarity index 100% rename from matchers/compat/parse_test.go rename to matcher/compat/parse_test.go diff --git a/matchers/compliance/compliance_test.go b/matcher/compliance/compliance_test.go similarity index 99% rename from matchers/compliance/compliance_test.go rename to matcher/compliance/compliance_test.go index 844f80a5..2fd39ec6 100644 --- a/matchers/compliance/compliance_test.go +++ b/matcher/compliance/compliance_test.go @@ -17,7 +17,7 @@ import ( "reflect" "testing" - "github.com/prometheus/alertmanager/matchers/parse" + "github.com/prometheus/alertmanager/matcher/parse" "github.com/prometheus/alertmanager/pkg/labels" ) diff --git a/matchers/parse/bench_test.go b/matcher/parse/bench_test.go similarity index 100% rename from matchers/parse/bench_test.go rename to matcher/parse/bench_test.go diff --git a/matchers/parse/fuzz_test.go b/matcher/parse/fuzz_test.go similarity index 100% rename from matchers/parse/fuzz_test.go rename to matcher/parse/fuzz_test.go diff --git a/matchers/parse/lexer.go b/matcher/parse/lexer.go similarity index 100% rename from matchers/parse/lexer.go rename to matcher/parse/lexer.go diff --git a/matchers/parse/lexer_test.go b/matcher/parse/lexer_test.go similarity index 100% rename from matchers/parse/lexer_test.go rename to matcher/parse/lexer_test.go diff --git a/matchers/parse/parse.go b/matcher/parse/parse.go similarity index 100% rename from matchers/parse/parse.go rename to matcher/parse/parse.go diff --git a/matchers/parse/parse_test.go b/matcher/parse/parse_test.go similarity index 100% rename from matchers/parse/parse_test.go rename to matcher/parse/parse_test.go diff --git a/matchers/parse/token.go b/matcher/parse/token.go similarity index 100% rename from matchers/parse/token.go rename to matcher/parse/token.go diff --git a/pkg/labels/matcher.go b/pkg/labels/matcher.go index f37fcb21..eba6b4ca 100644 --- a/pkg/labels/matcher.go +++ b/pkg/labels/matcher.go @@ -205,7 +205,7 @@ func (ms Matchers) String() string { return buf.String() } -// This is copied from matchers/parse/lexer.go. It will be removed when +// This is copied from matcher/parse/lexer.go. It will be removed when // the transition window from classic matchers to UTF-8 matchers is complete, // as then we can use double quotes when printing the label name for all // matchers. Until then, the classic parser does not understand double quotes diff --git a/silence/silence.go b/silence/silence.go index ecd3f840..828c282c 100644 --- a/silence/silence.go +++ b/silence/silence.go @@ -37,7 +37,7 @@ import ( "github.com/prometheus/common/model" "github.com/prometheus/alertmanager/cluster" - "github.com/prometheus/alertmanager/matchers/compat" + "github.com/prometheus/alertmanager/matcher/compat" "github.com/prometheus/alertmanager/pkg/labels" pb "github.com/prometheus/alertmanager/silence/silencepb" "github.com/prometheus/alertmanager/types" diff --git a/silence/silence_test.go b/silence/silence_test.go index ca425afe..98e70cda 100644 --- a/silence/silence_test.go +++ b/silence/silence_test.go @@ -33,7 +33,7 @@ import ( "go.uber.org/atomic" "github.com/prometheus/alertmanager/featurecontrol" - "github.com/prometheus/alertmanager/matchers/compat" + "github.com/prometheus/alertmanager/matcher/compat" pb "github.com/prometheus/alertmanager/silence/silencepb" "github.com/prometheus/alertmanager/types" ) diff --git a/types/types.go b/types/types.go index 85391ce9..727ac320 100644 --- a/types/types.go +++ b/types/types.go @@ -22,7 +22,7 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/model" - "github.com/prometheus/alertmanager/matchers/compat" + "github.com/prometheus/alertmanager/matcher/compat" "github.com/prometheus/alertmanager/pkg/labels" ) diff --git a/types/types_test.go b/types/types_test.go index 19880486..c5ca4b58 100644 --- a/types/types_test.go +++ b/types/types_test.go @@ -26,7 +26,7 @@ import ( "github.com/stretchr/testify/require" "github.com/prometheus/alertmanager/featurecontrol" - "github.com/prometheus/alertmanager/matchers/compat" + "github.com/prometheus/alertmanager/matcher/compat" ) func TestMemMarker_Muted(t *testing.T) {