0
Fork 0
mirror of https://github.com/project-zot/zot.git synced 2024-12-30 22:34:13 -05:00

ci: update golangci-lint version (#1834)

Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com>
This commit is contained in:
Ramkumar Chinchani 2023-10-20 07:27:04 -07:00 committed by GitHub
parent 7ce5a74598
commit 1675f30d4a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 33 additions and 32 deletions

View file

@ -24,7 +24,7 @@ jobs:
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.52.2
version: v1.54.2
# Optional: working directory, useful for monorepos
# working-directory: somedir

View file

@ -10,7 +10,7 @@ TOOLSDIR := $(shell pwd)/hack/tools
PATH := bin:$(TOOLSDIR)/bin:$(PATH)
STACKER := $(shell which stacker)
GOLINTER := $(TOOLSDIR)/bin/golangci-lint
GOLINTER_VERSION := v1.52.2
GOLINTER_VERSION := v1.54.2
NOTATION := $(TOOLSDIR)/bin/notation
NOTATION_VERSION := 1.0.0
COSIGN := $(TOOLSDIR)/bin/cosign

View file

@ -5,7 +5,7 @@ run:
linters:
enable-all: true
disable: funlen,gocognit,exhaustivestruct,paralleltest,forbidigo,ireturn,wrapcheck,exhaustive,maintidx,exhaustruct,nosnakecase,interfacer,structcheck,varcheck,deadcode,ifshort,golint,scopelint,maligned,rowserrcheck,sqlclosecheck,revive,musttag
disable: funlen,gocognit,exhaustivestruct,paralleltest,forbidigo,ireturn,wrapcheck,exhaustive,maintidx,exhaustruct,nosnakecase,interfacer,structcheck,varcheck,deadcode,ifshort,golint,scopelint,maligned,rowserrcheck,sqlclosecheck,revive,musttag,depguard
linters-settings:
dupl:

View file

@ -71,7 +71,7 @@ func NewController(config *config.Config) *Controller {
func DumpRuntimeParams(log log.Logger) {
var rLimit syscall.Rlimit
evt := log.Info().Int("cpus", runtime.NumCPU())
evt := log.Info().Int("cpus", runtime.NumCPU()) //nolint: zerologlint
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit)
if err == nil {

View file

@ -2111,6 +2111,7 @@ func (rh *RouteHandler) CreateAPIKey(resp http.ResponseWriter, req *http.Request
expirationDate := time.Time{}
if payload.ExpirationDate != "" {
//nolint: gosmopolitan
expirationDate, err = time.ParseInLocation(constants.APIKeyTimeFormat, payload.ExpirationDate, time.Local)
if err != nil {
resp.WriteHeader(http.StatusBadRequest)

View file

@ -546,7 +546,7 @@ func TestRoutes(t *testing.T) {
},
&mocks.MockedImageStore{
GetBlobFn: func(repo string, digest godigest.Digest, mediaType string) (io.ReadCloser, int64, error) {
return io.NopCloser(bytes.NewBuffer([]byte(""))), 0, zerr.ErrRepoNotFound
return io.NopCloser(bytes.NewBufferString("")), 0, zerr.ErrRepoNotFound
},
})
So(statusCode, ShouldEqual, http.StatusNotFound)
@ -559,7 +559,7 @@ func TestRoutes(t *testing.T) {
},
&mocks.MockedImageStore{
GetBlobFn: func(repo string, digest godigest.Digest, mediaType string) (io.ReadCloser, int64, error) {
return io.NopCloser(bytes.NewBuffer([]byte(""))), 0, zerr.ErrBadBlobDigest
return io.NopCloser(bytes.NewBufferString("")), 0, zerr.ErrBadBlobDigest
},
})
So(statusCode, ShouldEqual, http.StatusBadRequest)

View file

@ -654,7 +654,7 @@ func getMockImageSummary() common.ImageSummary {
func TestUtils(t *testing.T) {
Convey("Utils", t, func() {
ok := haveSameArgs(field{"query", []struct {
Name string "json:\"name\""
Name string `json:"name"`
}{
{Name: "arg1"}, {Name: "arg2"},
}}, GQLQuery{
@ -663,7 +663,7 @@ func TestUtils(t *testing.T) {
So(ok, ShouldBeFalse)
ok = haveSameArgs(field{"query", []struct {
Name string "json:\"name\""
Name string `json:"name"`
}{
{Name: "arg1"}, {Name: "arg2"},
}}, GQLQuery{

View file

@ -88,7 +88,7 @@ func TestConfigReloader(t *testing.T) {
defer os.Remove(cfgfile.Name()) // clean up
_, err = cfgfile.Write([]byte(content))
_, err = cfgfile.WriteString(content)
So(err, ShouldBeNil)
// err = cfgfile.Close()
@ -216,7 +216,7 @@ func TestConfigReloader(t *testing.T) {
defer os.Remove(cfgfile.Name()) // clean up
_, err = cfgfile.Write([]byte(content))
_, err = cfgfile.WriteString(content)
So(err, ShouldBeNil)
// err = cfgfile.Close()
@ -341,7 +341,7 @@ func TestConfigReloader(t *testing.T) {
defer os.Remove(cfgfile.Name()) // clean up
_, err = cfgfile.Write([]byte(content))
_, err = cfgfile.WriteString(content)
So(err, ShouldBeNil)
os.Args = []string{"cli_test", "serve", cfgfile.Name()}
@ -463,7 +463,7 @@ func TestConfigReloader(t *testing.T) {
defer os.Remove(cfgfile.Name()) // clean up
_, err = cfgfile.Write([]byte(content))
_, err = cfgfile.WriteString(content)
So(err, ShouldBeNil)
// err = cfgfile.Close()

View file

@ -392,7 +392,7 @@ func TestServeExtensions(t *testing.T) {
cfgfile, err := os.CreateTemp("", "zot-test*.json")
So(err, ShouldBeNil)
defer os.Remove(cfgfile.Name()) // clean up
_, err = cfgfile.Write([]byte(content))
_, err = cfgfile.WriteString(content)
So(err, ShouldBeNil)
err = cfgfile.Close()
So(err, ShouldBeNil)
@ -435,7 +435,7 @@ func TestServeExtensions(t *testing.T) {
cfgfile, err := os.CreateTemp("", "zot-test*.json")
So(err, ShouldBeNil)
defer os.Remove(cfgfile.Name()) // clean up
_, err = cfgfile.Write([]byte(content))
_, err = cfgfile.WriteString(content)
So(err, ShouldBeNil)
err = cfgfile.Close()
So(err, ShouldBeNil)
@ -467,7 +467,7 @@ func testWithMetricsEnabled(cfgContentFormat string) {
So(err, ShouldBeNil)
defer os.Remove(cfgfile.Name()) // clean up
_, err = cfgfile.Write([]byte(content))
_, err = cfgfile.WriteString(content)
So(err, ShouldBeNil)
err = cfgfile.Close()
So(err, ShouldBeNil)
@ -595,7 +595,7 @@ func TestServeMetricsExtension(t *testing.T) {
cfgfile, err := os.CreateTemp("", "zot-test*.json")
So(err, ShouldBeNil)
defer os.Remove(cfgfile.Name()) // clean up
_, err = cfgfile.Write([]byte(content))
_, err = cfgfile.WriteString(content)
So(err, ShouldBeNil)
err = cfgfile.Close()
So(err, ShouldBeNil)

View file

@ -1376,7 +1376,7 @@ func runCLIWithConfig(tempDir string, config string) (string, error) {
config = fmt.Sprintf(config, tempDir, port, logFile.Name())
_, err = cfgfile.Write([]byte(config))
_, err = cfgfile.WriteString(config)
if err != nil {
return "", err
}

View file

@ -95,7 +95,7 @@ func TestSressTooManyOpenFiles(t *testing.T) {
cfgfile, err := os.CreateTemp("", "zot-test*.json")
So(err, ShouldBeNil)
defer os.Remove(cfgfile.Name()) // clean up
_, err = cfgfile.Write([]byte(content))
_, err = cfgfile.WriteString(content)
So(err, ShouldBeNil)
err = cfgfile.Close()
So(err, ShouldBeNil)

View file

@ -27,7 +27,7 @@ func SetupGQLPlaygroundRoutes(router *mux.Router,
templ, err := template.ParseFS(playgroundHTML, "index.html.tmpl")
if err != nil {
log.Fatal().Err(err)
log.Fatal().Err(err).Msg("")
}
//nolint:lll

View file

@ -1898,7 +1898,7 @@ func TestConfigReloader(t *testing.T) {
defer os.Remove(cfgfile.Name()) // clean up
_, err = cfgfile.Write([]byte(content))
_, err = cfgfile.WriteString(content)
So(err, ShouldBeNil)
hotReloader, err := cli.NewHotReloader(dctlr, cfgfile.Name())
@ -2046,7 +2046,7 @@ func TestConfigReloader(t *testing.T) {
defer os.Remove(cfgfile.Name()) // clean up
_, err = cfgfile.Write([]byte(content))
_, err = cfgfile.WriteString(content)
So(err, ShouldBeNil)
hotReloader, err := cli.NewHotReloader(dctlr, cfgfile.Name())

View file

@ -177,7 +177,7 @@ func (d *BoltDBDriver) GetBlob(digest godigest.Digest) (string, error) {
bucket := root.Bucket([]byte(digest.String()))
if bucket != nil {
origin := bucket.Bucket([]byte(constants.OriginalBucket))
blobPath.WriteString(string(d.getOne(origin)))
blobPath.Write(d.getOne(origin))
return nil
}

View file

@ -293,7 +293,7 @@ func (driver *Driver) Link(src, dest string) error {
/* also update the modtime, so that gc won't remove recently linked blobs
otherwise ifBlobOlderThan(gcDelay) will return the modtime of the inode */
currentTime := time.Now().Local()
currentTime := time.Now().Local() //nolint: gosmopolitan
if err := os.Chtimes(dest, currentTime, currentTime); err != nil {
return driver.formatErr(err)
}

View file

@ -303,7 +303,7 @@ func FuzzPutBlobChunk(f *testing.F) {
t.Error(err)
}
buf := bytes.NewBuffer([]byte(data))
buf := bytes.NewBufferString(data)
buflen := buf.Len()
_, err = imgStore.PutBlobChunk(repoName, uuid, 0, int64(buflen), buf)
if err != nil {
@ -337,7 +337,7 @@ func FuzzPutBlobChunkStreamed(f *testing.F) {
t.Error(err)
}
buf := bytes.NewBuffer([]byte(data))
buf := bytes.NewBufferString(data)
_, err = imgStore.PutBlobChunkStreamed(repoName, uuid, buf)
if err != nil {
t.Error(err)
@ -1073,7 +1073,7 @@ func FuzzGetOrasReferrers(f *testing.F) {
t.Error(err)
}
digest := godigest.FromBytes([]byte(data))
buf := bytes.NewBuffer([]byte(data))
buf := bytes.NewBufferString(data)
buflen := buf.Len()
err = os.WriteFile(path.Join(imgStore.RootDir(), //nolint: gosec
"zot-test", "blobs", digest.Algorithm().String(), digest.Encoded()),

View file

@ -870,7 +870,7 @@ func TestNegativeCasesObjectsStorage(t *testing.T) {
_, _, err = imgStore.PutImageManifest(testImage, "1.0", "application/json", []byte{})
So(err, ShouldNotBeNil)
_, err = imgStore.PutBlobChunkStreamed(testImage, upload, bytes.NewBuffer([]byte(testImage)))
_, err = imgStore.PutBlobChunkStreamed(testImage, upload, bytes.NewBufferString(testImage))
So(err, ShouldNotBeNil)
_, _, err = imgStore.FullBlobUpload(testImage, bytes.NewBuffer([]byte{}), "inexistent")
@ -3848,7 +3848,7 @@ func TestS3DedupeErr(t *testing.T) {
Convey("Test DeleteBlob() - error on store.Move()", t, func(c C) {
tdir := t.TempDir()
hash := "7173b809ca12ec5dee4506cd86be934c4596dd234ee82c0662eac04a8c2c71dc"
hash := "7173b809ca12ec5dee4506cd86be934c4596dd234ee82c0662eac04a8c2c71dc" // #nosec G101
digest := godigest.NewDigestFromEncoded(godigest.SHA256, hash)

View file

@ -148,7 +148,7 @@ func TestReadLogFileAndCountStringOccurence(t *testing.T) {
panic(err)
}
_, err = logFile.Write([]byte("line1\n line2\n line3 line1 line2\n line1"))
_, err = logFile.WriteString("line1\n line2\n line3 line1 line2\n line1")
if err != nil {
panic(err)
}