From 5465aa0d514215a19d59292a6c23ff62c01b2553 Mon Sep 17 00:00:00 2001 From: Ramkumar Chinchani <45800463+rchincha@users.noreply.github.com> Date: Fri, 8 Nov 2024 08:58:55 -0800 Subject: [PATCH] build: migrate to golang 1.23.x (#2701) * build: migrate to golang 1.23.x Signed-off-by: Ramkumar Chinchani * fix: golangci-lint reported errors Signed-off-by: Ramkumar Chinchani --------- Signed-off-by: Ramkumar Chinchani --- .github/workflows/benchmark.yaml | 2 +- .github/workflows/branch-cov.yaml | 2 +- .github/workflows/build.yaml | 2 +- .github/workflows/cloc.yaml | 2 +- .github/workflows/cluster.yaml | 2 +- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/compare-binary-size.yaml | 2 +- .github/workflows/ecosystem-tools.yaml | 2 +- .github/workflows/gc-stress-test.yaml | 8 ++--- .github/workflows/golangci-lint.yaml | 4 +-- .github/workflows/gqlgen.yaml | 2 +- .github/workflows/license.yaml | 2 +- .github/workflows/nightly.yaml | 12 +++---- .github/workflows/oci-conformance-action.yaml | 4 +-- .github/workflows/sync-3rdparty-images.yaml | 2 +- .github/workflows/test.yaml | 8 ++--- .github/workflows/tls.yaml | 2 +- .github/workflows/web-scan.yaml | 2 +- Makefile | 2 +- go.mod | 2 +- pkg/api/controller.go | 2 +- pkg/api/controller_test.go | 2 +- pkg/api/ldap.go | 4 +-- pkg/cli/client/service.go | 10 +++--- pkg/common/common_test.go | 2 +- pkg/exporter/api/controller_test.go | 4 +-- pkg/extensions/sync/sync_test.go | 4 +-- pkg/meta/boltdb/boltdb.go | 2 +- pkg/meta/boltdb/boltdb_test.go | 4 +-- pkg/meta/convert/convert_proto.go | 10 +++--- pkg/meta/dynamodb/dynamodb.go | 2 +- pkg/test/image-utils/utils.go | 36 +++++++++---------- pkg/test/oci-utils/oci_layout.go | 2 +- 33 files changed, 75 insertions(+), 75 deletions(-) diff --git a/.github/workflows/benchmark.yaml b/.github/workflows/benchmark.yaml index a8cf2556..c6bb9479 100644 --- a/.github/workflows/benchmark.yaml +++ b/.github/workflows/benchmark.yaml @@ -18,7 +18,7 @@ jobs: - uses: actions/setup-go@v5 with: cache: false - go-version: 1.22.x + go-version: 1.23.x # Run benchmark with `go test -bench` and stores the output to a file - name: Run benchmark run: make BENCH_OUTPUT=ci-cd run-bench diff --git a/.github/workflows/branch-cov.yaml b/.github/workflows/branch-cov.yaml index 84733a4e..3228058c 100644 --- a/.github/workflows/branch-cov.yaml +++ b/.github/workflows/branch-cov.yaml @@ -18,7 +18,7 @@ jobs: - uses: actions/setup-go@v5 with: cache: false - go-version: 1.22.x + go-version: 1.23.x - name: Install dependencies run: | cd $GITHUB_WORKSPACE diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 97dcdab9..838ba029 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -30,7 +30,7 @@ jobs: uses: actions/setup-go@v5 with: cache: false - go-version: 1.22.x + go-version: 1.23.x - name: Cache go dependencies id: cache-go-dependencies uses: actions/cache@v4 diff --git a/.github/workflows/cloc.yaml b/.github/workflows/cloc.yaml index bdf7bc54..ad3f261b 100644 --- a/.github/workflows/cloc.yaml +++ b/.github/workflows/cloc.yaml @@ -21,7 +21,7 @@ jobs: uses: actions/setup-go@v5 with: cache: false - go-version: 1.22.x + go-version: 1.23.x - name: Check out source code uses: actions/checkout@v4 - name: Install dependencies diff --git a/.github/workflows/cluster.yaml b/.github/workflows/cluster.yaml index 5e1bca20..52bc4203 100644 --- a/.github/workflows/cluster.yaml +++ b/.github/workflows/cluster.yaml @@ -31,7 +31,7 @@ jobs: - uses: actions/setup-go@v5 with: cache: false - go-version: 1.22.x + go-version: 1.23.x - name: Install dependencies run: | cd $GITHUB_WORKSPACE diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 5a537a71..7b54babb 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -49,7 +49,7 @@ jobs: uses: actions/setup-go@v5 with: cache: false - go-version: 1.22.x + go-version: 1.23.x # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/.github/workflows/compare-binary-size.yaml b/.github/workflows/compare-binary-size.yaml index b57f3a15..079bb47f 100644 --- a/.github/workflows/compare-binary-size.yaml +++ b/.github/workflows/compare-binary-size.yaml @@ -14,7 +14,7 @@ jobs: - uses: actions/setup-go@v5 with: cache: false - go-version: 1.22.x + go-version: 1.23.x - name: Checkout zot (main branch) run: | mkdir -p $GITHUB_WORKSPACE/zot_main diff --git a/.github/workflows/ecosystem-tools.yaml b/.github/workflows/ecosystem-tools.yaml index 533c037f..2c94b10a 100644 --- a/.github/workflows/ecosystem-tools.yaml +++ b/.github/workflows/ecosystem-tools.yaml @@ -20,7 +20,7 @@ jobs: - uses: actions/setup-go@v5 with: cache: false - go-version: 1.22.x + go-version: 1.23.x - name: Install dependencies run: | cd $GITHUB_WORKSPACE diff --git a/.github/workflows/gc-stress-test.yaml b/.github/workflows/gc-stress-test.yaml index 534018ec..782a7050 100644 --- a/.github/workflows/gc-stress-test.yaml +++ b/.github/workflows/gc-stress-test.yaml @@ -20,7 +20,7 @@ jobs: - uses: actions/setup-go@v5 with: cache: false - go-version: 1.22.x + go-version: 1.23.x - name: Run zb id: bench @@ -51,7 +51,7 @@ jobs: - uses: actions/setup-go@v5 with: cache: false - go-version: 1.22.x + go-version: 1.23.x - name: Run zb id: bench @@ -82,7 +82,7 @@ jobs: - uses: actions/setup-go@v5 with: cache: false - go-version: 1.22.x + go-version: 1.23.x - uses: ./.github/actions/setup-localstack - name: Setup minio service run: | @@ -157,7 +157,7 @@ jobs: - uses: actions/setup-go@v5 with: cache: false - go-version: 1.22.x + go-version: 1.23.x - uses: ./.github/actions/setup-localstack - name: Setup minio service run: | diff --git a/.github/workflows/golangci-lint.yaml b/.github/workflows/golangci-lint.yaml index 26b9d0e5..00c6b0ae 100644 --- a/.github/workflows/golangci-lint.yaml +++ b/.github/workflows/golangci-lint.yaml @@ -18,13 +18,13 @@ jobs: - uses: actions/setup-go@v5 with: cache: false - go-version: '1.22' + go-version: '1.23' - uses: actions/checkout@v4 - name: Run linter with GH action 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.59.1 + version: v1.61.0 # Optional: working directory, useful for monorepos # working-directory: somedir diff --git a/.github/workflows/gqlgen.yaml b/.github/workflows/gqlgen.yaml index 841e888f..7afa3c4d 100644 --- a/.github/workflows/gqlgen.yaml +++ b/.github/workflows/gqlgen.yaml @@ -25,7 +25,7 @@ jobs: - uses: actions/setup-go@v5 with: cache: false - go-version: 1.22.x + go-version: 1.23.x - name: Install dependencies run: | cd $GITHUB_WORKSPACE diff --git a/.github/workflows/license.yaml b/.github/workflows/license.yaml index 47967ba4..48ad6abb 100644 --- a/.github/workflows/license.yaml +++ b/.github/workflows/license.yaml @@ -22,7 +22,7 @@ jobs: - uses: actions/setup-go@v5 with: cache: false - go-version: 1.22.x + go-version: 1.23.x - name: Install go-licenses run: go install github.com/google/go-licenses@latest - name: Check for forbidden licenses diff --git a/.github/workflows/nightly.yaml b/.github/workflows/nightly.yaml index b22976c8..a85f14f5 100644 --- a/.github/workflows/nightly.yaml +++ b/.github/workflows/nightly.yaml @@ -21,7 +21,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: 1.22.x + go-version: 1.23.x - name: Install dependencies run: | cd $GITHUB_WORKSPACE @@ -72,7 +72,7 @@ jobs: uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: 1.22.x + go-version: 1.23.x - name: Install dependencies run: | cd $GITHUB_WORKSPACE @@ -90,7 +90,7 @@ jobs: - uses: actions/setup-go@v5 with: cache: false - go-version: 1.22.x + go-version: 1.23.x - uses: ./.github/actions/setup-localstack - name: Run zb @@ -127,7 +127,7 @@ jobs: - uses: actions/setup-go@v5 with: cache: false - go-version: 1.22.x + go-version: 1.23.x - uses: ./.github/actions/setup-localstack - name: Run zb @@ -175,7 +175,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: 1.22.x + go-version: 1.23.x - name: Install dependencies run: | cd $GITHUB_WORKSPACE @@ -206,7 +206,7 @@ jobs: - uses: actions/setup-go@v5 with: cache: false - go-version: 1.22.x + go-version: 1.23.x - name: Install dependencies run: | cd $GITHUB_WORKSPACE diff --git a/.github/workflows/oci-conformance-action.yaml b/.github/workflows/oci-conformance-action.yaml index f1e0fd5a..46a7b78b 100644 --- a/.github/workflows/oci-conformance-action.yaml +++ b/.github/workflows/oci-conformance-action.yaml @@ -20,11 +20,11 @@ jobs: runs-on: ubuntu-latest # Steps represent a sequence of tasks that will be executed as part of the job steps: - - name: Install go 1.22 + - name: Install go 1.23 uses: actions/setup-go@v5 with: cache: false - go-version: 1.22.x + go-version: 1.23.x - name: Checkout this PR uses: actions/checkout@v4 - name: Start zot server diff --git a/.github/workflows/sync-3rdparty-images.yaml b/.github/workflows/sync-3rdparty-images.yaml index d448d61a..4bf612a5 100644 --- a/.github/workflows/sync-3rdparty-images.yaml +++ b/.github/workflows/sync-3rdparty-images.yaml @@ -18,7 +18,7 @@ jobs: strategy: matrix: golang_version: - - "1.22" + - "1.23" runs-on: ubuntu-latest steps: - name: Log in to GitHub Docker Registry diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 3646408d..e2ad93ca 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -21,7 +21,7 @@ jobs: uses: actions/setup-go@v5 with: cache: false - go-version: 1.22.x + go-version: 1.23.x - name: Cache go dependencies id: cache-go-dependencies uses: actions/cache@v4 @@ -60,7 +60,7 @@ jobs: - uses: actions/setup-go@v5 with: cache: false - go-version: 1.22.x + go-version: 1.23.x - name: Cache go dependencies id: cache-go-dependencies uses: actions/cache@v4 @@ -99,7 +99,7 @@ jobs: - uses: actions/setup-go@v5 with: cache: false - go-version: 1.22.x + go-version: 1.23.x - name: Cache go dependencies id: cache-go-dependencies uses: actions/cache@v4 @@ -133,7 +133,7 @@ jobs: - uses: actions/setup-go@v5 with: cache: false - go-version: 1.22.x + go-version: 1.23.x - name: download all workflow coverage files uses: actions/download-artifact@v4 - name: merge code coverage diff --git a/.github/workflows/tls.yaml b/.github/workflows/tls.yaml index 1c5ac552..6a70712e 100644 --- a/.github/workflows/tls.yaml +++ b/.github/workflows/tls.yaml @@ -18,7 +18,7 @@ jobs: - uses: actions/setup-go@v5 with: cache: false - go-version: 1.22.x + go-version: 1.23.x - name: Install dependencies run: | cd $GITHUB_WORKSPACE diff --git a/.github/workflows/web-scan.yaml b/.github/workflows/web-scan.yaml index 4eeb2711..af82fa3e 100644 --- a/.github/workflows/web-scan.yaml +++ b/.github/workflows/web-scan.yaml @@ -25,7 +25,7 @@ jobs: uses: actions/setup-go@v5 with: cache: false - go-version: 1.22.x + go-version: 1.23.x - name: Checkout uses: actions/checkout@v4 - name: Build zot diff --git a/Makefile b/Makefile index 89fe4016..c43f3c00 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.59.1 +GOLINTER_VERSION := v1.61.0 NOTATION := $(TOOLSDIR)/bin/notation NOTATION_VERSION := 1.0.0 COSIGN := $(TOOLSDIR)/bin/cosign diff --git a/go.mod b/go.mod index 1ba1b83a..0e0e9bf4 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module zotregistry.dev/zot -go 1.22.8 +go 1.23.2 require ( github.com/99designs/gqlgen v0.17.55 diff --git a/pkg/api/controller.go b/pkg/api/controller.go index d9446ba7..056a9bab 100644 --- a/pkg/api/controller.go +++ b/pkg/api/controller.go @@ -78,7 +78,7 @@ func NewController(appConfig *config.Config) *Controller { panic("failed to get member socket") } - if memberSocket == "" { + if memberSocketIdx < 0 || memberSocket == "" { // there is a misconfiguration if the memberSocket cannot be identified logger.Error(). Str("members", strings.Join(appConfig.Cluster.Members, ",")). diff --git a/pkg/api/controller_test.go b/pkg/api/controller_test.go index 66da6687..d97d6b4c 100644 --- a/pkg/api/controller_test.go +++ b/pkg/api/controller_test.go @@ -381,7 +381,7 @@ func TestAutoPortSelection(t *testing.T) { break } - t.Logf(scanner.Text()) + t.Logf("%s", scanner.Text()) } So(scanner.Err(), ShouldBeNil) diff --git a/pkg/api/ldap.go b/pkg/api/ldap.go index 9101093b..bd9ac45d 100644 --- a/pkg/api/ldap.go +++ b/pkg/api/ldap.go @@ -61,7 +61,7 @@ func (lc *LDAPClient) Connect() error { RootCAs: lc.ClientCAs, } - if lc.ClientCertificates != nil && len(lc.ClientCertificates) > 0 { + if len(lc.ClientCertificates) > 0 { config.Certificates = lc.ClientCertificates } @@ -78,7 +78,7 @@ func (lc *LDAPClient) Connect() error { ServerName: lc.ServerName, RootCAs: lc.ClientCAs, } - if lc.ClientCertificates != nil && len(lc.ClientCertificates) > 0 { + if len(lc.ClientCertificates) > 0 { config.Certificates = lc.ClientCertificates } diff --git a/pkg/cli/client/service.go b/pkg/cli/client/service.go index 5ddac93d..f0d24b49 100644 --- a/pkg/cli/client/service.go +++ b/pkg/cli/client/service.go @@ -962,7 +962,7 @@ func (ref referrersResult) stringPlainText(maxArtifactTypeLen int) (string, erro for _, referrer := range ref { artifactType := ellipsize(referrer.ArtifactType, maxArtifactTypeLen, ellipsis) // digest := ellipsize(godigest.Digest(referrer.Digest).Encoded(), digestWidth, "") - size := ellipsize(humanize.Bytes(uint64(referrer.Size)), sizeWidth, ellipsis) + size := ellipsize(humanize.Bytes(uint64(referrer.Size)), sizeWidth, ellipsis) //nolint:gosec,lll // refererrer.Size should >= 0 row := make([]string, refRowWidth) row[refArtifactTypeIndex] = artifactType @@ -1042,7 +1042,7 @@ func (repo repoStruct) stringPlainText(repoMaxLen, maxTimeLen int, verbose bool) row := make([]string, repoRowWidth) row[repoNameIndex] = repoName - row[repoSizeIndex] = ellipsize(strings.ReplaceAll(humanize.Bytes(uint64(repoSize)), " ", ""), sizeWidth, ellipsis) + row[repoSizeIndex] = ellipsize(strings.ReplaceAll(humanize.Bytes(uint64(repoSize)), " ", ""), sizeWidth, ellipsis) //nolint:gosec,lll // ignore overflow row[repoLastUpdatedIndex] = repoLastUpdated.String() row[repoDownloadsIndex] = strconv.Itoa(repoDownloads) row[repoStarsIndex] = strconv.Itoa(repoStars) @@ -1335,15 +1335,15 @@ func combineServerAndEndpointURL(serverURL, endPoint string) (string, error) { return newURL.String(), nil } -func ellipsize(text string, max int, trailing string) string { +func ellipsize(text string, maxLength int, trailing string) string { text = strings.TrimSpace(text) - if len(text) <= max { + if len(text) <= maxLength { return text } chopLength := len(trailing) - return text[:max-chopLength] + trailing + return text[:maxLength-chopLength] + trailing } func getImageTableWriter(writer io.Writer) *tablewriter.Table { diff --git a/pkg/common/common_test.go b/pkg/common/common_test.go index a6c0f7c3..e3a00fda 100644 --- a/pkg/common/common_test.go +++ b/pkg/common/common_test.go @@ -118,7 +118,7 @@ func TestCommon(t *testing.T) { }) Convey("Test AreSocketsEqual with equal IPv6 sockets", t, func() { - result, err := common.AreSocketsEqual("[::1]:9000", "[0000:0000:0000:0000:0000:0000:0000:00001]:9000") + result, err := common.AreSocketsEqual("[::1]:9000", "[0000:0000:0000:0000:0000:0000:0000:0001]:9000") So(err, ShouldBeNil) So(result, ShouldBeTrue) }) diff --git a/pkg/exporter/api/controller_test.go b/pkg/exporter/api/controller_test.go index 7fade424..e5628119 100644 --- a/pkg/exporter/api/controller_test.go +++ b/pkg/exporter/api/controller_test.go @@ -30,8 +30,8 @@ import ( . "zotregistry.dev/zot/pkg/test/common" ) -func getRandomLatencyN(max int64) time.Duration { - nBig, err := rand.Int(rand.Reader, big.NewInt(max)) +func getRandomLatencyN(maxLatency int64) time.Duration { + nBig, err := rand.Int(rand.Reader, big.NewInt(maxLatency)) if err != nil { panic(err) } diff --git a/pkg/extensions/sync/sync_test.go b/pkg/extensions/sync/sync_test.go index d0fc8a79..85c81c4b 100644 --- a/pkg/extensions/sync/sync_test.go +++ b/pkg/extensions/sync/sync_test.go @@ -4670,7 +4670,7 @@ func TestSignatures(t *testing.T) { splittedURL := strings.SplitAfter(srcBaseURL, ":") srcPort := splittedURL[len(splittedURL)-1] - t.Logf(srcPort) + t.Logf("%s", srcPort) cwd, err := os.Getwd() So(err, ShouldBeNil) @@ -5201,7 +5201,7 @@ func TestSignatures(t *testing.T) { splittedURL := strings.SplitAfter(srcBaseURL, ":") srcPort := splittedURL[len(splittedURL)-1] - t.Logf(srcPort) + t.Logf("%s", srcPort) err := signature.SignImageUsingCosign(fmt.Sprintf("%s@%s", repoName, digest.String()), srcPort, true) So(err, ShouldBeNil) diff --git a/pkg/meta/boltdb/boltdb.go b/pkg/meta/boltdb/boltdb.go index 851ee6d7..0166bf51 100644 --- a/pkg/meta/boltdb/boltdb.go +++ b/pkg/meta/boltdb/boltdb.go @@ -451,7 +451,7 @@ func (bdw *BoltDB) SearchRepos(ctx context.Context, searchText string, continue } - protoRepoMeta.Rank = int32(rank) + protoRepoMeta.Rank = int32(rank) //nolint:gosec // ignore overflow protoRepoMeta.IsStarred = zcommon.Contains(userStars, protoRepoMeta.Name) protoRepoMeta.IsBookmarked = zcommon.Contains(userBookmarks, protoRepoMeta.Name) diff --git a/pkg/meta/boltdb/boltdb_test.go b/pkg/meta/boltdb/boltdb_test.go index 60074bb3..067925f3 100644 --- a/pkg/meta/boltdb/boltdb_test.go +++ b/pkg/meta/boltdb/boltdb_test.go @@ -647,7 +647,7 @@ func TestWrapperErrors(t *testing.T) { Convey("DeleteUserData", func() { userAc = reqCtx.NewUserAccessControl() - ctx = userAc.DeriveContext(context.Background()) + ctx = userAc.DeriveContext(context.Background()) //nolint:fatcontext // test code err = boltdbWrapper.DeleteUserData(ctx) So(err, ShouldNotBeNil) @@ -667,7 +667,7 @@ func TestWrapperErrors(t *testing.T) { Convey("GetUserGroups and SetUserGroups", func() { userAc = reqCtx.NewUserAccessControl() - ctx = userAc.DeriveContext(context.Background()) + ctx = userAc.DeriveContext(context.Background()) //nolint:fatcontext // test code _, err := boltdbWrapper.GetUserGroups(ctx) So(err, ShouldNotBeNil) diff --git a/pkg/meta/convert/convert_proto.go b/pkg/meta/convert/convert_proto.go index 59ea2668..b8985be3 100644 --- a/pkg/meta/convert/convert_proto.go +++ b/pkg/meta/convert/convert_proto.go @@ -23,8 +23,8 @@ func GetProtoRepoMeta(repo mTypes.RepoMeta) *proto_go.RepoMeta { Vendors: repo.Vendors, Platforms: GetProtoPlatforms(repo.Platforms), LastUpdatedImage: GetProtoLastUpdatedImage(repo.LastUpdatedImage), - Stars: int32(repo.StarCount), - Downloads: int32(repo.DownloadCount), + Stars: int32(repo.StarCount), //nolint:gosec // ignore overflow + Downloads: int32(repo.DownloadCount), //nolint:gosec // ignore overflow } } @@ -65,7 +65,7 @@ func GetProtoManifestMeta(manifestContent ispec.Manifest, configContent ispec.Im Digest: digest, Size: size, Manifest: &proto_go.Manifest{ - Versioned: &proto_go.Versioned{SchemaVersion: int32(manifestContent.SchemaVersion)}, + Versioned: &proto_go.Versioned{SchemaVersion: int32(manifestContent.SchemaVersion)}, //nolint:gosec,lll // ignore overflow Config: &proto_go.Descriptor{ Digest: manifestContent.Config.Digest.String(), Size: manifestContent.Config.Size, @@ -108,7 +108,7 @@ func GetProtoImageIndexMeta(indexContent ispec.Index, size int64, digest string) Size: size, Digest: digest, Index: &proto_go.Index{ - Versioned: &proto_go.Versioned{SchemaVersion: int32(indexContent.Versioned.SchemaVersion)}, + Versioned: &proto_go.Versioned{SchemaVersion: int32(indexContent.Versioned.SchemaVersion)}, //nolint:gosec,lll // ignore overflow MediaType: ref(ispec.MediaTypeImageIndex), ArtifactType: ref(common.GetIndexArtifactType(indexContent)), Manifests: getProtoManifestList(indexContent.Manifests), @@ -125,7 +125,7 @@ func GetProtoStatistics(stats map[mTypes.ImageDigest]mTypes.DescriptorStatistics for digest, stat := range stats { results[digest] = &proto_go.DescriptorStatistics{ - DownloadCount: int32(stat.DownloadCount), + DownloadCount: int32(stat.DownloadCount), //nolint:gosec // ignore overflow LastPullTimestamp: timestamppb.New(stat.LastPullTimestamp), PushTimestamp: timestamppb.New(stat.PushTimestamp), PushedBy: stat.PushedBy, diff --git a/pkg/meta/dynamodb/dynamodb.go b/pkg/meta/dynamodb/dynamodb.go index f375e768..8488c78e 100644 --- a/pkg/meta/dynamodb/dynamodb.go +++ b/pkg/meta/dynamodb/dynamodb.go @@ -613,7 +613,7 @@ func (dwr *DynamoDB) SearchRepos(ctx context.Context, searchText string) ([]mTyp continue } - protoRepoMeta.Rank = int32(rank) + protoRepoMeta.Rank = int32(rank) //nolint:gosec // ignore overflow protoRepoMeta.IsStarred = zcommon.Contains(userStars, protoRepoMeta.Name) protoRepoMeta.IsBookmarked = zcommon.Contains(userBookmarks, protoRepoMeta.Name) diff --git a/pkg/test/image-utils/utils.go b/pkg/test/image-utils/utils.go index 58018011..aa39e5a4 100644 --- a/pkg/test/image-utils/utils.go +++ b/pkg/test/image-utils/utils.go @@ -92,36 +92,36 @@ func GetDefaultConfig() ispec.Image { func DefaultTimeRef() *time.Time { var ( - year = 2010 - month = time.Month(1) - day = 1 - hour = 1 - min = 1 - sec = 1 - nsec = 0 + year = 2010 + month = time.Month(1) + day = 1 + hour = 1 + minute = 1 + sec = 1 + nsec = 0 ) - return DateRef(year, month, day, hour, min, sec, nsec, time.UTC) + return DateRef(year, month, day, hour, minute, sec, nsec, time.UTC) } -func DateRef(year int, month time.Month, day, hour, min, sec, nsec int, loc *time.Location) *time.Time { - date := time.Date(year, month, day, hour, min, sec, nsec, loc) +func DateRef(year int, month time.Month, day, hour, minute, sec, nsec int, loc *time.Location) *time.Time { + date := time.Date(year, month, day, hour, minute, sec, nsec, loc) return &date } func RandomDateRef(loc *time.Location) *time.Time { var ( - year = 1990 + mathRand.Intn(30) //nolint: gosec,mnd - month = time.Month(1 + mathRand.Intn(10)) //nolint: gosec,mnd - day = 1 + mathRand.Intn(5) //nolint: gosec,mnd - hour = 1 + mathRand.Intn(22) //nolint: gosec,mnd - min = 1 + mathRand.Intn(58) //nolint: gosec,mnd - sec = 1 + mathRand.Intn(58) //nolint: gosec,mnd - nsec = 1 + year = 1990 + mathRand.Intn(30) //nolint: gosec,mnd + month = time.Month(1 + mathRand.Intn(10)) //nolint: gosec,mnd + day = 1 + mathRand.Intn(5) //nolint: gosec,mnd + hour = 1 + mathRand.Intn(22) //nolint: gosec,mnd + minute = 1 + mathRand.Intn(58) //nolint: gosec,mnd + sec = 1 + mathRand.Intn(58) //nolint: gosec,mnd + nsec = 1 ) - return DateRef(year, month, day, hour, min, sec, nsec, time.UTC) + return DateRef(year, month, day, hour, minute, sec, nsec, time.UTC) } func GetDefaultVulnConfig() ispec.Image { diff --git a/pkg/test/oci-utils/oci_layout.go b/pkg/test/oci-utils/oci_layout.go index f2a1cc54..43bead73 100644 --- a/pkg/test/oci-utils/oci_layout.go +++ b/pkg/test/oci-utils/oci_layout.go @@ -107,7 +107,7 @@ func (olu BaseOciLayoutUtils) GetImageManifests(repo string) ([]ispec.Descriptor buf, err := imageStore.GetIndexContent(repo) if err != nil { - if goerrors.Is(zerr.ErrRepoNotFound, err) { + if goerrors.Is(err, zerr.ErrRepoNotFound) { olu.Log.Error().Err(err).Msg("failed to get index.json contents because the file is missing") return nil, zerr.ErrRepoNotFound