digest: remove stuttering ParseDigest function

Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
Stephen J Day 2016-12-15 14:58:54 -08:00
parent ad80b3d492
commit d5cc235c48
No known key found for this signature in database
GPG key ID: FB5F6B2905D7ECF3
3 changed files with 9 additions and 5 deletions

View file

@ -63,12 +63,16 @@ var (
// ParseDigest parses s and returns the validated digest object. An error will // ParseDigest parses s and returns the validated digest object. An error will
// be returned if the format is invalid. // be returned if the format is invalid.
func ParseDigest(s string) (Digest, error) { func Parse(s string) (Digest, error) {
d := Digest(s) d := Digest(s)
return d, d.Validate() return d, d.Validate()
} }
// ParseDigest is deprecated. Use Parse.
func ParseDigest(s string) (Digest, error) {
return Parse(s)
}
// FromReader returns the most valid digest for the underlying content using // FromReader returns the most valid digest for the underlying content using
// the canonical digest algorithm. // the canonical digest algorithm.
func FromReader(rd io.Reader) (Digest, error) { func FromReader(rd io.Reader) (Digest, error) {

View file

@ -51,7 +51,7 @@ func TestParseDigest(t *testing.T) {
err: ErrDigestUnsupported, err: ErrDigestUnsupported,
}, },
} { } {
digest, err := ParseDigest(testcase.input) digest, err := Parse(testcase.input)
if err != testcase.err { if err != testcase.err {
t.Fatalf("error differed from expected while parsing %q: %v != %v", testcase.input, err, testcase.err) t.Fatalf("error differed from expected while parsing %q: %v != %v", testcase.input, err, testcase.err)
} }
@ -69,7 +69,7 @@ func TestParseDigest(t *testing.T) {
} }
// Parse string return value and check equality // Parse string return value and check equality
newParsed, err := ParseDigest(digest.String()) newParsed, err := Parse(digest.String())
if err != nil { if err != nil {
t.Fatalf("unexpected error parsing input %q: %v", testcase.input, err) t.Fatalf("unexpected error parsing input %q: %v", testcase.input, err)

View file

@ -75,7 +75,7 @@ func (dst *Set) Lookup(d string) (Digest, error) {
alg Algorithm alg Algorithm
hex string hex string
) )
dgst, err := ParseDigest(d) dgst, err := Parse(d)
if err == ErrDigestInvalidFormat { if err == ErrDigestInvalidFormat {
hex = d hex = d
searchFunc = func(i int) bool { searchFunc = func(i int) bool {