github.com/uppal0016/docker_new@v0.0.0-20240123060250-1c98be13ac2c/distribution/pull_v2_windows.go (about) 1 // +build windows 2 3 package distribution 4 5 import ( 6 "encoding/json" 7 "fmt" 8 9 "github.com/docker/distribution/manifest/schema1" 10 "github.com/docker/docker/image" 11 ) 12 13 func detectBaseLayer(is image.Store, m *schema1.Manifest, rootFS *image.RootFS) error { 14 v1img := &image.V1Image{} 15 if err := json.Unmarshal([]byte(m.History[len(m.History)-1].V1Compatibility), v1img); err != nil { 16 return err 17 } 18 if v1img.Parent == "" { 19 return fmt.Errorf("Last layer %q does not have a base layer reference", v1img.ID) 20 } 21 // There must be an image that already references the baselayer. 22 for _, img := range is.Map() { 23 if img.RootFS.Type == image.TypeLayersWithBase && img.RootFS.BaseLayerID() == v1img.Parent { 24 rootFS.BaseLayer = img.RootFS.BaseLayer 25 rootFS.Type = image.TypeLayersWithBase 26 return nil 27 } 28 } 29 return fmt.Errorf("Invalid base layer %q", v1img.Parent) 30 }