Skip to content

Commit 1f8bcbe

Browse files
authored
Merge pull request #508 from mtrmac/ParseAnyReference
Deprecate reference.ParseAnyReference
2 parents 63be353 + ad8a7c4 commit 1f8bcbe

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

image/docker/daemon/daemon_transport_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func testParseReference(t *testing.T, fn func(string) (types.ImageReference, err
7575
daemonRef, ok := ref.(daemonReference)
7676
require.True(t, ok, c.input)
7777
// If we don't reject the input, the interpretation must be consistent with reference.ParseAnyReference
78-
dockerRef, err := reference.ParseAnyReference(c.input)
78+
dockerRef, err := reference.ParseAnyReference(c.input) //nolint:staticcheck // "reference.ParseAnyReference is deprecated" — this is explicitly a check of consistency with that function’s behavior.
7979
require.NoError(t, err, c.input)
8080

8181
if c.expectedRef == "" {

image/docker/reference/normalize.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,17 @@ func TagNameOnly(ref Named) Named {
169169

170170
// ParseAnyReference parses a reference string as a possible identifier,
171171
// full digest, or familiar name.
172+
//
173+
// Deprecated: This parses inputs with 64 hexadecimal characters as sha256 digests,
174+
// and that can’t be generalized (a digest algorithm can not be determined purely
175+
// from the length of the input).
176+
//
177+
// In the future, image IDs will either stay 256-bit, but will not be SHA-256 values;
178+
// or they will support arbitrary algorithms, in which case the hexadecimal-only syntax
179+
// is not sufficient. Either way, this function will not be fit for purpose.
180+
//
181+
// Callers (if any) should redesign their syntax to strictly differentiate between
182+
// image IDs (with an as-yet-unknown future syntax) and named image references.
172183
func ParseAnyReference(ref string) (Reference, error) {
173184
if ok := anchoredIdentifierRegexp.MatchString(ref); ok {
174185
return digestReference("sha256:" + ref), nil

0 commit comments

Comments
 (0)