The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/7475

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
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.ekanay...@canonical.com>
From ee0e23fa614c23d6cd5ebde75e2533c7af4be1a7 Mon Sep 17 00:00:00 2001
From: Free Ekanayaka <free.ekanay...@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.ekanay...@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
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to