Fix checksum computing
This commit is contained in:
parent
6e2ddf6f60
commit
f10b0f75e0
1 changed files with 13 additions and 9 deletions
22
image.go
22
image.go
|
@ -283,22 +283,26 @@ func (img *Image) Checksum() (string, error) {
|
|||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
layerData, err := Tar(layer, Xz)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
h := sha256.New()
|
||||
if _, err := io.Copy(h, layerData); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
jsonData, err := ioutil.ReadFile(jsonPath(root))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
layerData, err := Tar(layer, Xz)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
h := sha256.New()
|
||||
if _, err := io.Copy(h, bytes.NewBuffer(jsonData)); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if _, err := io.Copy(h, strings.NewReader("\n")); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if _, err := io.Copy(h, layerData); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
hash := "sha256:"+hex.EncodeToString(h.Sum(nil))
|
||||
if *checksums == nil {
|
||||
|
|
Loading…
Reference in a new issue