From 7378ee13c1f73118185ea7c9f7c6a86ca0c2ea50 Mon Sep 17 00:00:00 2001 From: AbdelrahmanElawady Date: Wed, 8 May 2024 18:45:54 +0300 Subject: [PATCH] Add note about parsing images with digest Signed-off-by: AbdelrahmanElawady --- README.md | 11 +++++++++++ reference.go | 3 +++ 2 files changed, 14 insertions(+) diff --git a/README.md b/README.md index 172a02e..e4dd052 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,17 @@ Go library to handle references to container images. This repository contains a library for handling references to container images held in container registries. Please see [godoc](https://pkg.go.dev/github.com/distribution/reference) for details. +## Usage + +Make sure to import hash implementation when parsing images with digest in a non-test file. For example: + +```go +import ( + _ "crypto/sha256" + _ "crypto/sha512" +) +``` + ## Contribution Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute diff --git a/reference.go b/reference.go index 900398b..e35e198 100644 --- a/reference.go +++ b/reference.go @@ -1,6 +1,9 @@ // Package reference provides a general type to represent any way of referencing images within the registry. // Its main purpose is to abstract tags and digests (content-addressable hash). // +// Note: Hash implementation packages must be imported in order +// for digest parsing to work. Example package for sha256: [crypto/sha256] +// // Grammar // // reference := name [ ":" tag ] [ "@" digest ]