Selaa lähdekoodia

c8d/tag: Don't create a separate error variable

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 <pawel.gronowski@docker.com>
Paweł Gronowski 2 vuotta sitten
vanhempi
commit
8657c87c8c
1 muutettua tiedostoa jossa 2 lisäystä ja 2 poistoa
  1. 2 2
      daemon/containerd/image_tag.go

+ 2 - 2
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()))
 		}