Skip to content

Commit 535eac9

Browse files
committed
exporter: allow unpack on multi-platform images
fddd129 added an overly broad check for preventing unpacking scratch objects, which also prevents unpacking any multi-platform images (which instead use `src.Refs`). We can push the nil check down into unpackImage, and also use the `FindRef` result helper to simplify to the Ref(s). Signed-off-by: Justin Chadwell <[email protected]>
1 parent ff62ebf commit 535eac9

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

exporter/containerimage/export.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ func (e *imageExporterInstance) Export(ctx context.Context, src *exporter.Source
258258
}
259259
tagDone(nil)
260260

261-
if src.Ref != nil && e.unpack {
261+
if e.unpack {
262262
if err := e.unpackImage(ctx, img, src, session.NewGroup(sessionID)); err != nil {
263263
return nil, nil, err
264264
}
@@ -366,16 +366,16 @@ func (e *imageExporterInstance) unpackImage(ctx context.Context, img images.Imag
366366
return err
367367
}
368368

369-
topLayerRef := src.Ref
370-
if len(src.Refs) > 0 {
371-
if r, ok := src.Refs[defaultPlatform()]; ok {
372-
topLayerRef = r
373-
} else {
374-
return errors.Errorf("no reference for default platform %s", defaultPlatform())
375-
}
369+
ref, ok := src.FindRef(defaultPlatform())
370+
if !ok {
371+
return errors.Errorf("no reference for default platform %s", defaultPlatform())
372+
}
373+
if ref == nil {
374+
// ref has no layers, so nothing to unpack
375+
return nil
376376
}
377377

378-
remotes, err := topLayerRef.GetRemotes(ctx, true, e.opts.RefCfg, false, s)
378+
remotes, err := ref.GetRemotes(ctx, true, e.opts.RefCfg, false, s)
379379
if err != nil {
380380
return err
381381
}

0 commit comments

Comments
 (0)