mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-12 14:27:27 -08:00
refactor (package model): move from github.com/pkg/errors to 'errors' and 'fmt' packages (#10748)
Signed-off-by: Matthieu MOREL <mmorel-35@users.noreply.github.com>
This commit is contained in:
parent
454714105d
commit
80fbe1de96
|
@ -30,7 +30,6 @@ import (
|
||||||
"github.com/go-kit/log"
|
"github.com/go-kit/log"
|
||||||
"github.com/go-kit/log/level"
|
"github.com/go-kit/log/level"
|
||||||
"github.com/go-openapi/strfmt"
|
"github.com/go-openapi/strfmt"
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/prometheus/alertmanager/api/v2/models"
|
"github.com/prometheus/alertmanager/api/v2/models"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
config_util "github.com/prometheus/common/config"
|
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.
|
// Any HTTP status 2xx is OK.
|
||||||
if resp.StatusCode/100 != 2 {
|
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
|
return nil
|
||||||
|
@ -742,7 +741,7 @@ func AlertmanagerFromGroup(tg *targetgroup.Group, cfg *config.AlertmanagerConfig
|
||||||
case "https":
|
case "https":
|
||||||
addr = addr + ":443"
|
addr = addr + ":443"
|
||||||
default:
|
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)
|
lb.Set(model.AddressLabel, addr)
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/prometheus/alertmanager/api/v2/models"
|
"github.com/prometheus/alertmanager/api/v2/models"
|
||||||
config_util "github.com/prometheus/common/config"
|
config_util "github.com/prometheus/common/config"
|
||||||
"github.com/prometheus/common/model"
|
"github.com/prometheus/common/model"
|
||||||
|
@ -88,11 +87,11 @@ func TestHandlerNextBatch(t *testing.T) {
|
||||||
|
|
||||||
func alertsEqual(a, b []*Alert) error {
|
func alertsEqual(a, b []*Alert) error {
|
||||||
if len(a) != len(b) {
|
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 {
|
for i, alert := range a {
|
||||||
if !labels.Equal(alert.Labels, b[i].Labels) {
|
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
|
return nil
|
||||||
|
@ -121,14 +120,14 @@ func TestHandlerSendAll(t *testing.T) {
|
||||||
}()
|
}()
|
||||||
user, pass, _ := r.BasicAuth()
|
user, pass, _ := r.BasicAuth()
|
||||||
if user != u || pass != p {
|
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)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
b, err := io.ReadAll(r.Body)
|
b, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = errors.Errorf("error reading body: %v", err)
|
err = fmt.Errorf("error reading body: %w", err)
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue