Skip to content

Commit

Permalink
ociindex: add utility method for getting a single manifest from the i…
Browse files Browse the repository at this point in the history
…ndex

Signed-off-by: Justin Chadwell <[email protected]>
  • Loading branch information
jedevc committed Dec 14, 2022
1 parent 49c2275 commit 9623017
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions client/ociindex/ociindex.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,18 @@ func (s StoreIndex) Get(tag string) (*ocispecs.Descriptor, error) {
return nil, nil
}

func (s StoreIndex) GetSingle() (*ocispecs.Descriptor, error) {
idx, err := s.Read()
if err != nil {
return nil, err
}

if len(idx.Manifests) == 1 {
return &idx.Manifests[0], nil
}
return nil, nil
}

// insertDesc puts desc to index with tag.
// Existing manifests with the same tag will be removed from the index.
func insertDesc(index *ocispecs.Index, desc ocispecs.Descriptor, tag string) error {
Expand Down

0 comments on commit 9623017

Please sign in to comment.