mirror of
				https://gitea.com/Lydanne/buildx.git
				synced 2025-11-01 00:23:56 +08:00 
			
		
		
		
	Synchronise access to the map when printing.
Signed-off-by: Felix de Souza <fdesouza@palantir.com>
This commit is contained in:
		| @@ -8,6 +8,7 @@ import ( | ||||
| 	"os" | ||||
| 	"sort" | ||||
| 	"strings" | ||||
| 	"sync" | ||||
| 	"text/tabwriter" | ||||
| 	"text/template" | ||||
|  | ||||
| @@ -113,6 +114,7 @@ func (p *Printer) Print(raw bool, out io.Writer) error { | ||||
|  | ||||
| 	imageconfigs := make(map[string]*ocispecs.Image) | ||||
| 	buildinfos := make(map[string]*binfotypes.BuildInfo) | ||||
| 	mutex := &sync.RWMutex{} | ||||
|  | ||||
| 	eg, _ := errgroup.WithContext(p.ctx) | ||||
| 	for _, platform := range p.platforms { | ||||
| @@ -122,12 +124,16 @@ func (p *Printer) Print(raw bool, out io.Writer) error { | ||||
| 				if err != nil { | ||||
| 					return err | ||||
| 				} else if img != nil { | ||||
| 					mutex.Lock() | ||||
| 					imageconfigs[platforms.Format(platform)] = img | ||||
| 					mutex.Unlock() | ||||
| 				} | ||||
| 				if bi, err := imageutil.BuildInfo(dtic); err != nil { | ||||
| 					return err | ||||
| 				} else if bi != nil { | ||||
| 					mutex.Lock() | ||||
| 					buildinfos[platforms.Format(platform)] = bi | ||||
| 					mutex.Unlock() | ||||
| 				} | ||||
| 				return nil | ||||
| 			}) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Felix de Souza
					Felix de Souza