github.com/endocode/docker@v1.4.2-0.20160113120958-46eb4700391e/image/rootfs_windows.go (about) 1 // +build windows 2 3 package image 4 5 import ( 6 "crypto/sha512" 7 "fmt" 8 9 "github.com/docker/distribution/digest" 10 "github.com/docker/docker/layer" 11 ) 12 13 // RootFS describes images root filesystem 14 // This is currently a placeholder that only supports layers. In the future 15 // this can be made into a interface that supports different implementations. 16 type RootFS struct { 17 Type string `json:"type"` 18 DiffIDs []layer.DiffID `json:"diff_ids,omitempty"` 19 BaseLayer string `json:"base_layer,omitempty"` 20 } 21 22 // BaseLayerID returns the 64 byte hex ID for the baselayer name. 23 func (r *RootFS) BaseLayerID() string { 24 baseID := sha512.Sum384([]byte(r.BaseLayer)) 25 return fmt.Sprintf("%x", baseID[:32]) 26 } 27 28 // ChainID returns the ChainID for the top layer in RootFS. 29 func (r *RootFS) ChainID() layer.ChainID { 30 baseDiffID := digest.FromBytes([]byte(r.BaseLayerID())) 31 return layer.CreateChainID(append([]layer.DiffID{layer.DiffID(baseDiffID)}, r.DiffIDs...)) 32 } 33 34 // NewRootFS returns empty RootFS struct 35 func NewRootFS() *RootFS { 36 return &RootFS{Type: "layers+base"} 37 }