Skip to content

Commit

Permalink
ci: update golangci-lint version (project-zot#1834)
Browse files Browse the repository at this point in the history
Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com>
  • Loading branch information
rchincha authored Oct 20, 2023
1 parent 7ce5a74 commit 1675f30
Show file tree
Hide file tree
Showing 19 changed files with 33 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion golangcilint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions pkg/api/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/routes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions pkg/cli/client/search_functions_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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{
Expand Down
8 changes: 4 additions & 4 deletions pkg/cli/server/config_reloader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()}
Expand Down Expand Up @@ -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()
Expand Down
8 changes: 4 additions & 4 deletions pkg/cli/server/extensions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/server/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/server/stress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pkg/debug/gqlplayground/gqlplayground.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions pkg/extensions/extension_mgmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ type OpenIDConfig struct {

type Auth struct {
HTPasswd *HTPasswd `json:"htpasswd,omitempty" mapstructure:"htpasswd"`
Bearer *BearerConfig `json:"bearer,omitempty" mapstructure:"bearer"`
Bearer *BearerConfig `json:"bearer,omitempty" mapstructure:"bearer"`
LDAP *struct {
Address string `json:"address,omitempty" mapstructure:"address"`
} `json:"ldap,omitempty" mapstructure:"ldap"`
} `json:"ldap,omitempty" mapstructure:"ldap"`
OpenID *OpenIDConfig `json:"openid,omitempty" mapstructure:"openid"`
}

type StrippedConfig struct {
DistSpecVersion string `json:"distSpecVersion" mapstructure:"distSpecVersion"`
BinaryType string `json:"binaryType" mapstructure:"binaryType"`
BinaryType string `json:"binaryType" mapstructure:"binaryType"`
HTTP struct {
Auth *Auth `json:"auth,omitempty" mapstructure:"auth"`
} `json:"http" mapstructure:"http"`
Expand Down
4 changes: 2 additions & 2 deletions pkg/extensions/sync/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/cache/boltdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/local/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/storage/local/local_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()),
Expand Down
4 changes: 2 additions & 2 deletions pkg/storage/s3/s3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion pkg/test/common/fs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 1675f30

Please sign in to comment.