digest: Minor refactoring
Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)
This commit is contained in:
parent
68f9f26f83
commit
3e658d29a6
4 changed files with 28 additions and 6 deletions
|
@ -236,7 +236,10 @@ func TestLayerAPI(t *testing.T) {
|
|||
})
|
||||
|
||||
// Verify the body
|
||||
verifier := digest.NewDigestVerifier(layerDigest)
|
||||
verifier, err := digest.NewDigestVerifier(layerDigest)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error getting digest verifier: %s", err)
|
||||
}
|
||||
io.Copy(verifier, resp.Body)
|
||||
|
||||
if !verifier.Verified() {
|
||||
|
|
|
@ -41,7 +41,11 @@ func TestSimpleRead(t *testing.T) {
|
|||
t.Fatalf("error allocating file reader: %v", err)
|
||||
}
|
||||
|
||||
verifier := digest.NewDigestVerifier(dgst)
|
||||
verifier, err := digest.NewDigestVerifier(dgst)
|
||||
if err != nil {
|
||||
t.Fatalf("error getting digest verifier: %s", err)
|
||||
}
|
||||
|
||||
io.Copy(verifier, fr)
|
||||
|
||||
if !verifier.Verified() {
|
||||
|
|
|
@ -55,7 +55,11 @@ func TestSimpleWrite(t *testing.T) {
|
|||
}
|
||||
defer fr.Close()
|
||||
|
||||
verifier := digest.NewDigestVerifier(dgst)
|
||||
verifier, err := digest.NewDigestVerifier(dgst)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error getting digest verifier: %s", err)
|
||||
}
|
||||
|
||||
io.Copy(verifier, fr)
|
||||
|
||||
if !verifier.Verified() {
|
||||
|
@ -94,7 +98,11 @@ func TestSimpleWrite(t *testing.T) {
|
|||
}
|
||||
defer fr.Close()
|
||||
|
||||
verifier = digest.NewDigestVerifier(doubledgst)
|
||||
verifier, err = digest.NewDigestVerifier(doubledgst)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error getting digest verifier: %s", err)
|
||||
}
|
||||
|
||||
io.Copy(verifier, fr)
|
||||
|
||||
if !verifier.Verified() {
|
||||
|
@ -141,7 +149,11 @@ func TestSimpleWrite(t *testing.T) {
|
|||
}
|
||||
defer fr.Close()
|
||||
|
||||
verifier = digest.NewDigestVerifier(doubledgst)
|
||||
verifier, err = digest.NewDigestVerifier(doubledgst)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error getting digest verifier: %s", err)
|
||||
}
|
||||
|
||||
io.Copy(verifier, fr)
|
||||
|
||||
if !verifier.Verified() {
|
||||
|
|
|
@ -85,7 +85,10 @@ func (luc *layerUploadController) Cancel() error {
|
|||
// validateLayer checks the layer data against the digest, returning an error
|
||||
// if it does not match. The canonical digest is returned.
|
||||
func (luc *layerUploadController) validateLayer(dgst digest.Digest) (digest.Digest, error) {
|
||||
digestVerifier := digest.NewDigestVerifier(dgst)
|
||||
digestVerifier, err := digest.NewDigestVerifier(dgst)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
// TODO(stevvooe): Store resumable hash calculations in upload directory
|
||||
// in driver. Something like a file at path <uuid>/resumablehash/<offest>
|
||||
|
|
Loading…
Reference in a new issue