Browse code

*: use opencontainers/go-digest package

The `digest` data type, used throughout docker for image verification
and identity, has been broken out into `opencontainers/go-digest`. This
PR updates the dependencies and moves uses over to the new type.

Signed-off-by: Stephen J Day <stephen.day@docker.com>

Stephen J Day authored on 2017/01/07 10:23:18
Showing 53 changed files
... ...
@@ -1,6 +1,7 @@
1 1
 package reference
2 2
 
3 3
 import (
4
+	_ "crypto/sha256"
4 5
 	"testing"
5 6
 )
6 7
 
... ...
@@ -10,7 +10,6 @@ import (
10 10
 	"sort"
11 11
 
12 12
 	"github.com/Sirupsen/logrus"
13
-	"github.com/docker/distribution/digest"
14 13
 	"github.com/docker/docker/api/types"
15 14
 	"github.com/docker/docker/cli/command"
16 15
 	"github.com/docker/docker/cli/trust"
... ...
@@ -19,6 +18,7 @@ import (
19 19
 	"github.com/docker/docker/registry"
20 20
 	"github.com/docker/notary/client"
21 21
 	"github.com/docker/notary/tuf/data"
22
+	"github.com/opencontainers/go-digest"
22 23
 	"golang.org/x/net/context"
23 24
 )
24 25
 
... ...
@@ -58,7 +58,7 @@ func PushTrustedReference(cli *command.DockerCli, repoInfo *registry.RepositoryI
58 58
 		var pushResult types.PushResult
59 59
 		err := json.Unmarshal(*aux, &pushResult)
60 60
 		if err == nil && pushResult.Tag != "" {
61
-			if dgst, err := digest.ParseDigest(pushResult.Digest); err == nil {
61
+			if dgst, err := digest.Parse(pushResult.Digest); err == nil {
62 62
 				h, err := hex.DecodeString(dgst.Hex())
63 63
 				if err != nil {
64 64
 					target = nil
... ...
@@ -5,7 +5,6 @@ import (
5 5
 	"fmt"
6 6
 
7 7
 	"github.com/Sirupsen/logrus"
8
-	"github.com/docker/distribution/digest"
9 8
 	distreference "github.com/docker/distribution/reference"
10 9
 	"github.com/docker/docker/api/types/swarm"
11 10
 	"github.com/docker/docker/cli/command"
... ...
@@ -13,6 +12,7 @@ import (
13 13
 	"github.com/docker/docker/reference"
14 14
 	"github.com/docker/docker/registry"
15 15
 	"github.com/docker/notary/tuf/data"
16
+	"github.com/opencontainers/go-digest"
16 17
 	"github.com/pkg/errors"
17 18
 	"golang.org/x/net/context"
18 19
 )
... ...
@@ -30,7 +30,7 @@ func resolveServiceImageDigest(dockerCli *command.DockerCli, service *swarm.Serv
30 30
 	// could be parsed as a digest reference. Specifying an image ID
31 31
 	// is valid but not resolvable. There is no warning message for
32 32
 	// an image ID because it's valid to use one.
33
-	if _, err := digest.ParseDigest(image); err == nil {
33
+	if _, err := digest.Parse(image); err == nil {
34 34
 		return nil
35 35
 	}
36 36
 
... ...
@@ -182,6 +182,7 @@ type bintree struct {
182 182
 	Func     func() (*asset, error)
183 183
 	Children map[string]*bintree
184 184
 }
185
+
185 186
 var _bintree = &bintree{nil, map[string]*bintree{
186 187
 	"data": &bintree{nil, map[string]*bintree{
187 188
 		"config_schema_v3.0.json": &bintree{dataConfig_schema_v30Json, map[string]*bintree{}},
... ...
@@ -234,4 +235,3 @@ func _filePath(dir, name string) string {
234 234
 	cannonicalName := strings.Replace(name, "\\", "/", -1)
235 235
 	return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
236 236
 }
237
-
... ...
@@ -52,7 +52,6 @@ import (
52 52
 	"time"
53 53
 
54 54
 	"github.com/Sirupsen/logrus"
55
-	"github.com/docker/distribution/digest"
56 55
 	distreference "github.com/docker/distribution/reference"
57 56
 	apierrors "github.com/docker/docker/api/errors"
58 57
 	apitypes "github.com/docker/docker/api/types"
... ...
@@ -73,6 +72,7 @@ import (
73 73
 	"github.com/docker/swarmkit/manager/encryption"
74 74
 	swarmnode "github.com/docker/swarmkit/node"
75 75
 	"github.com/docker/swarmkit/protobuf/ptypes"
76
+	"github.com/opencontainers/go-digest"
76 77
 	"github.com/pkg/errors"
77 78
 	"golang.org/x/net/context"
78 79
 )
... ...
@@ -832,7 +832,7 @@ func (c *Cluster) GetServices(options apitypes.ServiceListOptions) ([]types.Serv
832 832
 // TODO(nishanttotla): After the packages converge, the function must
833 833
 // convert distreference.Named -> distreference.Canonical, and the logic simplified.
834 834
 func (c *Cluster) imageWithDigestString(ctx context.Context, image string, authConfig *apitypes.AuthConfig) (string, error) {
835
-	if _, err := digest.ParseDigest(image); err == nil {
835
+	if _, err := digest.Parse(image); err == nil {
836 836
 		return "", errors.New("image reference is an image ID")
837 837
 	}
838 838
 	ref, err := distreference.ParseNamed(image)
... ...
@@ -14,7 +14,7 @@ func NodeFromGRPC(n swarmapi.Node) types.Node {
14 14
 	node := types.Node{
15 15
 		ID: n.ID,
16 16
 		Spec: types.NodeSpec{
17
-			Role:         types.NodeRole(strings.ToLower(n.Spec.Role.String())),
17
+			Role:         types.NodeRole(strings.ToLower(n.Spec.DesiredRole.String())),
18 18
 			Availability: types.NodeAvailability(strings.ToLower(n.Spec.Availability.String())),
19 19
 		},
20 20
 		Status: types.NodeStatus{
... ...
@@ -74,7 +74,7 @@ func NodeSpecToGRPC(s types.NodeSpec) (swarmapi.NodeSpec, error) {
74 74
 		},
75 75
 	}
76 76
 	if role, ok := swarmapi.NodeRole_value[strings.ToUpper(string(s.Role))]; ok {
77
-		spec.Role = swarmapi.NodeRole(role)
77
+		spec.DesiredRole = swarmapi.NodeRole(role)
78 78
 	} else {
79 79
 		return swarmapi.NodeSpec{}, fmt.Errorf("invalid Role: %q", s.Role)
80 80
 	}
... ...
@@ -11,7 +11,6 @@ import (
11 11
 	"time"
12 12
 
13 13
 	"github.com/Sirupsen/logrus"
14
-	"github.com/docker/distribution/digest"
15 14
 	"github.com/docker/docker/api/types"
16 15
 	"github.com/docker/docker/api/types/backend"
17 16
 	containertypes "github.com/docker/docker/api/types/container"
... ...
@@ -24,6 +23,7 @@ import (
24 24
 	"github.com/docker/swarmkit/api"
25 25
 	"github.com/docker/swarmkit/log"
26 26
 	"github.com/docker/swarmkit/protobuf/ptypes"
27
+	"github.com/opencontainers/go-digest"
27 28
 	"golang.org/x/net/context"
28 29
 	"golang.org/x/time/rate"
29 30
 )
... ...
@@ -54,7 +54,7 @@ func (c *containerAdapter) pullImage(ctx context.Context) error {
54 54
 	spec := c.container.spec()
55 55
 
56 56
 	// Skip pulling if the image is referenced by image ID.
57
-	if _, err := digest.ParseDigest(spec.Image); err == nil {
57
+	if _, err := digest.Parse(spec.Image); err == nil {
58 58
 		return nil
59 59
 	}
60 60
 
... ...
@@ -4,12 +4,12 @@ import (
4 4
 	"fmt"
5 5
 
6 6
 	"github.com/Sirupsen/logrus"
7
-	"github.com/docker/distribution/digest"
8 7
 	"github.com/docker/docker/api/types"
9 8
 	"github.com/docker/docker/api/types/filters"
10 9
 	"github.com/docker/docker/layer"
11 10
 	"github.com/docker/docker/pkg/directory"
12 11
 	"github.com/docker/docker/volume"
12
+	"github.com/opencontainers/go-digest"
13 13
 )
14 14
 
15 15
 func (daemon *Daemon) getLayerRefs() map[layer.ChainID]int {
... ...
@@ -5,7 +5,6 @@ import (
5 5
 	"strings"
6 6
 
7 7
 	dist "github.com/docker/distribution"
8
-	"github.com/docker/distribution/digest"
9 8
 	"github.com/docker/docker/api/types"
10 9
 	"github.com/docker/docker/builder"
11 10
 	"github.com/docker/docker/distribution"
... ...
@@ -13,6 +12,7 @@ import (
13 13
 	"github.com/docker/docker/pkg/progress"
14 14
 	"github.com/docker/docker/reference"
15 15
 	"github.com/docker/docker/registry"
16
+	"github.com/opencontainers/go-digest"
16 17
 	"golang.org/x/net/context"
17 18
 )
18 19
 
... ...
@@ -32,7 +32,7 @@ func (daemon *Daemon) PullImage(ctx context.Context, image, tag string, metaHead
32 32
 	if tag != "" {
33 33
 		// The "tag" could actually be a digest.
34 34
 		var dgst digest.Digest
35
-		dgst, err = digest.ParseDigest(tag)
35
+		dgst, err = digest.Parse(tag)
36 36
 		if err == nil {
37 37
 			ref, err = reference.WithDigest(reference.TrimNamed(ref), dgst)
38 38
 		} else {
... ...
@@ -5,7 +5,6 @@ import (
5 5
 	"regexp"
6 6
 
7 7
 	"github.com/Sirupsen/logrus"
8
-	"github.com/docker/distribution/digest"
9 8
 	"github.com/docker/docker/api/types"
10 9
 	"github.com/docker/docker/api/types/filters"
11 10
 	"github.com/docker/docker/image"
... ...
@@ -15,6 +14,7 @@ import (
15 15
 	"github.com/docker/docker/runconfig"
16 16
 	"github.com/docker/docker/volume"
17 17
 	"github.com/docker/libnetwork"
18
+	"github.com/opencontainers/go-digest"
18 19
 )
19 20
 
20 21
 // ContainersPrune removes unused containers
... ...
@@ -7,7 +7,6 @@ import (
7 7
 	"runtime"
8 8
 
9 9
 	"github.com/docker/distribution"
10
-	"github.com/docker/distribution/digest"
11 10
 	"github.com/docker/distribution/manifest/schema2"
12 11
 	"github.com/docker/docker/api/types"
13 12
 	"github.com/docker/docker/distribution/metadata"
... ...
@@ -18,6 +17,7 @@ import (
18 18
 	"github.com/docker/docker/reference"
19 19
 	"github.com/docker/docker/registry"
20 20
 	"github.com/docker/libtrust"
21
+	"github.com/opencontainers/go-digest"
21 22
 	"golang.org/x/net/context"
22 23
 )
23 24
 
... ...
@@ -7,9 +7,9 @@ import (
7 7
 	"encoding/json"
8 8
 	"errors"
9 9
 
10
-	"github.com/docker/distribution/digest"
11 10
 	"github.com/docker/docker/api/types"
12 11
 	"github.com/docker/docker/layer"
12
+	"github.com/opencontainers/go-digest"
13 13
 )
14 14
 
15 15
 // V2MetadataService maps layer IDs to a set of known metadata for
... ...
@@ -8,8 +8,8 @@ import (
8 8
 	"reflect"
9 9
 	"testing"
10 10
 
11
-	"github.com/docker/distribution/digest"
12 11
 	"github.com/docker/docker/layer"
12
+	"github.com/opencontainers/go-digest"
13 13
 )
14 14
 
15 15
 func TestV2MetadataService(t *testing.T) {
... ...
@@ -5,12 +5,12 @@ import (
5 5
 	"fmt"
6 6
 
7 7
 	"github.com/Sirupsen/logrus"
8
-	"github.com/docker/distribution/digest"
9 8
 	"github.com/docker/docker/api"
10 9
 	"github.com/docker/docker/distribution/metadata"
11 10
 	"github.com/docker/docker/pkg/progress"
12 11
 	"github.com/docker/docker/reference"
13 12
 	"github.com/docker/docker/registry"
13
+	"github.com/opencontainers/go-digest"
14 14
 	"golang.org/x/net/context"
15 15
 )
16 16
 
... ...
@@ -12,7 +12,6 @@ import (
12 12
 
13 13
 	"github.com/Sirupsen/logrus"
14 14
 	"github.com/docker/distribution"
15
-	"github.com/docker/distribution/digest"
16 15
 	"github.com/docker/distribution/manifest/manifestlist"
17 16
 	"github.com/docker/distribution/manifest/schema1"
18 17
 	"github.com/docker/distribution/manifest/schema2"
... ...
@@ -29,6 +28,7 @@ import (
29 29
 	"github.com/docker/docker/pkg/stringid"
30 30
 	"github.com/docker/docker/reference"
31 31
 	"github.com/docker/docker/registry"
32
+	"github.com/opencontainers/go-digest"
32 33
 	"golang.org/x/net/context"
33 34
 )
34 35
 
... ...
@@ -228,10 +228,7 @@ func (ld *v2LayerDescriptor) Download(ctx context.Context, progressOutput progre
228 228
 	defer reader.Close()
229 229
 
230 230
 	if ld.verifier == nil {
231
-		ld.verifier, err = digest.NewDigestVerifier(ld.digest)
232
-		if err != nil {
233
-			return nil, 0, xfer.DoNotRetry{Err: err}
234
-		}
231
+		ld.verifier = ld.digest.Verifier()
235 232
 	}
236 233
 
237 234
 	_, err = io.Copy(tmpFile, io.TeeReader(reader, ld.verifier))
... ...
@@ -716,10 +713,7 @@ func (p *v2Puller) pullSchema2Config(ctx context.Context, dgst digest.Digest) (c
716 716
 	}
717 717
 
718 718
 	// Verify image config digest
719
-	verifier, err := digest.NewDigestVerifier(dgst)
720
-	if err != nil {
721
-		return nil, err
722
-	}
719
+	verifier := dgst.Verifier()
723 720
 	if _, err := verifier.Write(configJSON); err != nil {
724 721
 		return nil, err
725 722
 	}
... ...
@@ -742,10 +736,7 @@ func schema2ManifestDigest(ref reference.Named, mfst distribution.Manifest) (dig
742 742
 
743 743
 	// If pull by digest, then verify the manifest digest.
744 744
 	if digested, isDigested := ref.(reference.Canonical); isDigested {
745
-		verifier, err := digest.NewDigestVerifier(digested.Digest())
746
-		if err != nil {
747
-			return "", err
748
-		}
745
+		verifier := digested.Digest().Verifier()
749 746
 		if _, err := verifier.Write(canonical); err != nil {
750 747
 			return "", err
751 748
 		}
... ...
@@ -798,10 +789,7 @@ func verifySchema1Manifest(signedManifest *schema1.SignedManifest, ref reference
798 798
 	// important to do this first, before any other content validation. If the
799 799
 	// digest cannot be verified, don't even bother with those other things.
800 800
 	if digested, isCanonical := ref.(reference.Canonical); isCanonical {
801
-		verifier, err := digest.NewDigestVerifier(digested.Digest())
802
-		if err != nil {
803
-			return nil, err
804
-		}
801
+		verifier := digested.Digest().Verifier()
805 802
 		if _, err := verifier.Write(signedManifest.Canonical); err != nil {
806 803
 			return nil, err
807 804
 		}
... ...
@@ -8,9 +8,9 @@ import (
8 8
 	"strings"
9 9
 	"testing"
10 10
 
11
-	"github.com/docker/distribution/digest"
12 11
 	"github.com/docker/distribution/manifest/schema1"
13 12
 	"github.com/docker/docker/reference"
13
+	"github.com/opencontainers/go-digest"
14 14
 )
15 15
 
16 16
 // TestFixManifestLayers checks that fixManifestLayers removes a duplicate
... ...
@@ -5,7 +5,6 @@ import (
5 5
 	"sync"
6 6
 
7 7
 	"github.com/Sirupsen/logrus"
8
-	"github.com/docker/distribution/digest"
9 8
 	"github.com/docker/distribution/registry/client/transport"
10 9
 	"github.com/docker/docker/distribution/metadata"
11 10
 	"github.com/docker/docker/dockerversion"
... ...
@@ -17,6 +16,7 @@ import (
17 17
 	"github.com/docker/docker/pkg/stringid"
18 18
 	"github.com/docker/docker/reference"
19 19
 	"github.com/docker/docker/registry"
20
+	"github.com/opencontainers/go-digest"
20 21
 	"golang.org/x/net/context"
21 22
 )
22 23
 
... ...
@@ -13,7 +13,6 @@ import (
13 13
 
14 14
 	"github.com/Sirupsen/logrus"
15 15
 	"github.com/docker/distribution"
16
-	"github.com/docker/distribution/digest"
17 16
 	"github.com/docker/distribution/manifest/schema1"
18 17
 	"github.com/docker/distribution/manifest/schema2"
19 18
 	distreference "github.com/docker/distribution/reference"
... ...
@@ -27,6 +26,7 @@ import (
27 27
 	"github.com/docker/docker/pkg/stringid"
28 28
 	"github.com/docker/docker/reference"
29 29
 	"github.com/docker/docker/registry"
30
+	"github.com/opencontainers/go-digest"
30 31
 )
31 32
 
32 33
 const (
... ...
@@ -435,7 +435,7 @@ func (pd *v2PushDescriptor) uploadUsingSession(
435 435
 		return distribution.Descriptor{}, fmt.Errorf("unsupported layer media type %s", m)
436 436
 	}
437 437
 
438
-	digester := digest.Canonical.New()
438
+	digester := digest.Canonical.Digester()
439 439
 	tee := io.TeeReader(reader, digester.Hash())
440 440
 
441 441
 	nn, err := layerUpload.ReadFrom(tee)
... ...
@@ -7,13 +7,13 @@ import (
7 7
 
8 8
 	"github.com/docker/distribution"
9 9
 	"github.com/docker/distribution/context"
10
-	"github.com/docker/distribution/digest"
11 10
 	"github.com/docker/distribution/manifest/schema2"
12 11
 	distreference "github.com/docker/distribution/reference"
13 12
 	"github.com/docker/docker/distribution/metadata"
14 13
 	"github.com/docker/docker/layer"
15 14
 	"github.com/docker/docker/pkg/progress"
16 15
 	"github.com/docker/docker/reference"
16
+	"github.com/opencontainers/go-digest"
17 17
 )
18 18
 
19 19
 func TestGetRepositoryMountCandidates(t *testing.T) {
... ...
@@ -12,10 +12,10 @@ import (
12 12
 	"time"
13 13
 
14 14
 	"github.com/docker/distribution"
15
-	"github.com/docker/distribution/digest"
16 15
 	"github.com/docker/docker/image"
17 16
 	"github.com/docker/docker/layer"
18 17
 	"github.com/docker/docker/pkg/progress"
18
+	"github.com/opencontainers/go-digest"
19 19
 	"golang.org/x/net/context"
20 20
 )
21 21
 
... ...
@@ -8,8 +8,8 @@ import (
8 8
 	"sync"
9 9
 
10 10
 	"github.com/Sirupsen/logrus"
11
-	"github.com/docker/distribution/digest"
12 11
 	"github.com/docker/docker/pkg/ioutils"
12
+	"github.com/opencontainers/go-digest"
13 13
 )
14 14
 
15 15
 // DigestWalkFunc is function called by StoreBackend.Walk
... ...
@@ -11,7 +11,7 @@ import (
11 11
 	"path/filepath"
12 12
 	"testing"
13 13
 
14
-	"github.com/docker/distribution/digest"
14
+	"github.com/opencontainers/go-digest"
15 15
 )
16 16
 
17 17
 func TestFSGetSet(t *testing.T) {
... ...
@@ -6,8 +6,8 @@ import (
6 6
 	"io"
7 7
 	"time"
8 8
 
9
-	"github.com/docker/distribution/digest"
10 9
 	"github.com/docker/docker/api/types/container"
10
+	"github.com/opencontainers/go-digest"
11 11
 )
12 12
 
13 13
 // ID is the content-addressable ID of an image.
... ...
@@ -7,8 +7,9 @@ import (
7 7
 	"sync"
8 8
 
9 9
 	"github.com/Sirupsen/logrus"
10
-	"github.com/docker/distribution/digest"
10
+	"github.com/docker/distribution/digestset"
11 11
 	"github.com/docker/docker/layer"
12
+	"github.com/opencontainers/go-digest"
12 13
 )
13 14
 
14 15
 // Store is an interface for creating and accessing images
... ...
@@ -40,7 +41,7 @@ type store struct {
40 40
 	ls        LayerGetReleaser
41 41
 	images    map[ID]*imageMeta
42 42
 	fs        StoreBackend
43
-	digestSet *digest.Set
43
+	digestSet *digestset.Set
44 44
 }
45 45
 
46 46
 // NewImageStore returns new store object for given layer store
... ...
@@ -49,7 +50,7 @@ func NewImageStore(fs StoreBackend, ls LayerGetReleaser) (Store, error) {
49 49
 		ls:        ls,
50 50
 		images:    make(map[ID]*imageMeta),
51 51
 		fs:        fs,
52
-		digestSet: digest.NewSet(),
52
+		digestSet: digestset.NewSet(),
53 53
 	}
54 54
 
55 55
 	// load all current images and retain layers
... ...
@@ -170,7 +171,7 @@ func (is *store) Search(term string) (ID, error) {
170 170
 
171 171
 	dgst, err := is.digestSet.Lookup(term)
172 172
 	if err != nil {
173
-		if err == digest.ErrDigestNotFound {
173
+		if err == digestset.ErrDigestNotFound {
174 174
 			err = fmt.Errorf("No such image: %s", term)
175 175
 		}
176 176
 		return "", err
... ...
@@ -5,8 +5,8 @@ import (
5 5
 	"os"
6 6
 	"testing"
7 7
 
8
-	"github.com/docker/distribution/digest"
9 8
 	"github.com/docker/docker/layer"
9
+	"github.com/opencontainers/go-digest"
10 10
 )
11 11
 
12 12
 func TestRestore(t *testing.T) {
... ...
@@ -11,7 +11,6 @@ import (
11 11
 
12 12
 	"github.com/Sirupsen/logrus"
13 13
 	"github.com/docker/distribution"
14
-	"github.com/docker/distribution/digest"
15 14
 	"github.com/docker/docker/image"
16 15
 	"github.com/docker/docker/image/v1"
17 16
 	"github.com/docker/docker/layer"
... ...
@@ -23,6 +22,7 @@ import (
23 23
 	"github.com/docker/docker/pkg/symlink"
24 24
 	"github.com/docker/docker/pkg/system"
25 25
 	"github.com/docker/docker/reference"
26
+	"github.com/opencontainers/go-digest"
26 27
 )
27 28
 
28 29
 func (l *tarexporter) Load(inTar io.ReadCloser, outStream io.Writer, quiet bool) error {
... ...
@@ -10,13 +10,13 @@ import (
10 10
 	"time"
11 11
 
12 12
 	"github.com/docker/distribution"
13
-	"github.com/docker/distribution/digest"
14 13
 	"github.com/docker/docker/image"
15 14
 	"github.com/docker/docker/image/v1"
16 15
 	"github.com/docker/docker/layer"
17 16
 	"github.com/docker/docker/pkg/archive"
18 17
 	"github.com/docker/docker/pkg/system"
19 18
 	"github.com/docker/docker/reference"
19
+	"github.com/opencontainers/go-digest"
20 20
 	"github.com/pkg/errors"
21 21
 )
22 22
 
... ...
@@ -6,11 +6,11 @@ import (
6 6
 	"strings"
7 7
 
8 8
 	"github.com/Sirupsen/logrus"
9
-	"github.com/docker/distribution/digest"
10 9
 	"github.com/docker/docker/api/types/versions"
11 10
 	"github.com/docker/docker/image"
12 11
 	"github.com/docker/docker/layer"
13 12
 	"github.com/docker/docker/pkg/stringid"
13
+	"github.com/opencontainers/go-digest"
14 14
 )
15 15
 
16 16
 // noFallbackMinVersion is the minimum version for which v1compatibility
... ...
@@ -8,13 +8,13 @@ import (
8 8
 	"regexp"
9 9
 	"strings"
10 10
 
11
-	"github.com/docker/distribution/digest"
12 11
 	"github.com/docker/distribution/manifest/schema1"
13 12
 	"github.com/docker/distribution/manifest/schema2"
14 13
 	"github.com/docker/docker/api/types"
15 14
 	"github.com/docker/docker/integration-cli/checker"
16 15
 	"github.com/docker/docker/pkg/stringutils"
17 16
 	"github.com/go-check/check"
17
+	"github.com/opencontainers/go-digest"
18 18
 )
19 19
 
20 20
 var (
... ...
@@ -11,12 +11,12 @@ import (
11 11
 	"strings"
12 12
 
13 13
 	"github.com/docker/distribution"
14
-	"github.com/docker/distribution/digest"
15 14
 	"github.com/docker/distribution/manifest"
16 15
 	"github.com/docker/distribution/manifest/manifestlist"
17 16
 	"github.com/docker/distribution/manifest/schema2"
18 17
 	"github.com/docker/docker/integration-cli/checker"
19 18
 	"github.com/go-check/check"
19
+	"github.com/opencontainers/go-digest"
20 20
 )
21 21
 
22 22
 // testPullImageWithAliases pulls a specific image tag and verifies that any aliases (i.e., other
... ...
@@ -7,9 +7,9 @@ import (
7 7
 	"sync"
8 8
 	"time"
9 9
 
10
-	"github.com/docker/distribution/digest"
11 10
 	"github.com/docker/docker/integration-cli/checker"
12 11
 	"github.com/go-check/check"
12
+	"github.com/opencontainers/go-digest"
13 13
 )
14 14
 
15 15
 // TestPullFromCentralRegistry pulls an image from the central registry and verifies that the client
... ...
@@ -26,7 +26,7 @@ func (s *DockerHubPullSuite) TestPullFromCentralRegistry(c *check.C) {
26 26
 	matches := regexp.MustCompile(`Digest: (.+)\n`).FindAllStringSubmatch(out, -1)
27 27
 	c.Assert(len(matches), checker.Equals, 1, check.Commentf("expected exactly one image digest in the output"))
28 28
 	c.Assert(len(matches[0]), checker.Equals, 2, check.Commentf("unexpected number of submatches for the digest"))
29
-	_, err := digest.ParseDigest(matches[0][1])
29
+	_, err := digest.Parse(matches[0][1])
30 30
 	c.Check(err, checker.IsNil, check.Commentf("invalid digest %q in output", matches[0][1]))
31 31
 
32 32
 	// We should have a single entry in images.
... ...
@@ -13,10 +13,10 @@ import (
13 13
 	"strings"
14 14
 	"time"
15 15
 
16
-	"github.com/docker/distribution/digest"
17 16
 	"github.com/docker/docker/integration-cli/checker"
18 17
 	"github.com/docker/docker/pkg/testutil"
19 18
 	"github.com/go-check/check"
19
+	"github.com/opencontainers/go-digest"
20 20
 )
21 21
 
22 22
 // save a repo using gz compression and try to load it using stdout
... ...
@@ -8,7 +8,7 @@ import (
8 8
 	"os/exec"
9 9
 	"path/filepath"
10 10
 
11
-	"github.com/docker/distribution/digest"
11
+	"github.com/opencontainers/go-digest"
12 12
 )
13 13
 
14 14
 const (
... ...
@@ -4,7 +4,7 @@ import (
4 4
 	"io"
5 5
 	"testing"
6 6
 
7
-	"github.com/docker/distribution/digest"
7
+	"github.com/opencontainers/go-digest"
8 8
 )
9 9
 
10 10
 func TestEmptyLayer(t *testing.T) {
... ...
@@ -33,7 +33,7 @@ func TestEmptyLayer(t *testing.T) {
33 33
 		t.Fatalf("error streaming tar for empty layer: %v", err)
34 34
 	}
35 35
 
36
-	digester := digest.Canonical.New()
36
+	digester := digest.Canonical.Digester()
37 37
 	_, err = io.Copy(digester.Hash(), tarStream)
38 38
 
39 39
 	if err != nil {
... ...
@@ -15,8 +15,8 @@ import (
15 15
 
16 16
 	"github.com/Sirupsen/logrus"
17 17
 	"github.com/docker/distribution"
18
-	"github.com/docker/distribution/digest"
19 18
 	"github.com/docker/docker/pkg/ioutils"
19
+	"github.com/opencontainers/go-digest"
20 20
 )
21 21
 
22 22
 var (
... ...
@@ -165,7 +165,7 @@ func (fms *fileMetadataStore) GetParent(layer ChainID) (ChainID, error) {
165 165
 		return "", err
166 166
 	}
167 167
 
168
-	dgst, err := digest.ParseDigest(strings.TrimSpace(string(content)))
168
+	dgst, err := digest.Parse(strings.TrimSpace(string(content)))
169 169
 	if err != nil {
170 170
 		return "", err
171 171
 	}
... ...
@@ -179,7 +179,7 @@ func (fms *fileMetadataStore) GetDiffID(layer ChainID) (DiffID, error) {
179 179
 		return "", err
180 180
 	}
181 181
 
182
-	dgst, err := digest.ParseDigest(strings.TrimSpace(string(content)))
182
+	dgst, err := digest.Parse(strings.TrimSpace(string(content)))
183 183
 	if err != nil {
184 184
 		return "", err
185 185
 	}
... ...
@@ -296,7 +296,7 @@ func (fms *fileMetadataStore) GetMountParent(mount string) (ChainID, error) {
296 296
 		return "", err
297 297
 	}
298 298
 
299
-	dgst, err := digest.ParseDigest(strings.TrimSpace(string(content)))
299
+	dgst, err := digest.Parse(strings.TrimSpace(string(content)))
300 300
 	if err != nil {
301 301
 		return "", err
302 302
 	}
... ...
@@ -10,7 +10,7 @@ import (
10 10
 	"syscall"
11 11
 	"testing"
12 12
 
13
-	"github.com/docker/distribution/digest"
13
+	"github.com/opencontainers/go-digest"
14 14
 )
15 15
 
16 16
 func randomLayerID(seed int64) ChainID {
... ...
@@ -15,8 +15,8 @@ import (
15 15
 
16 16
 	"github.com/Sirupsen/logrus"
17 17
 	"github.com/docker/distribution"
18
-	"github.com/docker/distribution/digest"
19 18
 	"github.com/docker/docker/pkg/archive"
19
+	"github.com/opencontainers/go-digest"
20 20
 )
21 21
 
22 22
 var (
... ...
@@ -9,11 +9,11 @@ import (
9 9
 
10 10
 	"github.com/Sirupsen/logrus"
11 11
 	"github.com/docker/distribution"
12
-	"github.com/docker/distribution/digest"
13 12
 	"github.com/docker/docker/daemon/graphdriver"
14 13
 	"github.com/docker/docker/pkg/idtools"
15 14
 	"github.com/docker/docker/pkg/plugingetter"
16 15
 	"github.com/docker/docker/pkg/stringid"
16
+	"github.com/opencontainers/go-digest"
17 17
 	"github.com/vbatts/tar-split/tar/asm"
18 18
 	"github.com/vbatts/tar-split/tar/storage"
19 19
 )
... ...
@@ -204,7 +204,7 @@ func (ls *layerStore) loadMount(mount string) error {
204 204
 }
205 205
 
206 206
 func (ls *layerStore) applyTar(tx MetadataTransaction, ts io.Reader, parent string, layer *roLayer) error {
207
-	digester := digest.Canonical.New()
207
+	digester := digest.Canonical.Digester()
208 208
 	tr := io.TeeReader(ts, digester.Hash())
209 209
 
210 210
 	tsw, err := tx.TarSplitWriter(true)
... ...
@@ -10,12 +10,12 @@ import (
10 10
 	"strings"
11 11
 	"testing"
12 12
 
13
-	"github.com/docker/distribution/digest"
14 13
 	"github.com/docker/docker/daemon/graphdriver"
15 14
 	"github.com/docker/docker/daemon/graphdriver/vfs"
16 15
 	"github.com/docker/docker/pkg/archive"
17 16
 	"github.com/docker/docker/pkg/idtools"
18 17
 	"github.com/docker/docker/pkg/stringid"
18
+	"github.com/opencontainers/go-digest"
19 19
 )
20 20
 
21 21
 func init() {
... ...
@@ -5,8 +5,8 @@ import (
5 5
 	"fmt"
6 6
 
7 7
 	"github.com/Sirupsen/logrus"
8
-	"github.com/docker/distribution/digest"
9 8
 	"github.com/docker/docker/daemon/graphdriver"
9
+	"github.com/opencontainers/go-digest"
10 10
 )
11 11
 
12 12
 // GetLayerPath returns the path to a layer
... ...
@@ -8,7 +8,7 @@ import (
8 8
 	"os"
9 9
 
10 10
 	"github.com/Sirupsen/logrus"
11
-	"github.com/docker/distribution/digest"
11
+	"github.com/opencontainers/go-digest"
12 12
 	"github.com/vbatts/tar-split/tar/asm"
13 13
 	"github.com/vbatts/tar-split/tar/storage"
14 14
 )
... ...
@@ -98,7 +98,7 @@ func (ls *layerStore) ChecksumForGraphID(id, parent, oldTarDataPath, newTarDataP
98 98
 		return
99 99
 	}
100 100
 
101
-	dgst := digest.Canonical.New()
101
+	dgst := digest.Canonical.Digester()
102 102
 	err = ls.assembleTarTo(id, uncompressed, &size, dgst.Hash())
103 103
 	if err != nil {
104 104
 		return
... ...
@@ -5,7 +5,7 @@ import (
5 5
 	"io"
6 6
 
7 7
 	"github.com/docker/distribution"
8
-	"github.com/docker/distribution/digest"
8
+	"github.com/opencontainers/go-digest"
9 9
 )
10 10
 
11 11
 type roLayer struct {
... ...
@@ -156,14 +156,10 @@ func storeLayer(tx MetadataTransaction, layer *roLayer) error {
156 156
 }
157 157
 
158 158
 func newVerifiedReadCloser(rc io.ReadCloser, dgst digest.Digest) (io.ReadCloser, error) {
159
-	verifier, err := digest.NewDigestVerifier(dgst)
160
-	if err != nil {
161
-		return nil, err
162
-	}
163 159
 	return &verifiedReadCloser{
164 160
 		rc:       rc,
165 161
 		dgst:     dgst,
166
-		verifier: verifier,
162
+		verifier: dgst.Verifier(),
167 163
 	}, nil
168 164
 }
169 165
 
... ...
@@ -14,13 +14,13 @@ import (
14 14
 	"encoding/json"
15 15
 
16 16
 	"github.com/Sirupsen/logrus"
17
-	"github.com/docker/distribution/digest"
18 17
 	"github.com/docker/docker/distribution/metadata"
19 18
 	"github.com/docker/docker/image"
20 19
 	imagev1 "github.com/docker/docker/image/v1"
21 20
 	"github.com/docker/docker/layer"
22 21
 	"github.com/docker/docker/pkg/ioutils"
23 22
 	"github.com/docker/docker/reference"
23
+	"github.com/opencontainers/go-digest"
24 24
 )
25 25
 
26 26
 type graphIDRegistrar interface {
... ...
@@ -327,7 +327,7 @@ func migrateRefs(root, driverName string, rs refAdder, mappings map[string]image
327 327
 					logrus.Errorf("migrate tags: invalid name %q, %q", name, err)
328 328
 					continue
329 329
 				}
330
-				if dgst, err := digest.ParseDigest(tag); err == nil {
330
+				if dgst, err := digest.Parse(tag); err == nil {
331 331
 					canonical, err := reference.WithDigest(reference.TrimNamed(ref), dgst)
332 332
 					if err != nil {
333 333
 						logrus.Errorf("migrate tags: invalid digest %q, %q", dgst, err)
... ...
@@ -425,7 +425,7 @@ func migrateImage(id, root string, ls graphIDRegistrar, is image.Store, ms metad
425 425
 	if err != nil {
426 426
 		return err
427 427
 	}
428
-	diffID, err := digest.ParseDigest(string(diffIDData))
428
+	diffID, err := digest.Parse(string(diffIDData))
429 429
 	if err != nil {
430 430
 		return err
431 431
 	}
... ...
@@ -477,7 +477,7 @@ func migrateImage(id, root string, ls graphIDRegistrar, is image.Store, ms metad
477 477
 
478 478
 	checksum, err := ioutil.ReadFile(filepath.Join(root, graphDirName, id, "checksum"))
479 479
 	if err == nil { // best effort
480
-		dgst, err := digest.ParseDigest(string(checksum))
480
+		dgst, err := digest.Parse(string(checksum))
481 481
 		if err == nil {
482 482
 			V2MetadataService := metadata.NewV2MetadataService(ms)
483 483
 			V2MetadataService.Add(layer.DiffID(), metadata.V2Metadata{Digest: dgst})
... ...
@@ -13,11 +13,11 @@ import (
13 13
 	"runtime"
14 14
 	"testing"
15 15
 
16
-	"github.com/docker/distribution/digest"
17 16
 	"github.com/docker/docker/distribution/metadata"
18 17
 	"github.com/docker/docker/image"
19 18
 	"github.com/docker/docker/layer"
20 19
 	"github.com/docker/docker/reference"
20
+	"github.com/opencontainers/go-digest"
21 21
 )
22 22
 
23 23
 func TestMigrateRefs(t *testing.T) {
... ...
@@ -16,7 +16,6 @@ import (
16 16
 	"strings"
17 17
 
18 18
 	"github.com/Sirupsen/logrus"
19
-	"github.com/docker/distribution/digest"
20 19
 	"github.com/docker/distribution/manifest/schema2"
21 20
 	"github.com/docker/docker/api/types"
22 21
 	"github.com/docker/docker/distribution"
... ...
@@ -29,6 +28,7 @@ import (
29 29
 	"github.com/docker/docker/pkg/progress"
30 30
 	"github.com/docker/docker/plugin/v2"
31 31
 	"github.com/docker/docker/reference"
32
+	"github.com/opencontainers/go-digest"
32 33
 	"github.com/pkg/errors"
33 34
 	"golang.org/x/net/context"
34 35
 )
... ...
@@ -123,7 +123,7 @@ func (s *tempConfigStore) Put(c []byte) (digest.Digest, error) {
123 123
 
124 124
 func (s *tempConfigStore) Get(d digest.Digest) ([]byte, error) {
125 125
 	if d != s.configDigest {
126
-		return nil, digest.ErrDigestNotFound
126
+		return nil, fmt.Errorf("digest not found")
127 127
 	}
128 128
 	return s.config, nil
129 129
 }
... ...
@@ -556,7 +556,7 @@ func (pm *Manager) CreateFromContext(ctx context.Context, tarCtx io.ReadCloser,
556 556
 	}
557 557
 	defer rootFSBlob.Close()
558 558
 	gzw := gzip.NewWriter(rootFSBlob)
559
-	layerDigester := digest.Canonical.New()
559
+	layerDigester := digest.Canonical.Digester()
560 560
 	rootFSReader := io.TeeReader(rootFS, io.MultiWriter(gzw, layerDigester.Hash()))
561 561
 
562 562
 	if err := chrootarchive.Untar(rootFSReader, tmpRootFSDir, nil); err != nil {
... ...
@@ -1,18 +1,19 @@
1 1
 package plugin
2 2
 
3 3
 import (
4
+	"fmt"
4 5
 	"io"
5 6
 	"io/ioutil"
6 7
 	"os"
7 8
 	"path/filepath"
8 9
 
9 10
 	"github.com/Sirupsen/logrus"
10
-	"github.com/docker/distribution/digest"
11 11
 	"github.com/docker/docker/distribution/xfer"
12 12
 	"github.com/docker/docker/image"
13 13
 	"github.com/docker/docker/layer"
14 14
 	"github.com/docker/docker/pkg/archive"
15 15
 	"github.com/docker/docker/pkg/progress"
16
+	"github.com/opencontainers/go-digest"
16 17
 	"github.com/pkg/errors"
17 18
 	"golang.org/x/net/context"
18 19
 )
... ...
@@ -86,7 +87,7 @@ type insertion struct {
86 86
 }
87 87
 
88 88
 func newInsertion(tempFile *os.File) *insertion {
89
-	digester := digest.Canonical.New()
89
+	digester := digest.Canonical.Digester()
90 90
 	return &insertion{f: tempFile, digester: digester, Writer: io.MultiWriter(tempFile, digester.Hash())}
91 91
 }
92 92
 
... ...
@@ -141,7 +142,7 @@ func (dm *downloadManager) Download(ctx context.Context, initialRootFS image.Roo
141 141
 		if err != nil {
142 142
 			return initialRootFS, nil, err
143 143
 		}
144
-		digester := digest.Canonical.New()
144
+		digester := digest.Canonical.Digester()
145 145
 		if _, err := archive.ApplyLayer(dm.tmpDir, io.TeeReader(inflatedLayerData, digester.Hash())); err != nil {
146 146
 			return initialRootFS, nil, err
147 147
 		}
... ...
@@ -174,7 +175,7 @@ func (dm *downloadManager) Put(dt []byte) (digest.Digest, error) {
174 174
 }
175 175
 
176 176
 func (dm *downloadManager) Get(d digest.Digest) ([]byte, error) {
177
-	return nil, digest.ErrDigestNotFound
177
+	return nil, fmt.Errorf("digest not found")
178 178
 }
179 179
 func (dm *downloadManager) RootFSFromConfig(c []byte) (*image.RootFS, error) {
180 180
 	return configToRootFS(c)
... ...
@@ -12,7 +12,6 @@ import (
12 12
 	"sync"
13 13
 
14 14
 	"github.com/Sirupsen/logrus"
15
-	"github.com/docker/distribution/digest"
16 15
 	"github.com/docker/docker/api/types"
17 16
 	"github.com/docker/docker/image"
18 17
 	"github.com/docker/docker/layer"
... ...
@@ -22,6 +21,7 @@ import (
22 22
 	"github.com/docker/docker/plugin/v2"
23 23
 	"github.com/docker/docker/reference"
24 24
 	"github.com/docker/docker/registry"
25
+	"github.com/opencontainers/go-digest"
25 26
 	"github.com/pkg/errors"
26 27
 )
27 28
 
... ...
@@ -11,7 +11,6 @@ import (
11 11
 	"time"
12 12
 
13 13
 	"github.com/Sirupsen/logrus"
14
-	"github.com/docker/distribution/digest"
15 14
 	"github.com/docker/docker/api/types"
16 15
 	"github.com/docker/docker/daemon/initlayer"
17 16
 	"github.com/docker/docker/libcontainerd"
... ...
@@ -19,6 +18,7 @@ import (
19 19
 	"github.com/docker/docker/pkg/plugins"
20 20
 	"github.com/docker/docker/pkg/stringid"
21 21
 	"github.com/docker/docker/plugin/v2"
22
+	"github.com/opencontainers/go-digest"
22 23
 	specs "github.com/opencontainers/runtime-spec/specs-go"
23 24
 	"github.com/pkg/errors"
24 25
 )
... ...
@@ -5,10 +5,10 @@ import (
5 5
 	"strings"
6 6
 	"sync"
7 7
 
8
-	"github.com/docker/distribution/digest"
9 8
 	"github.com/docker/docker/api/types"
10 9
 	"github.com/docker/docker/pkg/plugingetter"
11 10
 	"github.com/docker/docker/pkg/plugins"
11
+	"github.com/opencontainers/go-digest"
12 12
 )
13 13
 
14 14
 // Plugin represents an individual plugin.
... ...
@@ -5,9 +5,9 @@ import (
5 5
 	"fmt"
6 6
 	"strings"
7 7
 
8
-	"github.com/docker/distribution/digest"
9 8
 	distreference "github.com/docker/distribution/reference"
10 9
 	"github.com/docker/docker/pkg/stringid"
10
+	"github.com/opencontainers/go-digest"
11 11
 )
12 12
 
13 13
 const (
... ...
@@ -166,7 +166,7 @@ func ParseIDOrReference(idOrRef string) (digest.Digest, Named, error) {
166 166
 	if err := stringid.ValidateID(idOrRef); err == nil {
167 167
 		idOrRef = "sha256:" + idOrRef
168 168
 	}
169
-	if dgst, err := digest.ParseDigest(idOrRef); err == nil {
169
+	if dgst, err := digest.Parse(idOrRef); err == nil {
170 170
 		return dgst, nil, nil
171 171
 	}
172 172
 	ref, err := ParseNamed(idOrRef)
... ...
@@ -3,7 +3,7 @@ package reference
3 3
 import (
4 4
 	"testing"
5 5
 
6
-	"github.com/docker/distribution/digest"
6
+	"github.com/opencontainers/go-digest"
7 7
 )
8 8
 
9 9
 func TestValidateReferenceName(t *testing.T) {
... ...
@@ -9,8 +9,8 @@ import (
9 9
 	"sort"
10 10
 	"sync"
11 11
 
12
-	"github.com/docker/distribution/digest"
13 12
 	"github.com/docker/docker/pkg/ioutils"
13
+	"github.com/opencontainers/go-digest"
14 14
 )
15 15
 
16 16
 var (
... ...
@@ -8,7 +8,7 @@ import (
8 8
 	"strings"
9 9
 	"testing"
10 10
 
11
-	"github.com/docker/distribution/digest"
11
+	"github.com/opencontainers/go-digest"
12 12
 )
13 13
 
14 14
 var (