github.com/resin-io/docker@v1.13.1/image/rootfs.go (about) 1 package image 2 3 import ( 4 "runtime" 5 6 "github.com/Sirupsen/logrus" 7 "github.com/docker/docker/layer" 8 ) 9 10 // TypeLayers is used for RootFS.Type for filesystems organized into layers. 11 const TypeLayers = "layers" 12 13 // typeLayersWithBase is an older format used by Windows up to v1.12. We 14 // explicitly handle this as an error case to ensure that a daemon which still 15 // has an older image like this on disk can still start, even though the 16 // image itself is not usable. See https://github.com/docker/docker/pull/25806. 17 const typeLayersWithBase = "layers+base" 18 19 // RootFS describes images root filesystem 20 // This is currently a placeholder that only supports layers. In the future 21 // this can be made into an interface that supports different implementations. 22 type RootFS struct { 23 Type string `json:"type"` 24 DiffIDs []layer.DiffID `json:"diff_ids,omitempty"` 25 } 26 27 // NewRootFS returns empty RootFS struct 28 func NewRootFS() *RootFS { 29 return &RootFS{Type: TypeLayers} 30 } 31 32 // Append appends a new diffID to rootfs 33 func (r *RootFS) Append(id layer.DiffID) { 34 r.DiffIDs = append(r.DiffIDs, id) 35 } 36 37 // ChainID returns the ChainID for the top layer in RootFS. 38 func (r *RootFS) ChainID() layer.ChainID { 39 if runtime.GOOS == "windows" && r.Type == typeLayersWithBase { 40 logrus.Warnf("Layer type is unsupported on this platform. DiffIDs: '%v'", r.DiffIDs) 41 return "" 42 } 43 return layer.CreateChainID(r.DiffIDs) 44 }