c8d/softDelete: Deep copy Labels
So we don't override the original Labels in the passed image object.
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
(cherry picked from commit a6d5db3f9b
)
Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
This commit is contained in:
parent
8afe75ffa9
commit
8bf037b246
1 changed files with 9 additions and 2 deletions
|
@ -53,9 +53,16 @@ func (i *ImageService) softImageDelete(ctx context.Context, img containerdimages
|
|||
func (i *ImageService) ensureDanglingImage(ctx context.Context, from containerdimages.Image) error {
|
||||
danglingImage := from
|
||||
|
||||
danglingImage.Labels = make(map[string]string)
|
||||
for k, v := range from.Labels {
|
||||
switch k {
|
||||
case containerdimages.AnnotationImageName, ocispec.AnnotationRefName:
|
||||
// Don't copy name labels.
|
||||
default:
|
||||
danglingImage.Labels[k] = v
|
||||
}
|
||||
}
|
||||
danglingImage.Name = danglingImageName(from.Target.Digest)
|
||||
delete(danglingImage.Labels, containerdimages.AnnotationImageName)
|
||||
delete(danglingImage.Labels, ocispec.AnnotationRefName)
|
||||
|
||||
_, err := i.client.ImageService().Create(context.Background(), danglingImage)
|
||||
// If it already exists, then just continue.
|
||||
|
|
Loading…
Reference in a new issue