@@ -12,6 +12,7 @@ import (
12
12
"github.com/google/go-containerregistry/pkg/name"
13
13
v1 "github.com/google/go-containerregistry/pkg/v1"
14
14
"github.com/google/go-containerregistry/pkg/v1/remote/transport"
15
+ "github.com/hashicorp/go-multierror"
15
16
"github.com/samber/lo"
16
17
"golang.org/x/xerrors"
17
18
@@ -224,6 +225,7 @@ func NewArtifacts(repos []name.Reference, opt types.RegistryOptions, opts ...Opt
224
225
// Download downloads artifacts until one of them succeeds.
225
226
// Attempts to download next artifact if the first one fails due to a temporary error.
226
227
func (a Artifacts ) Download (ctx context.Context , dst string , opt DownloadOption ) error {
228
+ var errs error
227
229
for i , art := range a {
228
230
log .InfoContext (ctx , "Downloading artifact..." , log .String ("repo" , art .repository ))
229
231
err := art .Download (ctx , dst , opt )
@@ -239,9 +241,10 @@ func (a Artifacts) Download(ctx context.Context, dst string, opt DownloadOption)
239
241
if i < len (a )- 1 {
240
242
log .InfoContext (ctx , "Trying to download artifact from other repository..." )
241
243
}
244
+ errs = multierror .Append (errs , err )
242
245
}
243
246
244
- return xerrors .New ("failed to download artifact from any source" )
247
+ return xerrors .Errorf ("failed to download artifact from any source: %w" , errs )
245
248
}
246
249
247
250
func shouldTryOtherRepo (err error ) bool {
0 commit comments