build(deps): upgraded linter to v1.55.2, fixed warnings (#3611)

* build(deps): upgraded linter to v1.55.2, fixed warnings

* removed unsafe hacks with better equivalents

* test fixes
This commit is contained in:
Jarek Kowalski authored and GitHub committed 2024-02-02 23:34:34 -08:00
1 parent c478141bbf
commit a8e4d50600
69 files changed
+235 -232

No files matched your search

+4
View File
@@ -19,6 +19,10 @@ func requestError(apiErrorCode serverapi.APIErrorCode, message string) *apiError
return &apiError{http.StatusBadRequest, apiErrorCode, message}
}
func unableToDecodeRequest(err error) *apiError {
return requestError(serverapi.ErrorMalformedRequest, "unable to decode request: "+err.Error())
}
func notFoundError(message string) *apiError {
return &apiError{http.StatusNotFound, serverapi.ErrorNotFound, message}
}
+1 -1
View File
@@ -66,7 +66,7 @@ func handlePolicyResolve(ctx context.Context, rc requestContext) (interface{}, *
var req serverapi.ResolvePolicyRequest
if err := json.Unmarshal(rc.body, &req); err != nil {
return nil, requestError(serverapi.ErrorMalformedRequest, "unable to decode request: "+err.Error())
return nil, unableToDecodeRequest(err)
}
target := getSnapshotSourceFromURL(rc.req.URL)
+5 -5
View File
@@ -128,7 +128,7 @@ func handleRepoCreate(ctx context.Context, rc requestContext) (interface{}, *api
var req serverapi.CreateRepositoryRequest
if err := json.Unmarshal(rc.body, &req); err != nil {
return nil, requestError(serverapi.ErrorMalformedRequest, "unable to decode request: "+err.Error())
return nil, unableToDecodeRequest(err)
}
if err := maybeDecodeToken(&req.ConnectRepositoryRequest); err != nil {
@@ -181,7 +181,7 @@ func handleRepoExists(ctx context.Context, rc requestContext) (interface{}, *api
var req serverapi.CheckRepositoryExistsRequest
if err := json.Unmarshal(rc.body, &req); err != nil {
return nil, requestError(serverapi.ErrorMalformedRequest, "unable to decode request: "+err.Error())
return nil, unableToDecodeRequest(err)
}
st, err := blob.NewStorage(ctx, req.Storage, false)
@@ -213,7 +213,7 @@ func handleRepoConnect(ctx context.Context, rc requestContext) (interface{}, *ap
var req serverapi.ConnectRepositoryRequest
if err := json.Unmarshal(rc.body, &req); err != nil {
return nil, requestError(serverapi.ErrorMalformedRequest, "unable to decode request: "+err.Error())
return nil, unableToDecodeRequest(err)
}
if err := maybeDecodeToken(&req); err != nil {
@@ -254,7 +254,7 @@ func handleRepoSetDescription(ctx context.Context, rc requestContext) (interface
var req repo.ClientOptions
if err := json.Unmarshal(rc.body, &req); err != nil {
return nil, requestError(serverapi.ErrorMalformedRequest, "unable to decode request: "+err.Error())
return nil, unableToDecodeRequest(err)
}
cliOpt := rc.rep.ClientOptions()
@@ -345,7 +345,7 @@ func handleRepoSetThrottle(ctx context.Context, rc requestContext) (interface{},
var req throttling.Limits
if err := json.Unmarshal(rc.body, &req); err != nil {
return nil, requestError(serverapi.ErrorMalformedRequest, "unable to decode request: "+err.Error())
return nil, unableToDecodeRequest(err)
}
if err := dr.Throttler().SetLimits(req); err != nil {
+8 -8
View File
@@ -134,7 +134,7 @@ func (s *Server) Session(srv grpcapi.KopiaRepository_SessionServer) error {
defer s.grpcServerState.sem.Release(1)
handleSessionRequest(ctx, dw, authz, usernameAtHostname, req, func(resp *grpcapi.SessionResponse) {
if err := s.send(srv, req.RequestId, resp); err != nil {
if err := s.send(srv, req.GetRequestId(), resp); err != nil {
select {
case lastErr <- err:
default:
@@ -151,9 +151,9 @@ func (s *Server) Session(srv grpcapi.KopiaRepository_SessionServer) error {
var tracer = otel.Tracer("kopia/grpc")
func handleSessionRequest(ctx context.Context, dw repo.DirectRepositoryWriter, authz auth.AuthorizationInfo, usernameAtHostname string, req *grpcapi.SessionRequest, respond func(*grpcapi.SessionResponse)) {
if req.TraceContext != nil {
if req.GetTraceContext() != nil {
var tc propagation.TraceContext
ctx = tc.Extract(ctx, propagation.MapCarrier(req.TraceContext))
ctx = tc.Extract(ctx, propagation.MapCarrier(req.GetTraceContext()))
}
switch inner := req.GetRequest().(type) {
@@ -429,12 +429,12 @@ func handlePrefetchContentsRequest(ctx context.Context, rep repo.Repository, aut
return accessDeniedResponse()
}
contentIDs, err := content.IDsFromStrings(req.ContentIds)
contentIDs, err := content.IDsFromStrings(req.GetContentIds())
if err != nil {
return errorResponse(err)
}
cids := rep.PrefetchContents(ctx, contentIDs, req.Hint)
cids := rep.PrefetchContents(ctx, contentIDs, req.GetHint())
return &grpcapi.SessionResponse{
Response: &grpcapi.SessionResponse_PrefetchContents{
@@ -463,7 +463,7 @@ func handleApplyRetentionPolicyRequest(ctx context.Context, rep repo.RepositoryW
manifest.TypeLabelKey: snapshot.ManifestType,
snapshot.UsernameLabel: username,
snapshot.HostnameLabel: hostname,
snapshot.PathLabel: req.SourcePath,
snapshot.PathLabel: req.GetSourcePath(),
}) < auth.AccessLevelAppend {
return accessDeniedResponse()
}
@@ -471,8 +471,8 @@ func handleApplyRetentionPolicyRequest(ctx context.Context, rep repo.RepositoryW
manifestIDs, err := policy.ApplyRetentionPolicy(ctx, rep, snapshot.SourceInfo{
Host: hostname,
UserName: username,
Path: req.SourcePath,
}, req.ReallyDelete)
Path: req.GetSourcePath(),
}, req.GetReallyDelete())
if err != nil {
return errorResponse(err)
}