google / google/go-containerregistry
Ability to get root index or manifest of an image from v1/layout
- Dominant language
- Go
- Stars
- 4k
- Forks
- 686
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 26
Description
When I want to get the root ImageIndex or Image from a remote registry, I can call `remote.Get`. At that point, with an `Image` or `ImageIndex`, I can do whatever I need.
If the image already is downloaded to a path using v1/layout, I have to do some processing to get the same root, based on the `index.json`.
I would like an ability to get the root by a matcher, so I can do `Path.Get(someArg)` and get back either an `Image` or an `ImageIndex`, and then follow the rest of the `Path` flow just like with `remote`.
However, unlike `remote.Get()`, the possible inputs are more than just a tag->hash. It could be anything in a descriptor, since the entry in `index.json` is a list of manifests, each of which is a full `Descriptor`.
The simplest I could come up with was:
```go
type Matcher func(desc Descriptor) bool
func (p Path) FindIndex(m Matcher) (ImageIndex, error) { }
func (p Path) FindImage(m Matcher) (Image, error) { }
```
The caller provides a function that either matches or does not match the descriptor, and returns a bool. The `FindIndex`/`FindImage` then can find the right blob, process it, and return the `ImageIndex`/`Image`/.
A slightly simpler interface - one that more closely hews to `remote.Get()` and may allow code reuse, would be:
```go
type Matcher func(desc Descriptor) bool
func (p Path) Find(m Matcher) (*v1.Descriptor, error) { }
```
Happy to submit a PR once design is agreed.
As discussed offline with @jonjohnsonjr
Contributor guide
Research direction
Start by reading the v1/layout Path flow, the index.json descriptor entries, and the existing remote.Get entry point. Resolve the Matcher, Find, FindIndex, and FindImage API design, then verify that a selected descriptor can yield the corresponding root Image or ImageIndex and continue through the existing Path flow.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100