From e0286a7de0d85c4e3cf165ec34e00ce0032a1a8d Mon Sep 17 00:00:00 2001 From: Derek McGowan Date: Mon, 9 Jan 2017 15:44:13 -0800 Subject: [PATCH] Use go-digest package Signed-off-by: Derek McGowan (github: dmcgowan) --- reference/normalize.go | 9 +++++---- reference/normalize_test.go | 5 +++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/reference/normalize.go b/reference/normalize.go index 7fc6382b..7af0aa76 100644 --- a/reference/normalize.go +++ b/reference/normalize.go @@ -5,7 +5,8 @@ import ( "fmt" "strings" - "github.com/docker/distribution/digest" + "github.com/docker/distribution/digestset" + "github.com/opencontainers/go-digest" ) var ( @@ -142,7 +143,7 @@ func ParseAnyReference(ref string) (Reference, error) { if ok := anchoredIdentifierRegexp.MatchString(ref); ok { return digestReference("sha256:" + ref), nil } - if dgst, err := digest.ParseDigest(ref); err == nil { + if dgst, err := digest.Parse(ref); err == nil { return digestReference(dgst), nil } @@ -151,14 +152,14 @@ func ParseAnyReference(ref string) (Reference, error) { // ParseAnyReferenceWithSet parses a reference string as a possible short // identifier to be matched in a digest set, a full digest, or familiar name. -func ParseAnyReferenceWithSet(ref string, ds *digest.Set) (Reference, error) { +func ParseAnyReferenceWithSet(ref string, ds *digestset.Set) (Reference, error) { if ok := anchoredShortIdentifierRegexp.MatchString(ref); ok { dgst, err := ds.Lookup(ref) if err == nil { return digestReference(dgst), nil } } else { - if dgst, err := digest.ParseDigest(ref); err == nil { + if dgst, err := digest.Parse(ref); err == nil { return digestReference(dgst), nil } } diff --git a/reference/normalize_test.go b/reference/normalize_test.go index f4e09b04..baed3790 100644 --- a/reference/normalize_test.go +++ b/reference/normalize_test.go @@ -3,7 +3,8 @@ package reference import ( "testing" - "github.com/docker/distribution/digest" + "github.com/docker/distribution/digestset" + "github.com/opencontainers/go-digest" ) func TestValidateReferenceName(t *testing.T) { @@ -410,7 +411,7 @@ func TestParseAnyReference(t *testing.T) { if len(tcase.Digests) == 0 { ref, err = ParseAnyReference(tcase.Reference) } else { - ds := digest.NewSet() + ds := digestset.NewSet() for _, dgst := range tcase.Digests { if err := ds.Add(dgst); err != nil { t.Fatalf("Error adding digest %s: %v", dgst.String(), err)