Skip to content

Commit

Permalink
Rename matchers package to matcher singular (#3777)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
grobinson-grafana authored Jun 21, 2024
1 parent 04174d7 commit 52eb1fc
Show file tree
Hide file tree
Showing 24 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion api/v2/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion cli/alert_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
2 changes: 1 addition & 1 deletion cli/alert_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion cli/silence_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
2 changes: 1 addition & 1 deletion cli/silence_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion cli/test_routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/alertmanager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
16 changes: 8 additions & 8 deletions matchers/compat/parse.go → matcher/compat/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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) {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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)
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion pkg/labels/matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion silence/silence.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion silence/silence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
2 changes: 1 addition & 1 deletion types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
2 changes: 1 addition & 1 deletion types/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 52eb1fc

Please sign in to comment.