1package hcsshim
2
3import "github.com/sirupsen/logrus"
4
5// CreateSandboxLayer creates and populates new read-write layer for use by a container.
6// This requires both the id of the direct parent layer, as well as the full list
7// of paths to all parent layers up to the base (and including the direct parent
8// whose id was provided).
9func CreateSandboxLayer(info DriverInfo, layerId, parentId string, parentLayerPaths []string) error {
10	title := "hcsshim::CreateSandboxLayer "
11	logrus.Debugf(title+"layerId %s parentId %s", layerId, parentId)
12
13	// Generate layer descriptors
14	layers, err := layerPathsToDescriptors(parentLayerPaths)
15	if err != nil {
16		return err
17	}
18
19	// Convert info to API calling convention
20	infop, err := convertDriverInfo(info)
21	if err != nil {
22		logrus.Error(err)
23		return err
24	}
25
26	err = createSandboxLayer(&infop, layerId, parentId, layers)
27	if err != nil {
28		err = makeErrorf(err, title, "layerId=%s parentId=%s", layerId, parentId)
29		logrus.Error(err)
30		return err
31	}
32
33	logrus.Debugf(title+"- succeeded layerId=%s parentId=%s", layerId, parentId)
34	return nil
35}
36