Push flow
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
This commit is contained in:
parent
6b400cd63c
commit
06d0ef4179
1 changed files with 6 additions and 1 deletions
|
@ -267,7 +267,7 @@ func (r *Session) GetV2ImageBlobReader(imageName, sumType, sum string, token []s
|
|||
// Push the image to the server for storage.
|
||||
// 'layer' is an uncompressed reader of the blob to be pushed.
|
||||
// The server will generate it's own checksum calculation.
|
||||
func (r *Session) PutV2ImageBlob(imageName, sumType string, blobRdr io.Reader, token []string) (serverChecksum string, err error) {
|
||||
func (r *Session) PutV2ImageBlob(imageName, sumType, sumStr string, blobRdr io.Reader, token []string) (serverChecksum string, err error) {
|
||||
vars := map[string]string{
|
||||
"imagename": imageName,
|
||||
"sumtype": sumType,
|
||||
|
@ -285,6 +285,7 @@ func (r *Session) PutV2ImageBlob(imageName, sumType string, blobRdr io.Reader, t
|
|||
return "", err
|
||||
}
|
||||
setTokenAuth(req, token)
|
||||
req.Header.Set("X-Tarsum", sumStr)
|
||||
res, _, err := r.doRequest(req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
@ -309,6 +310,10 @@ func (r *Session) PutV2ImageBlob(imageName, sumType string, blobRdr io.Reader, t
|
|||
return "", fmt.Errorf("unable to decode PutV2ImageBlob JSON response: %s", err)
|
||||
}
|
||||
|
||||
if sumInfo.Checksum != sumStr {
|
||||
return "", fmt.Errorf("failed checksum comparison. serverChecksum: %q, localChecksum: %q", sumInfo.Checksum, sumStr)
|
||||
}
|
||||
|
||||
// XXX this is a json struct from the registry, with its checksum
|
||||
return sumInfo.Checksum, nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue