Sfoglia il codice sorgente

builder: support for images without layers

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Tonis Tiigi 7 anni fa
parent
commit
9328f0479b
1 ha cambiato i file con 7 aggiunte e 0 eliminazioni
  1. 7 0
      builder/builder-next/adapters/containerimage/pull.go

+ 7 - 0
builder/builder-next/adapters/containerimage/pull.go

@@ -293,6 +293,9 @@ func (p *puller) Snapshot(ctx context.Context) (cache.ImmutableRef, error) {
 	if p.config != nil {
 		img, err := p.is.ImageStore.Get(image.ID(digest.FromBytes(p.config)))
 		if err == nil {
+			if len(img.RootFS.DiffIDs) == 0 {
+				return nil, nil
+			}
 			ref, err := p.is.CacheAccessor.GetFromSnapshotter(ctx, string(img.RootFS.ChainID()), cache.WithDescription(fmt.Sprintf("from local %s", p.ref)))
 			if err != nil {
 				return nil, err
@@ -431,6 +434,10 @@ func (p *puller) Snapshot(ctx context.Context) (cache.ImmutableRef, error) {
 		}
 	}()
 
+	if len(mfst.Layers) == 0 {
+		return nil, nil
+	}
+
 	layers := make([]xfer.DownloadDescriptor, 0, len(mfst.Layers))
 
 	for i, desc := range mfst.Layers {