mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-18 00:47:48 +08:00
Merge pull request #1409 from jedevc/cherry-pick-1406-to-0.9
[0.9] Synchronise access to the map when printing
This commit is contained in:
commit
4e93e87991
@ -8,6 +8,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"text/tabwriter"
|
"text/tabwriter"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
@ -112,7 +113,9 @@ func (p *Printer) Print(raw bool, out io.Writer) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
imageconfigs := make(map[string]*ocispecs.Image)
|
imageconfigs := make(map[string]*ocispecs.Image)
|
||||||
|
imageconfigsMutex := sync.Mutex{}
|
||||||
buildinfos := make(map[string]*binfotypes.BuildInfo)
|
buildinfos := make(map[string]*binfotypes.BuildInfo)
|
||||||
|
buildinfosMutex := sync.Mutex{}
|
||||||
|
|
||||||
eg, _ := errgroup.WithContext(p.ctx)
|
eg, _ := errgroup.WithContext(p.ctx)
|
||||||
for _, platform := range p.platforms {
|
for _, platform := range p.platforms {
|
||||||
@ -122,12 +125,16 @@ func (p *Printer) Print(raw bool, out io.Writer) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
} else if img != nil {
|
} else if img != nil {
|
||||||
|
imageconfigsMutex.Lock()
|
||||||
imageconfigs[platforms.Format(platform)] = img
|
imageconfigs[platforms.Format(platform)] = img
|
||||||
|
imageconfigsMutex.Unlock()
|
||||||
}
|
}
|
||||||
if bi, err := imageutil.BuildInfo(dtic); err != nil {
|
if bi, err := imageutil.BuildInfo(dtic); err != nil {
|
||||||
return err
|
return err
|
||||||
} else if bi != nil {
|
} else if bi != nil {
|
||||||
|
buildinfosMutex.Lock()
|
||||||
buildinfos[platforms.Format(platform)] = bi
|
buildinfos[platforms.Format(platform)] = bi
|
||||||
|
buildinfosMutex.Unlock()
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user