From 80fbe1de9607f233f2ce8f5daa4ca1a3b82516cf Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Thu, 16 Jun 2022 10:38:27 +0200 Subject: [PATCH] refactor (package model): move from github.com/pkg/errors to 'errors' and 'fmt' packages (#10748) Signed-off-by: Matthieu MOREL --- notifier/notifier.go | 5 ++--- notifier/notifier_test.go | 9 ++++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/notifier/notifier.go b/notifier/notifier.go index 88cbbe0ae..78da1129a 100644 --- a/notifier/notifier.go +++ b/notifier/notifier.go @@ -30,7 +30,6 @@ import ( "github.com/go-kit/log" "github.com/go-kit/log/level" "github.com/go-openapi/strfmt" - "github.com/pkg/errors" "github.com/prometheus/alertmanager/api/v2/models" "github.com/prometheus/client_golang/prometheus" config_util "github.com/prometheus/common/config" @@ -588,7 +587,7 @@ func (n *Manager) sendOne(ctx context.Context, c *http.Client, url string, b []b // Any HTTP status 2xx is OK. if resp.StatusCode/100 != 2 { - return errors.Errorf("bad response status %s", resp.Status) + return fmt.Errorf("bad response status %s", resp.Status) } return nil @@ -742,7 +741,7 @@ func AlertmanagerFromGroup(tg *targetgroup.Group, cfg *config.AlertmanagerConfig case "https": addr = addr + ":443" default: - return nil, nil, errors.Errorf("invalid scheme: %q", cfg.Scheme) + return nil, nil, fmt.Errorf("invalid scheme: %q", cfg.Scheme) } lb.Set(model.AddressLabel, addr) } diff --git a/notifier/notifier_test.go b/notifier/notifier_test.go index e28a2609c..752429537 100644 --- a/notifier/notifier_test.go +++ b/notifier/notifier_test.go @@ -25,7 +25,6 @@ import ( "testing" "time" - "github.com/pkg/errors" "github.com/prometheus/alertmanager/api/v2/models" config_util "github.com/prometheus/common/config" "github.com/prometheus/common/model" @@ -88,11 +87,11 @@ func TestHandlerNextBatch(t *testing.T) { func alertsEqual(a, b []*Alert) error { if len(a) != len(b) { - return errors.Errorf("length mismatch: %v != %v", a, b) + return fmt.Errorf("length mismatch: %v != %v", a, b) } for i, alert := range a { if !labels.Equal(alert.Labels, b[i].Labels) { - return errors.Errorf("label mismatch at index %d: %s != %s", i, alert.Labels, b[i].Labels) + return fmt.Errorf("label mismatch at index %d: %s != %s", i, alert.Labels, b[i].Labels) } } return nil @@ -121,14 +120,14 @@ func TestHandlerSendAll(t *testing.T) { }() user, pass, _ := r.BasicAuth() if user != u || pass != p { - err = errors.Errorf("unexpected user/password: %s/%s != %s/%s", user, pass, u, p) + err = fmt.Errorf("unexpected user/password: %s/%s != %s/%s", user, pass, u, p) w.WriteHeader(http.StatusInternalServerError) return } b, err := io.ReadAll(r.Body) if err != nil { - err = errors.Errorf("error reading body: %v", err) + err = fmt.Errorf("error reading body: %w", err) w.WriteHeader(http.StatusInternalServerError) return }