Skip to content

Commit 72d8875

Browse files
committed
estargz: deprecate errorutil in favor of native errors.Join
Commit cf6d7a0 introduced this package as a replacement for `github.com/hashicorp/go-multierror`. Now that Go stdlib provides native support for multi-errors through errors.Join, we can deprecated the utility, and use stdlib errors instead. Using errors.Join will produce a slightly different formatting, but should still capture the same information. There do not appear to be external consumers of this package, other than through vendoring, so we could decide to remove the package entirely; https://grep.app/search?f.lang=Go&q=estargz%2Ferrorutil Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 3070538 commit 72d8875

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

estargz/build.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ import (
3737
"sync"
3838
"sync/atomic"
3939

40-
"github.com/containerd/stargz-snapshotter/estargz/errorutil"
4140
"github.com/klauspost/compress/zstd"
4241
digest "github.com/opencontainers/go-digest"
4342
"golang.org/x/sync/errgroup"
@@ -656,7 +655,7 @@ func (tf *tempFiles) cleanupAll() error {
656655
}
657656
}
658657
tf.files = nil
659-
return errorutil.Aggregate(allErr)
658+
return errors.Join(allErr...)
660659
}
661660

662661
func newCountReadSeeker(r io.ReaderAt) (*countReadSeeker, error) {

estargz/errorutil/errors.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import (
2323
)
2424

2525
// Aggregate combines a list of errors into a single new error.
26+
//
27+
// Deprecated: use [errors.Join] instead. This package will be removed in v0.19.0
2628
func Aggregate(errs []error) error {
2729
switch len(errs) {
2830
case 0:

estargz/estargz.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ import (
3838
"sync"
3939
"time"
4040

41-
"github.com/containerd/stargz-snapshotter/estargz/errorutil"
4241
digest "github.com/opencontainers/go-digest"
4342
"github.com/vbatts/tar-split/archive/tar"
4443
)
@@ -164,7 +163,7 @@ func Open(sr *io.SectionReader, opt ...OpenOption) (*Reader, error) {
164163
allErr = append(allErr, err)
165164
}
166165
if !found {
167-
return nil, errorutil.Aggregate(allErr)
166+
return nil, errors.Join(allErr...)
168167
}
169168
if err := r.initFields(); err != nil {
170169
return nil, fmt.Errorf("failed to initialize fields of entries: %v", err)
@@ -192,7 +191,7 @@ func OpenFooter(sr *io.SectionReader) (tocOffset int64, footerSize int64, rErr e
192191
}
193192
allErr = append(allErr, err)
194193
}
195-
return 0, 0, errorutil.Aggregate(allErr)
194+
return 0, 0, errors.Join(allErr...)
196195
}
197196

198197
// initFields populates the Reader from r.toc after decoding it from

estargz/testutil.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ import (
4040
"strings"
4141
"time"
4242

43-
"github.com/containerd/stargz-snapshotter/estargz/errorutil"
4443
"github.com/klauspost/compress/zstd"
4544
digest "github.com/opencontainers/go-digest"
4645
)
@@ -1650,7 +1649,7 @@ func newCalledTelemetry() (telemetry *Telemetry, check func(needsGetTOC bool) er
16501649
if !deserializeTocLatencyCalled {
16511650
allErr = append(allErr, fmt.Errorf("metrics DeserializeTocLatency isn't called"))
16521651
}
1653-
return errorutil.Aggregate(allErr)
1652+
return errors.Join(allErr...)
16541653
}
16551654
}
16561655

0 commit comments

Comments
 (0)