Merge pull request #2651 from tonistiigi/bake-wrap-target-name

build: when building multiple targets include name in error
This commit is contained in:
Tõnis Tiigi 2024-08-14 13:19:26 +03:00 committed by GitHub
commit 0e64eb4f8b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 14 additions and 1 deletions

View File

@ -309,7 +309,7 @@ func BuildWithResultHandler(ctx context.Context, nodes []builder.Node, opt map[s
childTargets := calculateChildTargets(reqForNodes, opt) childTargets := calculateChildTargets(reqForNodes, opt)
for k, opt := range opt { for k, opt := range opt {
err := func(k string) error { err := func(k string) (err error) {
opt := opt opt := opt
dps := drivers[k] dps := drivers[k]
multiDriver := len(drivers[k]) > 1 multiDriver := len(drivers[k]) > 1
@ -321,6 +321,12 @@ func BuildWithResultHandler(ctx context.Context, nodes []builder.Node, opt map[s
} }
baseCtx := ctx baseCtx := ctx
if multiTarget {
defer func() {
err = errors.Wrapf(err, "target %s", k)
}()
}
res := make([]*client.SolveResponse, len(dps)) res := make([]*client.SolveResponse, len(dps))
eg2, ctx := errgroup.WithContext(ctx) eg2, ctx := errgroup.WithContext(ctx)
@ -565,6 +571,13 @@ func BuildWithResultHandler(ctx context.Context, nodes []builder.Node, opt map[s
tracing.FinishWithError(span, err) tracing.FinishWithError(span, err)
} }
}() }()
if multiTarget {
defer func() {
err = errors.Wrapf(err, "target %s", k)
}()
}
pw := progress.WithPrefix(w, "default", false) pw := progress.WithPrefix(w, "default", false)
if err := eg2.Wait(); err != nil { if err := eg2.Wait(); err != nil {
return err return err