From 2f452362b8ec924eff8c94b10fb0a051cdd95681 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Sun, 21 Jul 2024 09:40:39 +0200 Subject: [PATCH] ci(deps): upgrade golangci-lint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan-Otto Kröpke --- .github/workflows/golangci-lint.yaml | 2 +- Makefile | 2 +- cmd/zb/helper.go | 5 -- golangcilint.yaml | 58 +++++++++++++++++---- pkg/api/controller_test.go | 1 - pkg/api/ldap.go | 1 - pkg/cli/client/service.go | 2 - pkg/extensions/extension_image_trust.go | 1 - pkg/extensions/imagetrust/notation.go | 1 - pkg/extensions/search/cve/cve_test.go | 1 - pkg/extensions/sync/references/cosign.go | 1 - pkg/extensions/sync/sync_test.go | 1 - pkg/meta/dynamodb/dynamodb.go | 1 - pkg/meta/dynamodb/dynamodb_internal_test.go | 2 +- pkg/test/image-utils/upload.go | 2 - 15 files changed, 51 insertions(+), 30 deletions(-) diff --git a/.github/workflows/golangci-lint.yaml b/.github/workflows/golangci-lint.yaml index 344cf1e2..26b9d0e5 100644 --- a/.github/workflows/golangci-lint.yaml +++ b/.github/workflows/golangci-lint.yaml @@ -24,7 +24,7 @@ jobs: uses: golangci/golangci-lint-action@v6 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.54.2 + version: v1.59.1 # Optional: working directory, useful for monorepos # working-directory: somedir diff --git a/Makefile b/Makefile index 2afab068..3a6b63fe 100644 --- a/Makefile +++ b/Makefile @@ -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.54.2 +GOLINTER_VERSION := v1.59.1 NOTATION := $(TOOLSDIR)/bin/notation NOTATION_VERSION := 1.0.0 COSIGN := $(TOOLSDIR)/bin/cosign diff --git a/cmd/zb/helper.go b/cmd/zb/helper.go index 6cfda833..ba8a4b94 100644 --- a/cmd/zb/helper.go +++ b/cmd/zb/helper.go @@ -370,7 +370,6 @@ func pushMonolithImage(workdir, url, trepo string, repos []string, config testCo SetQueryParam("digest", digest.String()). SetHeader("Content-Length", fmt.Sprintf("%d", size)). SetHeader("Content-Type", "application/octet-stream").SetBody(fhandle).Put(loc) - if err != nil { return nil, repos, err } @@ -385,7 +384,6 @@ func pushMonolithImage(workdir, url, trepo string, repos []string, config testCo // upload image config blob resp, err = client.R(). Post(fmt.Sprintf("%s/v2/%s/blobs/uploads/", url, repo)) - if err != nil { return nil, repos, err } @@ -406,7 +404,6 @@ func pushMonolithImage(workdir, url, trepo string, repos []string, config testCo SetQueryParam("digest", cdigest.String()). SetBody(cblob). Put(loc) - if err != nil { return nil, repos, err } @@ -450,7 +447,6 @@ func pushMonolithImage(workdir, url, trepo string, repos []string, config testCo SetHeader("Content-Type", "application/vnd.oci.image.manifest.v1+json"). SetBody(content). Put(fmt.Sprintf("%s/v2/%s/manifests/%s", url, repo, manifestTag)) - if err != nil { return nil, repos, err } @@ -828,7 +824,6 @@ func pushChunkAndCollect(workdir, url, trepo string, count int, SetHeader("Content-Type", "application/octet-stream"). SetBody(fhandle). Patch(loc) - if err != nil { isConnFail = true diff --git a/golangcilint.yaml b/golangcilint.yaml index 7a866bda..29e3d508 100644 --- a/golangcilint.yaml +++ b/golangcilint.yaml @@ -1,11 +1,38 @@ run: - deadline: 60m - skip-dirs: - - "internal" + timeout: 60m 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,depguard + disable: + - funlen + - gocognit + - paralleltest + - forbidigo + - ireturn + - wrapcheck + - exhaustive + - maintidx + - exhaustruct + - rowserrcheck + - sqlclosecheck + - revive + - musttag + - depguard + - execinquery + - gomnd + - inamedparam + - protogetter + - promlinter + - perfsprint + - testifylint + - wsl + - zerologlint + - canonicalheader + - contextcheck + - mnd + - nilnil + - intrange + - copyloopvar linters-settings: dupl: @@ -41,22 +68,33 @@ linters-settings: - prefix(zotregistry.dev/zot) wsl: allow-assign-and-anything: true - enforce-err-cuddling: true + force-err-cuddling: true nolintlint: allow-unused: true - gomnd: - settings: - mnd: - checks: argument,case,condition,operation,return,assign - ignored-numbers: 10,64 + mnd: + checks: + - argument + - case + - condition + - operation + - return + - assign + ignored-numbers: + - "10" + - "64" gomoddirectives: replace-allow-list: - github.com/gorilla/mux - github.com/testcontainers/testcontainers-go issues: + exclude-dirs: + - "internal" exclude-rules: - path: pkg/extensions/search/schema.resolvers.go linters: - lll - varnamelen - gci + - path: _test\.go + linters: + - dupl \ No newline at end of file diff --git a/pkg/api/controller_test.go b/pkg/api/controller_test.go index c8d84710..9437fc35 100644 --- a/pkg/api/controller_test.go +++ b/pkg/api/controller_test.go @@ -10452,7 +10452,6 @@ func getAllBlobs(imagePath string) []string { p := path.Join(imagePath, "blobs", digest.Algorithm().String(), digest.Encoded()) buf, err = os.ReadFile(p) - if err != nil { panic(err) } diff --git a/pkg/api/ldap.go b/pkg/api/ldap.go index 94682feb..1e209ea7 100644 --- a/pkg/api/ldap.go +++ b/pkg/api/ldap.go @@ -66,7 +66,6 @@ func (lc *LDAPClient) Connect() error { } err = l.StartTLS(config) - if err != nil { lc.Log.Error().Err(err).Str("address", address).Msg("failed to establish a TLS connection") diff --git a/pkg/cli/client/service.go b/pkg/cli/client/service.go index 41538ff8..dffbc593 100644 --- a/pkg/cli/client/service.go +++ b/pkg/cli/client/service.go @@ -472,7 +472,6 @@ func (service searchService) getReferrers(ctx context.Context, config SearchConf referrerResp := &ispec.Index{} _, err = makeGETRequest(ctx, referrersEndpoint, username, password, config.VerifyTLS, config.Debug, &referrerResp, config.ResultWriter) - if err != nil { if common.IsContextDone(ctx) { return referrersResult{}, nil @@ -580,7 +579,6 @@ func getImage(ctx context.Context, config SearchConfig, username, password, imag tagList := &tagListResp{} _, err = makeGETRequest(ctx, tagListEndpoint, username, password, config.VerifyTLS, config.Debug, &tagList, config.ResultWriter) - if err != nil { if common.IsContextDone(ctx) { return diff --git a/pkg/extensions/extension_image_trust.go b/pkg/extensions/extension_image_trust.go index 78692829..7520dfda 100644 --- a/pkg/extensions/extension_image_trust.go +++ b/pkg/extensions/extension_image_trust.go @@ -176,7 +176,6 @@ func SetupImageTrustExtension(conf *config.Config, metaDB mTypes.MetaDB, log log endpoint, _ := conf.Storage.CacheDriver["endpoint"].(string) region, _ := conf.Storage.CacheDriver["region"].(string) imgTrustStore, err = imagetrust.NewAWSImageTrustStore(region, endpoint) - if err != nil { return err } diff --git a/pkg/extensions/imagetrust/notation.go b/pkg/extensions/imagetrust/notation.go index c5c3d4ad..5b382830 100644 --- a/pkg/extensions/imagetrust/notation.go +++ b/pkg/extensions/imagetrust/notation.go @@ -189,7 +189,6 @@ func (cloud *CertificateAWSStorage) InitTrustpolicy(trustpolicy []byte) error { } _, err = cloud.secretsManagerClient.DeleteSecret(context.Background(), deleteSecretParam) - if err != nil { return err } diff --git a/pkg/extensions/search/cve/cve_test.go b/pkg/extensions/search/cve/cve_test.go index 8eee4953..252d5d3b 100644 --- a/pkg/extensions/search/cve/cve_test.go +++ b/pkg/extensions/search/cve/cve_test.go @@ -182,7 +182,6 @@ func generateTestData(dbDir string) error { //nolint: gocyclo il := ispec.ImageLayout{Version: ispec.ImageLayoutVersion} buf, err = json.Marshal(il) - if err != nil { return err } diff --git a/pkg/extensions/sync/references/cosign.go b/pkg/extensions/sync/references/cosign.go index bb62ad7f..eaa6008c 100644 --- a/pkg/extensions/sync/references/cosign.go +++ b/pkg/extensions/sync/references/cosign.go @@ -156,7 +156,6 @@ func (ref CosignReference) SyncReferences(ctx context.Context, localRepo, remote err = meta.SetImageMetaFromInput(ctx, localRepo, cosignTag, ispec.MediaTypeImageManifest, referenceDigest, manifestBuf, ref.storeController.GetImageStore(localRepo), ref.metaDB, ref.log) - if err != nil { return refsDigests, fmt.Errorf("failed to set metadata for cosign reference in '%s@%s': %w", localRepo, subjectDigestStr, err) diff --git a/pkg/extensions/sync/sync_test.go b/pkg/extensions/sync/sync_test.go index 7bf98f2b..0a901d65 100644 --- a/pkg/extensions/sync/sync_test.go +++ b/pkg/extensions/sync/sync_test.go @@ -7158,7 +7158,6 @@ func pushBlob(url string, repoName string, buf []byte) godigest.Digest { SetQueryParam("digest", digest.String()). SetBody(buf). Put(loc) - if err != nil { panic(err) } diff --git a/pkg/meta/dynamodb/dynamodb.go b/pkg/meta/dynamodb/dynamodb.go index 58528554..f023a417 100644 --- a/pkg/meta/dynamodb/dynamodb.go +++ b/pkg/meta/dynamodb/dynamodb.go @@ -2179,7 +2179,6 @@ func (dwr *DynamoDB) createVersionTable() error { TableName: aws.String(dwr.VersionTablename), UpdateExpression: aws.String("SET #V = :Version"), }) - if err != nil { return err } diff --git a/pkg/meta/dynamodb/dynamodb_internal_test.go b/pkg/meta/dynamodb/dynamodb_internal_test.go index f187a7a3..d73c284f 100644 --- a/pkg/meta/dynamodb/dynamodb_internal_test.go +++ b/pkg/meta/dynamodb/dynamodb_internal_test.go @@ -12,7 +12,7 @@ import ( "github.com/rs/zerolog" . "github.com/smartystreets/goconvey/convey" - "zotregistry.dev/zot/pkg/log" //nolint:go-staticcheck + "zotregistry.dev/zot/pkg/log" "zotregistry.dev/zot/pkg/meta/version" tskip "zotregistry.dev/zot/pkg/test/skip" ) diff --git a/pkg/test/image-utils/upload.go b/pkg/test/image-utils/upload.go index dcf1a7d6..f07dab07 100644 --- a/pkg/test/image-utils/upload.go +++ b/pkg/test/image-utils/upload.go @@ -47,7 +47,6 @@ func UploadImage(img Image, baseURL, repo, ref string) error { SetQueryParam("digest", digest). SetBody(blob). Put(baseURL + loc) - if err != nil { return err } @@ -156,7 +155,6 @@ func UploadImageWithBasicAuth(img Image, baseURL, repo, ref, user, password stri SetQueryParam("digest", digest). SetBody(blob). Put(baseURL + loc) - if err != nil { return err }