Send an event when an image is deleted
Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
This commit is contained in:
parent
36d28b73fc
commit
1b178dffa3
1 changed files with 10 additions and 1 deletions
|
@ -45,7 +45,7 @@ import (
|
|||
// TODO(thaJeztah): implement ImageDelete "force" options; see https://github.com/moby/moby/issues/43850
|
||||
// TODO(thaJeztah): implement ImageDelete "prune" options; see https://github.com/moby/moby/issues/43849
|
||||
// TODO(thaJeztah): add support for image delete using image (short)ID; see https://github.com/moby/moby/issues/43854
|
||||
// TODO(thaJeztah): mage delete should send image "untag" events and prometheus counters; see https://github.com/moby/moby/issues/43855
|
||||
// TODO(thaJeztah): image delete should send prometheus counters; see https://github.com/moby/moby/issues/45268
|
||||
func (i *ImageService) ImageDelete(ctx context.Context, imageRef string, force, prune bool) ([]types.ImageDeleteResponseItem, error) {
|
||||
parsedRef, err := reference.ParseNormalizedNamed(imageRef)
|
||||
if err != nil {
|
||||
|
@ -53,10 +53,19 @@ func (i *ImageService) ImageDelete(ctx context.Context, imageRef string, force,
|
|||
}
|
||||
ref := reference.TagNameOnly(parsedRef)
|
||||
|
||||
desc, err := i.resolveDescriptor(ctx, imageRef)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
imgID := string(desc.Digest)
|
||||
err = i.client.ImageService().Delete(ctx, ref.String(), images.SynchronousDelete())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
i.LogImageEvent(imgID, imgID, "untag")
|
||||
i.LogImageEvent(imgID, imgID, "delete")
|
||||
|
||||
return []types.ImageDeleteResponseItem{{Untagged: reference.FamiliarString(parsedRef)}}, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue