Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add note about parsing images with digest #12

Closed
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
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions reference.go
Original file line number Diff line number Diff line change
@@ -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]
//
Comment on lines +4 to +6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should make this a separate section below the Grammar; we could borrow some of the wording from https://pkg.go.dev/github.com/opencontainers/go-digest#readme-usage

Might also be good to include this information in GoDoc for individual functions to describe their behavior.

// Grammar
//
// reference := name [ ":" tag ] [ "@" digest ]
Expand Down
Loading