Skip to content

Commit 39ee64d

Browse files
committed
commands/history: rewrite with stdlib multi-errors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 44945d7 commit 39ee64d

File tree

18 files changed

+9
-1487
lines changed

18 files changed

+9
-1487
lines changed

.golangci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ linters:
3333
desc: The containerd log package was migrated to a separate module. Use github.com/containerd/log instead.
3434
- pkg: "github.com/containerd/containerd/platforms"
3535
desc: The containerd platforms package was migrated to a separate module. Use github.com/containerd/platforms instead.
36+
- pkg: "github.com/hashicorp/go-multierror"
37+
desc: Use stdlib errors.Join instead.
3638
- pkg: "io/ioutil"
3739
desc: The io/ioutil package has been deprecated.
3840
forbidigo:

commands/history/rm.go

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ package history
22

33
import (
44
"context"
5+
stderrors "errors"
56
"io"
67

78
"github.com/docker/buildx/util/cobrautil/completion"
89
"github.com/docker/cli/cli/command"
9-
"github.com/hashicorp/go-multierror"
1010
controlapi "github.com/moby/buildkit/api/services/control"
1111
"github.com/pkg/errors"
1212
"github.com/spf13/cobra"
@@ -90,26 +90,18 @@ func runRm(ctx context.Context, dockerCli command.Cli, opts rmOptions) error {
9090
var out []error
9191
loop0:
9292
for _, nodeErrs := range errs {
93-
var nodeErr error
93+
var nodeErr []error
9494
for _, err1 := range nodeErrs {
9595
if err1 == nil {
9696
continue loop0
9797
}
98-
if nodeErr == nil {
99-
nodeErr = err1
100-
} else {
101-
nodeErr = multierror.Append(nodeErr, err1)
102-
}
98+
nodeErr = append(nodeErr, err1)
99+
}
100+
if len(nodeErr) > 0 {
101+
out = append(out, stderrors.Join(nodeErr...))
103102
}
104-
out = append(out, nodeErr)
105-
}
106-
if len(out) == 0 {
107-
return nil
108-
}
109-
if len(out) == 1 {
110-
return out[0]
111103
}
112-
return multierror.Append(out[0], out[1:]...)
104+
return stderrors.Join(out...)
113105
}
114106

115107
func rmCmd(dockerCli command.Cli, rootOpts RootOptions) *cobra.Command {

go.mod

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ require (
2525
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
2626
github.com/google/uuid v1.6.0
2727
github.com/hashicorp/go-cty-funcs v0.0.0-20250818135842-6aab67130928
28-
github.com/hashicorp/go-multierror v1.1.1
2928
github.com/hashicorp/hcl/v2 v2.24.0
3029
github.com/in-toto/in-toto-golang v0.9.0
3130
github.com/mitchellh/hashstructure/v2 v2.0.2
@@ -150,7 +149,6 @@ require (
150149
github.com/google/go-containerregistry v0.20.6 // indirect
151150
github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674 // indirect
152151
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3 // indirect
153-
github.com/hashicorp/errwrap v1.1.0 // indirect
154152
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
155153
github.com/hiddeco/sshsig v0.2.0 // indirect
156154
github.com/in-toto/attestation v1.1.2 // indirect

go.sum

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,6 @@ github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDa
324324
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0/go.mod h1:g5qyo/la0ALbONm6Vbp88Yd8NsDy6rZz+RcrMPxvld8=
325325
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3 h1:NmZ1PKzSTQbuGHw9DGPFomqkkLWMC+vZCkfs+FHv1Vg=
326326
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3/go.mod h1:zQrxl1YP88HQlA6i9c63DSVPFklWpGX4OWAc9bFuaH4=
327-
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
328327
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
329328
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
330329
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=

0 commit comments

Comments
 (0)