- 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>
| ... | ... |
@@ -166,15 +166,12 @@ func (i *ImageService) resolveImage(ctx context.Context, refOrID string) (c8dima |
| 166 | 166 |
return imgs[0], nil |
| 167 | 167 |
} |
| 168 | 168 |
|
| 169 |
+ // Try resolve by name:tag |
|
| 169 | 170 |
ref := reference.TagNameOnly(parsed.(reference.Named)).String() |
| 170 |
- img, err := i.images.Get(ctx, ref) |
|
| 171 |
- if err == nil {
|
|
| 171 |
+ if img, err := i.images.Get(ctx, ref); err == nil {
|
|
| 172 | 172 |
return img, nil |
| 173 |
- } else {
|
|
| 174 |
- // TODO(containerd): error translation can use common function |
|
| 175 |
- if !cerrdefs.IsNotFound(err) {
|
|
| 176 |
- return c8dimages.Image{}, err
|
|
| 177 |
- } |
|
| 173 |
+ } else if !cerrdefs.IsNotFound(err) {
|
|
| 174 |
+ return c8dimages.Image{}, err
|
|
| 178 | 175 |
} |
| 179 | 176 |
|
| 180 | 177 |
// If the identifier could be a short ID, attempt to match. |