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

feat: support deletion for memory resolver #607

Merged
merged 3 commits into from
Oct 2, 2023
Merged
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
5 changes: 5 additions & 0 deletions internal/resolver/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ func (m *Memory) Tag(_ context.Context, desc ocispec.Descriptor, reference strin
return nil
}

// Untag removes a reference from index map.
func (m *Memory) Untag(reference string) {
m.index.Delete(reference)
}

// Map dumps the memory into a built-in map structure.
// Like other operations, calling Map() is go-routine safe. However, it does not
// necessarily correspond to any consistent snapshot of the storage contents.
Expand Down
9 changes: 9 additions & 0 deletions internal/resolver/memory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ func TestMemorySuccess(t *testing.T) {
if got := len(s.Map()); got != 1 {
t.Errorf("Memory.Map() = %v, want %v", got, 1)
}

s.Untag(ref)
_, err = s.Resolve(ctx, ref)
if !errors.Is(err, errdef.ErrNotFound) {
t.Errorf("Memory.Resolve() error = %v, want %v", err, errdef.ErrNotFound)
}
if got := len(s.Map()); got != 0 {
t.Errorf("Memory.Map() = %v, want %v", got, 0)
}
}

func TestMemoryNotFound(t *testing.T) {
Expand Down
Loading