Chore: Replace go-multierror with errors package (#66432)

* code refactor and type assertions added to tests

* no-lint rule added for specific line
This commit is contained in:
SatVeer Singh
2023-06-19 12:29:45 +03:00
committed by GitHub
parent a75752b085
commit 1bfa3a0f1e
8 changed files with 25 additions and 30 deletions
+2 -3
View File
@@ -6,7 +6,6 @@ import (
"net/http"
"strconv"
"github.com/hashicorp/go-multierror"
"github.com/prometheus/client_golang/prometheus"
"go.opentelemetry.io/otel/attribute"
@@ -143,7 +142,7 @@ func ProvideService(
connector, errConnector := socialService.GetConnector(name)
httpClient, errHTTPClient := socialService.GetOAuthHttpClient(name)
if errConnector != nil || errHTTPClient != nil {
s.log.Error("Failed to configure oauth client", "client", clientName, "err", multierror.Append(errConnector, errHTTPClient))
s.log.Error("Failed to configure oauth client", "client", clientName, "err", errors.Join(errConnector, errHTTPClient))
} else {
s.RegisterClient(clients.ProvideOAuth(clientName, cfg, oauthCfg, connector, httpClient))
}
@@ -201,7 +200,7 @@ func (s *Service) Authenticate(ctx context.Context, r *authn.Request) (*authn.Id
return nil, err
}
authErr = multierror.Append(authErr, err)
authErr = errors.Join(authErr, err)
// try next
continue
}
+1 -3
View File
@@ -4,8 +4,6 @@ import (
"context"
"errors"
"github.com/hashicorp/go-multierror"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/services/authn"
"github.com/grafana/grafana/pkg/services/loginattempt"
@@ -50,7 +48,7 @@ func (c *Password) AuthenticatePassword(ctx context.Context, r *authn.Request, u
var clientErrs error
for _, pwClient := range c.clients {
identity, clientErr := pwClient.AuthenticatePassword(ctx, r, username, password)
clientErrs = multierror.Append(clientErrs, clientErr)
clientErrs = errors.Join(clientErrs, clientErr)
// we always try next client on any error
if clientErr != nil {
c.log.FromContext(ctx).Debug("Failed to authenticate password identity", "client", pwClient, "error", clientErr)