mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Use layer checksum if calculated during manifest creation
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
This commit is contained in:
parent
e15300b251
commit
ab589b442d
1 changed files with 22 additions and 18 deletions
|
@ -6,7 +6,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"path"
|
|
||||||
|
|
||||||
log "github.com/Sirupsen/logrus"
|
log "github.com/Sirupsen/logrus"
|
||||||
"github.com/docker/docker/engine"
|
"github.com/docker/docker/engine"
|
||||||
|
@ -93,28 +92,33 @@ func (s *TagStore) newManifest(localName, remoteName, tag string) ([]byte, error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
archive, err := layer.TarLayer()
|
checksum := layer.Checksum
|
||||||
if err != nil {
|
if tarsum.VersionLabelForChecksum(checksum) != tarsum.Version1.String() {
|
||||||
return nil, err
|
archive, err := layer.TarLayer()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
tarSum, err := tarsum.NewTarSum(archive, true, tarsum.Version1)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if _, err := io.Copy(ioutil.Discard, tarSum); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
checksum = tarSum.Sum(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
tarSum, err := tarsum.NewTarSum(archive, true, tarsum.Version1)
|
jsonData, err := layer.RawJson()
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if _, err := io.Copy(ioutil.Discard, tarSum); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
tarId := tarSum.Sum(nil)
|
|
||||||
|
|
||||||
manifest.FSLayers = append(manifest.FSLayers, ®istry.FSLayer{BlobSum: tarId})
|
|
||||||
|
|
||||||
layersSeen[layer.ID] = true
|
|
||||||
jsonData, err := ioutil.ReadFile(path.Join(s.graph.Root, layer.ID, "json"))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Cannot retrieve the path for {%s}: %s", layer.ID, err)
|
return nil, fmt.Errorf("Cannot retrieve the path for {%s}: %s", layer.ID, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
manifest.FSLayers = append(manifest.FSLayers, ®istry.FSLayer{BlobSum: checksum})
|
||||||
|
|
||||||
|
layersSeen[layer.ID] = true
|
||||||
|
|
||||||
manifest.History = append(manifest.History, ®istry.ManifestHistory{V1Compatibility: string(jsonData)})
|
manifest.History = append(manifest.History, ®istry.ManifestHistory{V1Compatibility: string(jsonData)})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue