Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion image/docker/daemon/daemon_transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func testParseReference(t *testing.T, fn func(string) (types.ImageReference, err
daemonRef, ok := ref.(daemonReference)
require.True(t, ok, c.input)
// If we don't reject the input, the interpretation must be consistent with reference.ParseAnyReference
dockerRef, err := reference.ParseAnyReference(c.input)
dockerRef, err := reference.ParseAnyReference(c.input) //nolint:staticcheck // "reference.ParseAnyReference is deprecated" — this is explicitly a check of consistency with that function’s behavior.
require.NoError(t, err, c.input)

if c.expectedRef == "" {
Expand Down
11 changes: 11 additions & 0 deletions image/docker/reference/normalize.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,17 @@ func TagNameOnly(ref Named) Named {

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