Skip to content

Commit

Permalink
build: migrate to golang 1.23.x (#2701)
Browse files Browse the repository at this point in the history
* build: migrate to golang 1.23.x

Signed-off-by: Ramkumar Chinchani <[email protected]>

* fix: golangci-lint reported errors

Signed-off-by: Ramkumar Chinchani <[email protected]>

---------

Signed-off-by: Ramkumar Chinchani <[email protected]>
  • Loading branch information
rchincha authored Nov 8, 2024
1 parent a76bfd4 commit 5465aa0
Show file tree
Hide file tree
Showing 33 changed files with 75 additions and 75 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/branch-cov.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cloc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/compare-binary-size.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ecosystem-tools.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/gc-stress-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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: |
Expand Down Expand Up @@ -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: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/golangci-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gqlgen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/license.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/oci-conformance-action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sync-3rdparty-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/web-scan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
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.59.1
GOLINTER_VERSION := v1.61.0
NOTATION := $(TOOLSDIR)/bin/notation
NOTATION_VERSION := 1.0.0
COSIGN := $(TOOLSDIR)/bin/cosign
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module zotregistry.dev/zot

go 1.22.8
go 1.23.2

require (
github.com/99designs/gqlgen v0.17.55
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, ",")).
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ func TestAutoPortSelection(t *testing.T) {
break
}

t.Logf(scanner.Text())
t.Logf("%s", scanner.Text())
}

So(scanner.Err(), ShouldBeNil)
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/ldap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
}

Expand Down
10 changes: 5 additions & 5 deletions pkg/cli/client/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/common/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down
4 changes: 2 additions & 2 deletions pkg/exporter/api/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Loading

0 comments on commit 5465aa0

Please sign in to comment.