github.com/Heebron/moby@v0.0.0-20221111184709-6eab4f55faf7/daemon/images/image_windows.go (about)

     1  package images
     2  
     3  import (
     4  	"github.com/docker/docker/image"
     5  	"github.com/docker/docker/layer"
     6  	"github.com/docker/docker/pkg/system"
     7  	"github.com/pkg/errors"
     8  )
     9  
    10  // GetContainerLayerSize returns real size & virtual size
    11  func (i *ImageService) GetContainerLayerSize(containerID string) (int64, int64) {
    12  	// TODO Windows
    13  	return 0, 0
    14  }
    15  
    16  // GetLayerFolders returns the layer folders from an image RootFS
    17  func (i *ImageService) GetLayerFolders(img *image.Image, rwLayer layer.RWLayer) ([]string, error) {
    18  	folders := []string{}
    19  	max := len(img.RootFS.DiffIDs)
    20  	for index := 1; index <= max; index++ {
    21  		// FIXME: why does this mutate the RootFS?
    22  		img.RootFS.DiffIDs = img.RootFS.DiffIDs[:index]
    23  		if !system.IsOSSupported(img.OperatingSystem()) {
    24  			return nil, errors.Wrapf(system.ErrNotSupportedOperatingSystem, "cannot get layerpath for ImageID %s", img.RootFS.ChainID())
    25  		}
    26  		layerPath, err := layer.GetLayerPath(i.layerStore, img.RootFS.ChainID())
    27  		if err != nil {
    28  			return nil, errors.Wrapf(err, "failed to get layer path from graphdriver %s for ImageID %s", i.layerStore, img.RootFS.ChainID())
    29  		}
    30  		// Reverse order, expecting parent first
    31  		folders = append([]string{layerPath}, folders...)
    32  	}
    33  	if rwLayer == nil {
    34  		return nil, errors.New("RWLayer is unexpectedly nil")
    35  	}
    36  	m, err := rwLayer.Metadata()
    37  	if err != nil {
    38  		return nil, errors.Wrap(err, "failed to get layer metadata")
    39  	}
    40  	return append(folders, m["dir"]), nil
    41  }