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) })