[lxc-devel] [lxd/master] client/lxd_images: Fix backward compatibility

stgraber on Github lxc-bot at linuxcontainers.org
Thu May 7 19:26:22 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 370 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200507/1c9bec2b/attachment.bin>
-------------- next part --------------
From a4f73777b23e2b56349d38e2c1a0d7cfb9e053db Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Thu, 7 May 2020 15:25:30 -0400
Subject: [PATCH] client/lxd_images: Fix backward compatibility
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #7308

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 client/lxd_images.go | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/client/lxd_images.go b/client/lxd_images.go
index 453bb624c3..0203b0ebbf 100644
--- a/client/lxd_images.go
+++ b/client/lxd_images.go
@@ -326,8 +326,14 @@ func (r *ProtocolLXD) GetImageAliasType(imageType string, name string) (*api.Ima
 		return nil, "", err
 	}
 
-	if imageType != "" && alias.Type != imageType {
-		return nil, "", fmt.Errorf("Alias doesn't exist for the specified type")
+	if imageType != "" {
+		if alias.Type == "" {
+			alias.Type = "container"
+		}
+
+		if alias.Type != imageType {
+			return nil, "", fmt.Errorf("Alias doesn't exist for the specified type")
+		}
 	}
 
 	return alias, etag, nil


More information about the lxc-devel mailing list