use format string when using printf like commands

As per https://github.com/golang/go/issues/60529, printf like commands with
non-constant format strings and no args give an error in govet

Signed-off-by: Akhil Mohan <akhilerm@gmail.com>
This commit is contained in:
Akhil Mohan 2024-08-14 16:01:12 +05:30
parent 1027b314a6
commit ebc47359ea
No known key found for this signature in database
GPG Key ID: BA8C85CD8F373329
4 changed files with 9 additions and 8 deletions

View File

@ -22,6 +22,7 @@ import (
"compress/gzip"
"context"
"encoding/json"
"errors"
"fmt"
"io"
"math/rand"
@ -290,14 +291,14 @@ func TestDockerFetcherOpen(t *testing.T) {
{
name: "should return just status if the registry request fails and does not return a docker error",
mockedStatus: 500,
mockedErr: fmt.Errorf("Non-docker error"),
mockedErr: errors.New("Non-docker error"),
want: nil,
wantErr: true,
wantPlainError: true,
}, {
name: "should return StatusRequestTimeout after 5 retries",
mockedStatus: http.StatusRequestTimeout,
mockedErr: fmt.Errorf(http.StatusText(http.StatusRequestTimeout)),
mockedErr: errors.New(http.StatusText(http.StatusRequestTimeout)),
want: nil,
wantErr: true,
wantPlainError: true,
@ -305,7 +306,7 @@ func TestDockerFetcherOpen(t *testing.T) {
}, {
name: "should return StatusTooManyRequests after 5 retries",
mockedStatus: http.StatusTooManyRequests,
mockedErr: fmt.Errorf(http.StatusText(http.StatusTooManyRequests)),
mockedErr: errors.New(http.StatusText(http.StatusTooManyRequests)),
want: nil,
wantErr: true,
wantPlainError: true,

View File

@ -76,7 +76,7 @@ func (c *criService) CheckpointContainer(ctx context.Context, r *runtime.Checkpo
podCriuVersion,
r.GetContainerId(),
)
log.G(ctx).WithError(err).Errorf(errorMessage)
log.G(ctx).WithError(err).Error(errorMessage)
return nil, fmt.Errorf(
"%s: %w",
errorMessage,

View File

@ -208,7 +208,7 @@ func (p *parser) field() (string, error) {
case tokenQuoted:
return p.unquote(pos, s, false)
case tokenIllegal:
return "", p.mkerr(pos, p.scanner.err)
return "", p.mkerr(pos, "%s", p.scanner.err)
}
return "", p.mkerr(pos, "expected field or quoted")
@ -229,7 +229,7 @@ func (p *parser) operator() (operator, error) {
return 0, p.mkerr(pos, "unsupported operator %q", s)
}
case tokenIllegal:
return 0, p.mkerr(pos, p.scanner.err)
return 0, p.mkerr(pos, "%s", p.scanner.err)
}
return 0, p.mkerr(pos, `expected an operator ("=="|"!="|"~=")`)
@ -244,7 +244,7 @@ func (p *parser) value(allowAltQuotes bool) (string, error) {
case tokenQuoted:
return p.unquote(pos, s, allowAltQuotes)
case tokenIllegal:
return "", p.mkerr(pos, p.scanner.err)
return "", p.mkerr(pos, "%s", p.scanner.err)
}
return "", p.mkerr(pos, "expected value or quoted")

View File

@ -133,7 +133,7 @@ func (s *service) Delete(ctx context.Context, req *api.DeleteContentRequest) (*p
log.G(ctx).WithField("digest", req.Digest).Debugf("delete content")
dg, err := digest.Parse(req.Digest)
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, err.Error())
return nil, status.Error(codes.InvalidArgument, err.Error())
}
if err := s.store.Delete(ctx, dg); err != nil {