Add delete target to image remove

Adds atomicity to image delete when deleting from a list.

Signed-off-by: Derek McGowan <derek@mcg.dev>
This commit is contained in:
Derek McGowan
2023-08-18 16:04:09 -07:00
parent f8fb2dad39
commit 2ce971d890
5 changed files with 128 additions and 38 deletions

View File

@@ -58,6 +58,7 @@ type Image struct {
// DeleteOptions provide options on image delete
type DeleteOptions struct {
Synchronous bool
Target *ocispec.Descriptor
}
// DeleteOpt allows configuring a delete operation
@@ -72,6 +73,16 @@ func SynchronousDelete() DeleteOpt {
}
}
// DeleteTarget is used to specify the target value an image is expected
// to have when deleting. If the image has a different target, then
// NotFound is returned.
func DeleteTarget(target *ocispec.Descriptor) DeleteOpt {
return func(ctx context.Context, o *DeleteOptions) error {
o.Target = target
return nil
}
}
// Store and interact with images
type Store interface {
Get(ctx context.Context, name string) (Image, error)