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 uses: golangci/golangci-lint-action@v3
with: with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version # 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 # Optional: working directory, useful for monorepos
# working-directory: somedir # working-directory: somedir

View file

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

View file

@ -5,7 +5,7 @@ run:
linters: linters:
enable-all: true 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: linters-settings:
dupl: dupl:

View file

@ -71,7 +71,7 @@ func NewController(config *config.Config) *Controller {
func DumpRuntimeParams(log log.Logger) { func DumpRuntimeParams(log log.Logger) {
var rLimit syscall.Rlimit 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) err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit)
if err == nil { if err == nil {

View file

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

View file

@ -546,7 +546,7 @@ func TestRoutes(t *testing.T) {
}, },
&mocks.MockedImageStore{ &mocks.MockedImageStore{
GetBlobFn: func(repo string, digest godigest.Digest, mediaType string) (io.ReadCloser, int64, error) { 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) So(statusCode, ShouldEqual, http.StatusNotFound)
@ -559,7 +559,7 @@ func TestRoutes(t *testing.T) {
}, },
&mocks.MockedImageStore{ &mocks.MockedImageStore{
GetBlobFn: func(repo string, digest godigest.Digest, mediaType string) (io.ReadCloser, int64, error) { 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) So(statusCode, ShouldEqual, http.StatusBadRequest)

View file

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

View file

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

View file

@ -392,7 +392,7 @@ func TestServeExtensions(t *testing.T) {
cfgfile, err := os.CreateTemp("", "zot-test*.json") cfgfile, err := os.CreateTemp("", "zot-test*.json")
So(err, ShouldBeNil) So(err, ShouldBeNil)
defer os.Remove(cfgfile.Name()) // clean up defer os.Remove(cfgfile.Name()) // clean up
_, err = cfgfile.Write([]byte(content)) _, err = cfgfile.WriteString(content)
So(err, ShouldBeNil) So(err, ShouldBeNil)
err = cfgfile.Close() err = cfgfile.Close()
So(err, ShouldBeNil) So(err, ShouldBeNil)
@ -435,7 +435,7 @@ func TestServeExtensions(t *testing.T) {
cfgfile, err := os.CreateTemp("", "zot-test*.json") cfgfile, err := os.CreateTemp("", "zot-test*.json")
So(err, ShouldBeNil) So(err, ShouldBeNil)
defer os.Remove(cfgfile.Name()) // clean up defer os.Remove(cfgfile.Name()) // clean up
_, err = cfgfile.Write([]byte(content)) _, err = cfgfile.WriteString(content)
So(err, ShouldBeNil) So(err, ShouldBeNil)
err = cfgfile.Close() err = cfgfile.Close()
So(err, ShouldBeNil) So(err, ShouldBeNil)
@ -467,7 +467,7 @@ func testWithMetricsEnabled(cfgContentFormat string) {
So(err, ShouldBeNil) So(err, ShouldBeNil)
defer os.Remove(cfgfile.Name()) // clean up defer os.Remove(cfgfile.Name()) // clean up
_, err = cfgfile.Write([]byte(content)) _, err = cfgfile.WriteString(content)
So(err, ShouldBeNil) So(err, ShouldBeNil)
err = cfgfile.Close() err = cfgfile.Close()
So(err, ShouldBeNil) So(err, ShouldBeNil)
@ -595,7 +595,7 @@ func TestServeMetricsExtension(t *testing.T) {
cfgfile, err := os.CreateTemp("", "zot-test*.json") cfgfile, err := os.CreateTemp("", "zot-test*.json")
So(err, ShouldBeNil) So(err, ShouldBeNil)
defer os.Remove(cfgfile.Name()) // clean up defer os.Remove(cfgfile.Name()) // clean up
_, err = cfgfile.Write([]byte(content)) _, err = cfgfile.WriteString(content)
So(err, ShouldBeNil) So(err, ShouldBeNil)
err = cfgfile.Close() err = cfgfile.Close()
So(err, ShouldBeNil) 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()) config = fmt.Sprintf(config, tempDir, port, logFile.Name())
_, err = cfgfile.Write([]byte(config)) _, err = cfgfile.WriteString(config)
if err != nil { if err != nil {
return "", err return "", err
} }

View file

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

View file

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

View file

@ -34,16 +34,16 @@ type OpenIDConfig struct {
type Auth struct { type Auth struct {
HTPasswd *HTPasswd `json:"htpasswd,omitempty" mapstructure:"htpasswd"` HTPasswd *HTPasswd `json:"htpasswd,omitempty" mapstructure:"htpasswd"`
Bearer *BearerConfig `json:"bearer,omitempty" mapstructure:"bearer"` Bearer *BearerConfig `json:"bearer,omitempty" mapstructure:"bearer"`
LDAP *struct { LDAP *struct {
Address string `json:"address,omitempty" mapstructure:"address"` Address string `json:"address,omitempty" mapstructure:"address"`
} `json:"ldap,omitempty" mapstructure:"ldap"` } `json:"ldap,omitempty" mapstructure:"ldap"`
OpenID *OpenIDConfig `json:"openid,omitempty" mapstructure:"openid"` OpenID *OpenIDConfig `json:"openid,omitempty" mapstructure:"openid"`
} }
type StrippedConfig struct { type StrippedConfig struct {
DistSpecVersion string `json:"distSpecVersion" mapstructure:"distSpecVersion"` DistSpecVersion string `json:"distSpecVersion" mapstructure:"distSpecVersion"`
BinaryType string `json:"binaryType" mapstructure:"binaryType"` BinaryType string `json:"binaryType" mapstructure:"binaryType"`
HTTP struct { HTTP struct {
Auth *Auth `json:"auth,omitempty" mapstructure:"auth"` Auth *Auth `json:"auth,omitempty" mapstructure:"auth"`
} `json:"http" mapstructure:"http"` } `json:"http" mapstructure:"http"`

View file

@ -1898,7 +1898,7 @@ func TestConfigReloader(t *testing.T) {
defer os.Remove(cfgfile.Name()) // clean up defer os.Remove(cfgfile.Name()) // clean up
_, err = cfgfile.Write([]byte(content)) _, err = cfgfile.WriteString(content)
So(err, ShouldBeNil) So(err, ShouldBeNil)
hotReloader, err := cli.NewHotReloader(dctlr, cfgfile.Name()) hotReloader, err := cli.NewHotReloader(dctlr, cfgfile.Name())
@ -2046,7 +2046,7 @@ func TestConfigReloader(t *testing.T) {
defer os.Remove(cfgfile.Name()) // clean up defer os.Remove(cfgfile.Name()) // clean up
_, err = cfgfile.Write([]byte(content)) _, err = cfgfile.WriteString(content)
So(err, ShouldBeNil) So(err, ShouldBeNil)
hotReloader, err := cli.NewHotReloader(dctlr, cfgfile.Name()) 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())) bucket := root.Bucket([]byte(digest.String()))
if bucket != nil { if bucket != nil {
origin := bucket.Bucket([]byte(constants.OriginalBucket)) origin := bucket.Bucket([]byte(constants.OriginalBucket))
blobPath.WriteString(string(d.getOne(origin))) blobPath.Write(d.getOne(origin))
return nil 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 /* also update the modtime, so that gc won't remove recently linked blobs
otherwise ifBlobOlderThan(gcDelay) will return the modtime of the inode */ 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 { if err := os.Chtimes(dest, currentTime, currentTime); err != nil {
return driver.formatErr(err) return driver.formatErr(err)
} }

View file

@ -303,7 +303,7 @@ func FuzzPutBlobChunk(f *testing.F) {
t.Error(err) t.Error(err)
} }
buf := bytes.NewBuffer([]byte(data)) buf := bytes.NewBufferString(data)
buflen := buf.Len() buflen := buf.Len()
_, err = imgStore.PutBlobChunk(repoName, uuid, 0, int64(buflen), buf) _, err = imgStore.PutBlobChunk(repoName, uuid, 0, int64(buflen), buf)
if err != nil { if err != nil {
@ -337,7 +337,7 @@ func FuzzPutBlobChunkStreamed(f *testing.F) {
t.Error(err) t.Error(err)
} }
buf := bytes.NewBuffer([]byte(data)) buf := bytes.NewBufferString(data)
_, err = imgStore.PutBlobChunkStreamed(repoName, uuid, buf) _, err = imgStore.PutBlobChunkStreamed(repoName, uuid, buf)
if err != nil { if err != nil {
t.Error(err) t.Error(err)
@ -1073,7 +1073,7 @@ func FuzzGetOrasReferrers(f *testing.F) {
t.Error(err) t.Error(err)
} }
digest := godigest.FromBytes([]byte(data)) digest := godigest.FromBytes([]byte(data))
buf := bytes.NewBuffer([]byte(data)) buf := bytes.NewBufferString(data)
buflen := buf.Len() buflen := buf.Len()
err = os.WriteFile(path.Join(imgStore.RootDir(), //nolint: gosec err = os.WriteFile(path.Join(imgStore.RootDir(), //nolint: gosec
"zot-test", "blobs", digest.Algorithm().String(), digest.Encoded()), "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{}) _, _, err = imgStore.PutImageManifest(testImage, "1.0", "application/json", []byte{})
So(err, ShouldNotBeNil) So(err, ShouldNotBeNil)
_, err = imgStore.PutBlobChunkStreamed(testImage, upload, bytes.NewBuffer([]byte(testImage))) _, err = imgStore.PutBlobChunkStreamed(testImage, upload, bytes.NewBufferString(testImage))
So(err, ShouldNotBeNil) So(err, ShouldNotBeNil)
_, _, err = imgStore.FullBlobUpload(testImage, bytes.NewBuffer([]byte{}), "inexistent") _, _, 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) { Convey("Test DeleteBlob() - error on store.Move()", t, func(c C) {
tdir := t.TempDir() tdir := t.TempDir()
hash := "7173b809ca12ec5dee4506cd86be934c4596dd234ee82c0662eac04a8c2c71dc" hash := "7173b809ca12ec5dee4506cd86be934c4596dd234ee82c0662eac04a8c2c71dc" // #nosec G101
digest := godigest.NewDigestFromEncoded(godigest.SHA256, hash) digest := godigest.NewDigestFromEncoded(godigest.SHA256, hash)

View file

@ -148,7 +148,7 @@ func TestReadLogFileAndCountStringOccurence(t *testing.T) {
panic(err) 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 { if err != nil {
panic(err) panic(err)
} }