github.com/reds/docker@v1.11.2-rc1/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.BaseLayerID() == v1img.Parent {
    24  			rootFS.BaseLayer = img.RootFS.BaseLayer
    25  			return nil
    26  		}
    27  	}
    28  	return fmt.Errorf("Invalid base layer %q", v1img.Parent)
    29  }