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 <george.robinson@grafana.com>
This commit is contained in:
George Robinson 2024-06-21 15:17:27 +01:00 committed by GitHub
parent 04174d7d7b
commit 52eb1fc4aa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
24 changed files with 23 additions and 23 deletions

View File

@ -45,7 +45,7 @@ import (
"github.com/prometheus/alertmanager/cluster" "github.com/prometheus/alertmanager/cluster"
"github.com/prometheus/alertmanager/config" "github.com/prometheus/alertmanager/config"
"github.com/prometheus/alertmanager/dispatch" "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/pkg/labels"
"github.com/prometheus/alertmanager/provider" "github.com/prometheus/alertmanager/provider"
"github.com/prometheus/alertmanager/silence" "github.com/prometheus/alertmanager/silence"

View File

@ -25,7 +25,7 @@ import (
"github.com/prometheus/alertmanager/api/v2/client/alert" "github.com/prometheus/alertmanager/api/v2/client/alert"
"github.com/prometheus/alertmanager/api/v2/models" "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" "github.com/prometheus/alertmanager/pkg/labels"
) )

View File

@ -23,7 +23,7 @@ import (
"github.com/prometheus/alertmanager/api/v2/client/alert" "github.com/prometheus/alertmanager/api/v2/client/alert"
"github.com/prometheus/alertmanager/cli/format" "github.com/prometheus/alertmanager/cli/format"
"github.com/prometheus/alertmanager/matchers/compat" "github.com/prometheus/alertmanager/matcher/compat"
) )
type alertQueryCmd struct { type alertQueryCmd struct {

View File

@ -34,7 +34,7 @@ import (
"github.com/prometheus/alertmanager/cli/config" "github.com/prometheus/alertmanager/cli/config"
"github.com/prometheus/alertmanager/cli/format" "github.com/prometheus/alertmanager/cli/format"
"github.com/prometheus/alertmanager/featurecontrol" "github.com/prometheus/alertmanager/featurecontrol"
"github.com/prometheus/alertmanager/matchers/compat" "github.com/prometheus/alertmanager/matcher/compat"
) )
var ( var (

View File

@ -27,7 +27,7 @@ import (
"github.com/prometheus/alertmanager/api/v2/client/silence" "github.com/prometheus/alertmanager/api/v2/client/silence"
"github.com/prometheus/alertmanager/api/v2/models" "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" "github.com/prometheus/alertmanager/pkg/labels"
) )

View File

@ -25,7 +25,7 @@ import (
"github.com/prometheus/alertmanager/api/v2/client/silence" "github.com/prometheus/alertmanager/api/v2/client/silence"
"github.com/prometheus/alertmanager/api/v2/models" "github.com/prometheus/alertmanager/api/v2/models"
"github.com/prometheus/alertmanager/cli/format" "github.com/prometheus/alertmanager/cli/format"
"github.com/prometheus/alertmanager/matchers/compat" "github.com/prometheus/alertmanager/matcher/compat"
) )
type silenceQueryCmd struct { type silenceQueryCmd struct {

View File

@ -24,7 +24,7 @@ import (
"github.com/prometheus/alertmanager/api/v2/models" "github.com/prometheus/alertmanager/api/v2/models"
"github.com/prometheus/alertmanager/dispatch" "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/pkg/labels"
) )

View File

@ -50,7 +50,7 @@ import (
"github.com/prometheus/alertmanager/dispatch" "github.com/prometheus/alertmanager/dispatch"
"github.com/prometheus/alertmanager/featurecontrol" "github.com/prometheus/alertmanager/featurecontrol"
"github.com/prometheus/alertmanager/inhibit" "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/nflog"
"github.com/prometheus/alertmanager/notify" "github.com/prometheus/alertmanager/notify"
"github.com/prometheus/alertmanager/provider/mem" "github.com/prometheus/alertmanager/provider/mem"

View File

@ -30,7 +30,7 @@ import (
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
"gopkg.in/yaml.v2" "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/pkg/labels"
"github.com/prometheus/alertmanager/timeinterval" "github.com/prometheus/alertmanager/timeinterval"
) )

View File

@ -24,7 +24,7 @@ import (
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
"github.com/prometheus/alertmanager/featurecontrol" "github.com/prometheus/alertmanager/featurecontrol"
"github.com/prometheus/alertmanager/matchers/parse" "github.com/prometheus/alertmanager/matcher/parse"
"github.com/prometheus/alertmanager/pkg/labels" "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. // in the input string. If this fails it does not revert to the pkg/labels parser.
func UTF8MatcherParser(l log.Logger) ParseMatcher { func UTF8MatcherParser(l log.Logger) ParseMatcher {
return func(input, origin string) (matcher *labels.Matcher, err error) { 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 // matchers in the input string. If this fails it does not revert to the
// pkg/labels parser. // pkg/labels parser.
func UTF8MatchersParser(l log.Logger) ParseMatchers { 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 // matchers in the string. If this fails it reverts to the pkg/labels parser and
// emits a warning log line. // emits a warning log line.
func FallbackMatcherParser(l log.Logger) ParseMatcher { func FallbackMatcherParser(l log.Logger) ParseMatcher {
@ -130,7 +130,7 @@ func FallbackMatcherParser(l log.Logger) ParseMatcher {
if cErr != nil { if cErr != nil {
return nil, cErr 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. // parser. This means the input is not forwards compatible.
suggestion := cMatcher.String() 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) 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 // matcher in the input string. If this fails it falls back to the pkg/labels
// parser and emits a warning log line. // parser and emits a warning log line.
func FallbackMatchersParser(l log.Logger) ParseMatchers { func FallbackMatchersParser(l log.Logger) ParseMatchers {
@ -161,7 +161,7 @@ func FallbackMatchersParser(l log.Logger) ParseMatchers {
if cErr != nil { if cErr != nil {
return nil, cErr 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. // parser. This means the input is not forwards compatible.
var sb strings.Builder var sb strings.Builder
for i, n := range cMatchers { for i, n := range cMatchers {
@ -172,7 +172,7 @@ func FallbackMatchersParser(l log.Logger) ParseMatchers {
} }
suggestion := sb.String() suggestion := sb.String()
// The input is valid in the pkg/labels parser, but not the // 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) 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 return cMatchers, nil
} }

View File

@ -17,7 +17,7 @@ import (
"reflect" "reflect"
"testing" "testing"
"github.com/prometheus/alertmanager/matchers/parse" "github.com/prometheus/alertmanager/matcher/parse"
"github.com/prometheus/alertmanager/pkg/labels" "github.com/prometheus/alertmanager/pkg/labels"
) )

View File

@ -205,7 +205,7 @@ func (ms Matchers) String() string {
return buf.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, // 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 // 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 // matchers. Until then, the classic parser does not understand double quotes

View File

@ -37,7 +37,7 @@ import (
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
"github.com/prometheus/alertmanager/cluster" "github.com/prometheus/alertmanager/cluster"
"github.com/prometheus/alertmanager/matchers/compat" "github.com/prometheus/alertmanager/matcher/compat"
"github.com/prometheus/alertmanager/pkg/labels" "github.com/prometheus/alertmanager/pkg/labels"
pb "github.com/prometheus/alertmanager/silence/silencepb" pb "github.com/prometheus/alertmanager/silence/silencepb"
"github.com/prometheus/alertmanager/types" "github.com/prometheus/alertmanager/types"

View File

@ -33,7 +33,7 @@ import (
"go.uber.org/atomic" "go.uber.org/atomic"
"github.com/prometheus/alertmanager/featurecontrol" "github.com/prometheus/alertmanager/featurecontrol"
"github.com/prometheus/alertmanager/matchers/compat" "github.com/prometheus/alertmanager/matcher/compat"
pb "github.com/prometheus/alertmanager/silence/silencepb" pb "github.com/prometheus/alertmanager/silence/silencepb"
"github.com/prometheus/alertmanager/types" "github.com/prometheus/alertmanager/types"
) )

View File

@ -22,7 +22,7 @@ import (
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
"github.com/prometheus/alertmanager/matchers/compat" "github.com/prometheus/alertmanager/matcher/compat"
"github.com/prometheus/alertmanager/pkg/labels" "github.com/prometheus/alertmanager/pkg/labels"
) )

View File

@ -26,7 +26,7 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/prometheus/alertmanager/featurecontrol" "github.com/prometheus/alertmanager/featurecontrol"
"github.com/prometheus/alertmanager/matchers/compat" "github.com/prometheus/alertmanager/matcher/compat"
) )
func TestMemMarker_Muted(t *testing.T) { func TestMemMarker_Muted(t *testing.T) {