From e04da86acadfbd3e33098f21c35d0a7949b428e6 Mon Sep 17 00:00:00 2001 From: CrazyMax <1951866+crazy-max@users.noreply.github.com> Date: Thu, 7 Nov 2024 13:54:05 +0100 Subject: [PATCH 1/4] fix golangci-lint issues Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com> --- .golangci.yml | 1 + builder/builder.go | 2 +- commands/inspect.go | 2 +- commands/ls.go | 2 +- commands/rm.go | 2 +- controller/remote/controller.go | 4 ++-- driver/docker/driver.go | 4 ++-- driver/remote/driver.go | 2 +- 8 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index b31d72fa..a21c7246 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -76,6 +76,7 @@ linters-settings: excludes: - G204 # Audit use of command execution - G402 # TLS MinVersion too low + - G115 # integer overflow conversion (TODO: verify these) config: G306: "0644" diff --git a/builder/builder.go b/builder/builder.go index 33d2bbef..8ab6ace1 100644 --- a/builder/builder.go +++ b/builder/builder.go @@ -523,7 +523,7 @@ func Create(ctx context.Context, txn *store.Txn, dockerCli command.Cli, opts Cre } cancelCtx, cancel := context.WithCancelCause(ctx) - timeoutCtx, _ := context.WithTimeoutCause(cancelCtx, 20*time.Second, errors.WithStack(context.DeadlineExceeded)) + timeoutCtx, _ := context.WithTimeoutCause(cancelCtx, 20*time.Second, errors.WithStack(context.DeadlineExceeded)) //nolint:govet,lostcancel // no need to manually cancel this context as we already rely on parent defer func() { cancel(errors.WithStack(context.Canceled)) }() nodes, err := b.LoadNodes(timeoutCtx, WithData()) diff --git a/commands/inspect.go b/commands/inspect.go index 8b16195a..8ff25c07 100644 --- a/commands/inspect.go +++ b/commands/inspect.go @@ -36,7 +36,7 @@ func runInspect(ctx context.Context, dockerCli command.Cli, in inspectOptions) e } timeoutCtx, cancel := context.WithCancelCause(ctx) - timeoutCtx, _ = context.WithTimeoutCause(timeoutCtx, 20*time.Second, errors.WithStack(context.DeadlineExceeded)) + timeoutCtx, _ = context.WithTimeoutCause(timeoutCtx, 20*time.Second, errors.WithStack(context.DeadlineExceeded)) //nolint:govet,lostcancel // no need to manually cancel this context as we already rely on parent defer func() { cancel(errors.WithStack(context.Canceled)) }() nodes, err := b.LoadNodes(timeoutCtx, builder.WithData()) diff --git a/commands/ls.go b/commands/ls.go index fa6ad54e..0e6e7a02 100644 --- a/commands/ls.go +++ b/commands/ls.go @@ -59,7 +59,7 @@ func runLs(ctx context.Context, dockerCli command.Cli, in lsOptions) error { } timeoutCtx, cancel := context.WithCancelCause(ctx) - timeoutCtx, _ = context.WithTimeoutCause(timeoutCtx, 20*time.Second, errors.WithStack(context.DeadlineExceeded)) + timeoutCtx, _ = context.WithTimeoutCause(timeoutCtx, 20*time.Second, errors.WithStack(context.DeadlineExceeded)) //nolint:govet,lostcancel // no need to manually cancel this context as we already rely on parent defer func() { cancel(errors.WithStack(context.Canceled)) }() eg, _ := errgroup.WithContext(timeoutCtx) diff --git a/commands/rm.go b/commands/rm.go index b7242804..cabbe9aa 100644 --- a/commands/rm.go +++ b/commands/rm.go @@ -151,7 +151,7 @@ func rmAllInactive(ctx context.Context, txn *store.Txn, dockerCli command.Cli, i } timeoutCtx, cancel := context.WithCancelCause(ctx) - timeoutCtx, _ = context.WithTimeoutCause(timeoutCtx, 20*time.Second, errors.WithStack(context.DeadlineExceeded)) + timeoutCtx, _ = context.WithTimeoutCause(timeoutCtx, 20*time.Second, errors.WithStack(context.DeadlineExceeded)) //nolint:govet,lostcancel // no need to manually cancel this context as we already rely on parent defer func() { cancel(errors.WithStack(context.Canceled)) }() eg, _ := errgroup.WithContext(timeoutCtx) diff --git a/controller/remote/controller.go b/controller/remote/controller.go index fd50d9d3..c9db86fd 100644 --- a/controller/remote/controller.go +++ b/controller/remote/controller.go @@ -63,7 +63,7 @@ func NewRemoteBuildxController(ctx context.Context, dockerCli command.Cli, opts // connect to buildx server if it is already running ctx2, cancel := context.WithCancelCause(ctx) - ctx2, _ = context.WithTimeoutCause(ctx2, 1*time.Second, errors.WithStack(context.DeadlineExceeded)) + ctx2, _ = context.WithTimeoutCause(ctx2, 1*time.Second, errors.WithStack(context.DeadlineExceeded)) //nolint:govet,lostcancel // no need to manually cancel this context as we already rely on parent c, err := newBuildxClientAndCheck(ctx2, filepath.Join(serverRoot, defaultSocketFilename)) cancel(errors.WithStack(context.Canceled)) if err != nil { @@ -92,7 +92,7 @@ func NewRemoteBuildxController(ctx context.Context, dockerCli command.Cli, opts // wait for buildx server to be ready ctx2, cancel = context.WithCancelCause(ctx) - ctx2, _ = context.WithTimeoutCause(ctx2, 10*time.Second, errors.WithStack(context.DeadlineExceeded)) + ctx2, _ = context.WithTimeoutCause(ctx2, 10*time.Second, errors.WithStack(context.DeadlineExceeded)) //nolint:govet,lostcancel // no need to manually cancel this context as we already rely on parent c, err = newBuildxClientAndCheck(ctx2, filepath.Join(serverRoot, defaultSocketFilename)) cancel(errors.WithStack(context.Canceled)) if err != nil { diff --git a/driver/docker/driver.go b/driver/docker/driver.go index d9d278e7..86e115ac 100644 --- a/driver/docker/driver.go +++ b/driver/docker/driver.go @@ -29,7 +29,7 @@ func (d *Driver) Bootstrap(ctx context.Context, l progress.Logger) error { func (d *Driver) Info(ctx context.Context) (*driver.Info, error) { _, err := d.DockerAPI.ServerVersion(ctx) if err != nil { - return nil, errors.Wrapf(driver.ErrNotConnecting{}, err.Error()) + return nil, errors.Wrap(driver.ErrNotConnecting{}, err.Error()) } return &driver.Info{ Status: driver.Running, @@ -39,7 +39,7 @@ func (d *Driver) Info(ctx context.Context) (*driver.Info, error) { func (d *Driver) Version(ctx context.Context) (string, error) { v, err := d.DockerAPI.ServerVersion(ctx) if err != nil { - return "", errors.Wrapf(driver.ErrNotConnecting{}, err.Error()) + return "", errors.Wrap(driver.ErrNotConnecting{}, err.Error()) } if bkversion, _ := resolveBuildKitVersion(v.Version); bkversion != "" { return bkversion, nil diff --git a/driver/remote/driver.go b/driver/remote/driver.go index 5fa9c70f..8718783d 100644 --- a/driver/remote/driver.go +++ b/driver/remote/driver.go @@ -48,7 +48,7 @@ func (d *Driver) Bootstrap(ctx context.Context, l progress.Logger) error { } return progress.Wrap("[internal] waiting for connection", l, func(_ progress.SubLogger) error { cancelCtx, cancel := context.WithCancelCause(ctx) - ctx, _ := context.WithTimeoutCause(cancelCtx, 20*time.Second, errors.WithStack(context.DeadlineExceeded)) + ctx, _ := context.WithTimeoutCause(cancelCtx, 20*time.Second, errors.WithStack(context.DeadlineExceeded)) //nolint:govet,lostcancel // no need to manually cancel this context as we already rely on parent defer func() { cancel(errors.WithStack(context.Canceled)) }() return c.Wait(ctx) }) From 300d56b3ff3f21e70767654fae3613e78242de49 Mon Sep 17 00:00:00 2001 From: CrazyMax <1951866+crazy-max@users.noreply.github.com> Date: Thu, 7 Nov 2024 13:53:54 +0100 Subject: [PATCH 2/4] update gopls and golangci-lint Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com> --- hack/dockerfiles/lint.Dockerfile | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hack/dockerfiles/lint.Dockerfile b/hack/dockerfiles/lint.Dockerfile index ff42b129..155ffd1a 100644 --- a/hack/dockerfiles/lint.Dockerfile +++ b/hack/dockerfiles/lint.Dockerfile @@ -2,11 +2,10 @@ ARG GO_VERSION=1.22 ARG XX_VERSION=1.3.0 -ARG GOLANGCI_LINT_VERSION=1.57.2 -ARG GOPLS_VERSION=v0.20.0 +ARG GOLANGCI_LINT_VERSION=1.62.0 +ARG GOPLS_VERSION=v0.26.0 # disabled: deprecated unusedvariable simplifyrange -ARG GOPLS_ANALYZERS="embeddirective fillreturns infertypeargs nonewvars noresultvalues simplifycompositelit simplifyslice stubmethods undeclaredname unusedparams useany" - +ARG GOPLS_ANALYZERS="embeddirective fillreturns infertypeargs nonewvars norangeoverfunc noresultvalues simplifycompositelit simplifyslice undeclaredname unusedparams useany" FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx From 11cf38bd97fb9f91e73bdf195526e4e687e8f910 Mon Sep 17 00:00:00 2001 From: CrazyMax <1951866+crazy-max@users.noreply.github.com> Date: Thu, 7 Nov 2024 13:46:47 +0100 Subject: [PATCH 3/4] update to go 1.23 Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com> --- .github/workflows/build.yml | 2 +- .github/workflows/codeql.yml | 2 +- .golangci.yml | 4 +++- Dockerfile | 2 +- hack/dockerfiles/docs.Dockerfile | 2 +- hack/dockerfiles/generated-files.Dockerfile | 4 ++-- hack/dockerfiles/govulncheck.Dockerfile | 4 ++-- hack/dockerfiles/lint.Dockerfile | 2 +- hack/dockerfiles/vendor.Dockerfile | 2 +- 9 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f60b9228..75841ceb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,7 +36,7 @@ env: TEST_CACHE_SCOPE: "test" TESTFLAGS: "-v --parallel=6 --timeout=30m" GOTESTSUM_FORMAT: "standard-verbose" - GO_VERSION: "1.22" + GO_VERSION: "1.23" GOTESTSUM_VERSION: "v1.9.0" # same as one in Dockerfile jobs: diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 9631b1b3..5da47e2e 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -17,7 +17,7 @@ on: pull_request: env: - GO_VERSION: "1.22" + GO_VERSION: "1.23" jobs: codeql: diff --git a/.golangci.yml b/.golangci.yml index a21c7246..14d7eb64 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,7 +1,9 @@ run: timeout: 30m - modules-download-mode: vendor + # default uses Go version from the go.mod file, fallback on the env var + # `GOVERSION`, fallback on 1.17: https://golangci-lint.run/usage/configuration/#run-configuration + go: "1.23" linters: enable: diff --git a/Dockerfile b/Dockerfile index 589e3913..39ef626d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1 -ARG GO_VERSION=1.22 +ARG GO_VERSION=1.23 ARG XX_VERSION=1.5.0 # for testing diff --git a/hack/dockerfiles/docs.Dockerfile b/hack/dockerfiles/docs.Dockerfile index e33ac709..8d851073 100644 --- a/hack/dockerfiles/docs.Dockerfile +++ b/hack/dockerfiles/docs.Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1 -ARG GO_VERSION=1.22 +ARG GO_VERSION=1.23 ARG FORMATS=md,yaml FROM golang:${GO_VERSION}-alpine AS docsgen diff --git a/hack/dockerfiles/generated-files.Dockerfile b/hack/dockerfiles/generated-files.Dockerfile index 69d9704f..a7b406c1 100644 --- a/hack/dockerfiles/generated-files.Dockerfile +++ b/hack/dockerfiles/generated-files.Dockerfile @@ -5,8 +5,8 @@ # Copyright The Buildx Authors. # Licensed under the Apache License, Version 2.0 -ARG GO_VERSION="1.22" -ARG PROTOC_VERSION="3.11.4" +ARG GO_VERSION=1.23 +ARG PROTOC_VERSION=3.11.4 ARG PROTOC_GOOGLEAPIS_VERSION=2af421884dd468d565137215c946ebe4e245ae26 # protoc is dynamically linked to glibc so can't use alpine base diff --git a/hack/dockerfiles/govulncheck.Dockerfile b/hack/dockerfiles/govulncheck.Dockerfile index df2cc876..11095600 100644 --- a/hack/dockerfiles/govulncheck.Dockerfile +++ b/hack/dockerfiles/govulncheck.Dockerfile @@ -1,7 +1,7 @@ # syntax=docker/dockerfile:1 -ARG GO_VERSION="1.22" -ARG GOVULNCHECK_VERSION="v1.1.3" +ARG GO_VERSION=1.23 +ARG GOVULNCHECK_VERSION=v1.1.3 ARG FORMAT="text" FROM golang:${GO_VERSION}-alpine AS base diff --git a/hack/dockerfiles/lint.Dockerfile b/hack/dockerfiles/lint.Dockerfile index 155ffd1a..5ed79efd 100644 --- a/hack/dockerfiles/lint.Dockerfile +++ b/hack/dockerfiles/lint.Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1 -ARG GO_VERSION=1.22 +ARG GO_VERSION=1.23 ARG XX_VERSION=1.3.0 ARG GOLANGCI_LINT_VERSION=1.62.0 ARG GOPLS_VERSION=v0.26.0 diff --git a/hack/dockerfiles/vendor.Dockerfile b/hack/dockerfiles/vendor.Dockerfile index 180acdeb..b550d122 100644 --- a/hack/dockerfiles/vendor.Dockerfile +++ b/hack/dockerfiles/vendor.Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1 -ARG GO_VERSION=1.22 +ARG GO_VERSION=1.23 ARG MODOUTDATED_VERSION=v0.9.0 FROM golang:${GO_VERSION}-alpine AS base From 50a8f11f0ff177172fe02ef9287fd4899eb204da Mon Sep 17 00:00:00 2001 From: CrazyMax <1951866+crazy-max@users.noreply.github.com> Date: Thu, 7 Nov 2024 13:54:55 +0100 Subject: [PATCH 4/4] dockerfile: missing xx update to 1.5.0 Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com> --- hack/dockerfiles/lint.Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hack/dockerfiles/lint.Dockerfile b/hack/dockerfiles/lint.Dockerfile index 5ed79efd..3ad8619c 100644 --- a/hack/dockerfiles/lint.Dockerfile +++ b/hack/dockerfiles/lint.Dockerfile @@ -1,7 +1,7 @@ # syntax=docker/dockerfile:1 ARG GO_VERSION=1.23 -ARG XX_VERSION=1.3.0 +ARG XX_VERSION=1.5.0 ARG GOLANGCI_LINT_VERSION=1.62.0 ARG GOPLS_VERSION=v0.26.0 # disabled: deprecated unusedvariable simplifyrange