From 8657c87c8cafca2740db7e0bbceba3ceb27ea550 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= Date: Tue, 21 Feb 2023 17:18:19 +0100 Subject: [PATCH] c8d/tag: Don't create a separate error variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Checking if the image creation failed due to IsAlreadyExists didn't use the error from ImageService.Create. Error from ImageService.Create was stored in a separate variable and later IsAlreadyExists checked the standard `err` variable instead of the `createErr`. As there's no need to store the error in a separate variable - just assign it to err variable and fix the check. Signed-off-by: Paweł Gronowski --- daemon/containerd/image_tag.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/daemon/containerd/image_tag.go b/daemon/containerd/image_tag.go index b59b3903fa..eab9107dcc 100644 --- a/daemon/containerd/image_tag.go +++ b/daemon/containerd/image_tag.go @@ -25,8 +25,8 @@ func (i *ImageService) TagImage(ctx context.Context, imageID image.ID, newTag re } is := i.client.ImageService() - _, createErr := is.Create(ctx, newImg) - if createErr != nil { + _, err = is.Create(ctx, newImg) + if err != nil { if !cerrdefs.IsAlreadyExists(err) { return errdefs.System(errors.Wrapf(err, "failed to create image with name %s and target %s", newImg.Name, newImg.Target.Digest.String())) }