daemon/containerd: ImageService.resolveImage: cleanup resolve by name:tag

- scope variables locally to the if/else if
- use if/else if to try to make it more clear it's a "best effort" before
  falling through to other ways of resolving the image reference
- remove outdated TODO, now that containerd errdefs can be used for either
  moby, or containerd error definitions.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2025-06-10 13:13:44 +02:00
parent 13879e7b49
commit 2bbf5f5a39

View File

@@ -166,15 +166,12 @@ func (i *ImageService) resolveImage(ctx context.Context, refOrID string) (c8dima
return imgs[0], nil
}
// Try resolve by name:tag
ref := reference.TagNameOnly(parsed.(reference.Named)).String()
img, err := i.images.Get(ctx, ref)
if err == nil {
if img, err := i.images.Get(ctx, ref); err == nil {
return img, nil
} else {
// TODO(containerd): error translation can use common function
if !cerrdefs.IsNotFound(err) {
return c8dimages.Image{}, err
}
} else if !cerrdefs.IsNotFound(err) {
return c8dimages.Image{}, err
}
// If the identifier could be a short ID, attempt to match.