[lxc-devel] [lxd/master] Fix regression in GetImageFromAnyProject
freeekanayaka on Github
lxc-bot at linuxcontainers.org
Mon Jun 1 14:42:04 UTC 2020
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 504 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200601/adbe5b8f/attachment.bin>
-------------- next part --------------
From ee0e23fa614c23d6cd5ebde75e2533c7af4be1a7 Mon Sep 17 00:00:00 2001
From: Free Ekanayaka <free.ekanayaka at canonical.com>
Date: Mon, 1 Jun 2020 15:40:32 +0100
Subject: [PATCH] Fix regression in GetImageFromAnyProject
The function was failing when more than one image was matching, although that's
expected in case multiple projects have it.
Fixes #7474
Signed-off-by: Free Ekanayaka <free.ekanayaka at canonical.com>
---
lxd/db/images.go | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/lxd/db/images.go b/lxd/db/images.go
index 712f94218f..0240be9dcd 100644
--- a/lxd/db/images.go
+++ b/lxd/db/images.go
@@ -536,10 +536,8 @@ func (c *Cluster) GetImageFromAnyProject(fingerprint string) (int, *api.Image, e
switch len(images) {
case 0:
return ErrNoSuchObject
- case 1:
- object = images[0]
default:
- return fmt.Errorf("More than one image matches")
+ object = images[0]
}
image.Fingerprint = object.Fingerprint
@@ -560,7 +558,7 @@ func (c *Cluster) GetImageFromAnyProject(fingerprint string) (int, *api.Image, e
return nil
})
if err != nil {
- return -1, nil, errors.Wrapf(err, "Fill image details")
+ return -1, nil, errors.Wrapf(err, "Get image %q", fingerprint)
}
return object.ID, &image, nil
More information about the lxc-devel
mailing list