Skip to content

Commit

Permalink
Add Untag() to oci.Store.
Browse files Browse the repository at this point in the history
Signed-off-by: Francis Laniel <[email protected]>
  • Loading branch information
eiffel-fl committed Nov 21, 2023
1 parent 79a08b4 commit 6f7761e
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions content/oci/oci.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,38 @@ func (s *Store) Resolve(ctx context.Context, reference string) (ocispec.Descript
return desc, nil
}

func (s *Store) Untag(ctx context.Context, reference string) error {
s.sync.RLock()
defer s.sync.RUnlock()

if reference == "" {
return errdef.ErrMissingReference
}

// attempt resolving manifest
_, err := s.tagResolver.Resolve(ctx, reference)
if err != nil {
if errors.Is(err, errdef.ErrNotFound) {
// attempt resolving blob
_, err := resolveBlob(os.DirFS(s.root), reference)
if err != nil {
return err
}
}
return err
}

return s.untag(reference)
}

func (s *Store) untag(reference string) error {
s.tagResolver.Untag(reference)
if s.AutoSaveIndex {
return s.saveIndex()
}
return nil
}

// Predecessors returns the nodes directly pointing to the current node.
// Predecessors returns nil without error if the node does not exists in the
// store.
Expand Down

0 comments on commit 6f7761e

Please sign in to comment.