From 5a86e80a28142b253ad04ee5b4dd2d2f3e1f4a59 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Fri, 30 Aug 2024 07:14:07 +0200 Subject: [PATCH] fix: golangci-lint (#993) * fix: golangci-lint - exclude G115 Signed-off-by: Matthieu MOREL --- .golangci.yml | 3 +++ pkg/server/delta/v3/server.go | 2 +- pkg/server/sotw/v3/ads.go | 2 +- pkg/server/v3/gateway.go | 6 +++--- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index c0038fda51..d4d93debb1 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -31,6 +31,9 @@ linters-settings: extra-rules: true goimports: local-prefixes: github.com/envoyproxy/go-control-plane + gosec: + excludes: + - G115 misspell: locale: US testifylint: diff --git a/pkg/server/delta/v3/server.go b/pkg/server/delta/v3/server.go index 1ef55e9dd2..347735a83c 100644 --- a/pkg/server/delta/v3/server.go +++ b/pkg/server/delta/v3/server.go @@ -107,7 +107,7 @@ func (s *server) processDelta(str stream.DeltaStream, reqCh <-chan *discovery.De process := func(resp cache.DeltaResponse) error { typ := resp.GetDeltaRequest().GetTypeUrl() if resp == deltaErrorResponse { - return status.Errorf(codes.Unavailable, typ+" watch failed") + return status.Errorf(codes.Unavailable, "%s watch failed", typ) } nonce, err := send(resp) diff --git a/pkg/server/sotw/v3/ads.go b/pkg/server/sotw/v3/ads.go index bbb6dd4b20..1579e12352 100644 --- a/pkg/server/sotw/v3/ads.go +++ b/pkg/server/sotw/v3/ads.go @@ -65,7 +65,7 @@ func (s *server) processADS(sw *streamWrapper, reqCh chan *discovery.DiscoveryRe // We only watch the multiplexed channel since all values will come through from process. case res := <-sw.watches.responders[resource.AnyType].response: if err := process(res); err != nil { - return status.Errorf(codes.Unavailable, err.Error()) + return status.Errorf(codes.Unavailable, "%v", err) } case req, ok := <-reqCh: // Input stream ended or failed. diff --git a/pkg/server/v3/gateway.go b/pkg/server/v3/gateway.go index aaf5cbb567..66197bb90d 100644 --- a/pkg/server/v3/gateway.go +++ b/pkg/server/v3/gateway.go @@ -73,7 +73,7 @@ func (h *HTTPGateway) ServeHTTP(req *http.Request) ([]byte, int, error) { out := &discovery.DiscoveryRequest{} err = protojson.Unmarshal(body, out) if err != nil { - return nil, http.StatusBadRequest, fmt.Errorf("cannot parse JSON body: " + err.Error()) + return nil, http.StatusBadRequest, fmt.Errorf("cannot parse JSON body: %w", err) } out.TypeUrl = typeURL @@ -86,12 +86,12 @@ func (h *HTTPGateway) ServeHTTP(req *http.Request) ([]byte, int, error) { if ok := errors.As(err, &skip); ok { return nil, http.StatusNotModified, nil } - return nil, http.StatusInternalServerError, fmt.Errorf("fetch error: " + err.Error()) + return nil, http.StatusInternalServerError, fmt.Errorf("fetch error: %w", err) } b, err := protojson.MarshalOptions{UseProtoNames: true}.Marshal(res) if err != nil { - return nil, http.StatusInternalServerError, fmt.Errorf("marshal error: " + err.Error()) + return nil, http.StatusInternalServerError, fmt.Errorf("marshal error: %w", err) } return b, http.StatusOK, nil