@@ -202,24 +202,28 @@ func RunBake(dockerCli command.Cli, in BakeOptions, validator BakeValidator, pri
202202 // Three concurrent pulls at a time to avoid overwhelming the registry.
203203 eg .SetLimit (3 )
204204 for i := range resp {
205- func (i int , targetsToLoad []string ) {
206- eg .Go (func () error {
207- depotResponses := []build.DepotBuildResponse {resp [i ]}
208- var err error
209- // Only load images from requested targets to avoid pulling unnecessary images.
210- if slices .Contains (targetsToLoad , resp [i ].Name ) {
211- reportingPrinter := progresshelper .NewReporter (ctx2 , printer , in .buildID , in .token )
212- defer reportingPrinter .Close ()
213- if in .DepotOptions .loadUsingRegistry && in .DepotOptions .pullInfo != nil {
214- err = load .DepotLoadFromRegistry (ctx , dockerCli .Client (), in .DepotOptions .pullInfo .Reference , true , pullOpts , reportingPrinter )
215- } else {
216- err = load .DepotFastLoad (ctx2 , dockerCli .Client (), depotResponses , pullOpts , reportingPrinter )
205+ eg .Go (func () error {
206+ depotResponses := []build.DepotBuildResponse {resp [i ]}
207+ var err error
208+ // Only load images from requested targets to avoid pulling unnecessary images.
209+ if slices .Contains (targetsToLoad , resp [i ].Name ) {
210+ reportingPrinter := progresshelper .NewReporter (ctx2 , printer , in .buildID , in .token )
211+ defer reportingPrinter .Close ()
212+
213+ if in .DepotOptions .loadUsingRegistry && in .DepotOptions .pullInfo != nil {
214+ target := resp [i ].Name
215+ pullOpt , ok := pullOpts [target ]
216+ if ok {
217+ pw := progress .WithPrefix (reportingPrinter , target , len (pullOpts ) > 1 )
218+ err = load .PullImages (ctx , dockerCli .Client (), fmt .Sprintf ("%s-%s" , in .DepotOptions .pullInfo .Reference , target ), pullOpt , pw )
217219 }
220+ } else {
221+ err = load .DepotFastLoad (ctx2 , dockerCli .Client (), depotResponses , pullOpts , reportingPrinter )
218222 }
219- load . DeleteExportLeases ( ctx2 , depotResponses )
220- return err
221- })
222- }( i , targetsToLoad )
223+ }
224+ load . DeleteExportLeases ( ctx2 , depotResponses )
225+ return err
226+ })
223227 }
224228
225229 err = eg .Wait ()
0 commit comments