[lxc-devel] [lxd/master] Fix "lxc image copy" not recording the source

stgraber on Github lxc-bot at linuxcontainers.org
Tue Jul 18 12:26:37 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 354 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170718/25b0b0fb/attachment.bin>
-------------- next part --------------
From 726cc594bd60d03bdce041b89ab67e2b16cec725 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 18 Jul 2017 14:21:43 +0200
Subject: [PATCH] Fix "lxc image copy" not recording the source
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxc/image.go | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/lxc/image.go b/lxc/image.go
index 6c0558504..fe6076e05 100644
--- a/lxc/image.go
+++ b/lxc/image.go
@@ -389,13 +389,26 @@ func (c *imageCmd) run(conf *config.Config, args []string) error {
 			return err
 		}
 
-		// Check if an alias
-		fingerprint := c.dereferenceAlias(d, inName)
+		// Optimisation for simplestreams
+		var imgInfo *api.Image
+		image := inName
+		if conf.Remotes[remote].Protocol == "simplestreams" {
+			imgInfo = &api.Image{}
+			imgInfo.Fingerprint = image
+			imgInfo.Public = true
+		} else {
 
-		// Get the image
-		image, _, err := d.GetImage(fingerprint)
-		if err != nil {
-			return err
+			// Attempt to resolve an image alias
+			alias, _, err := d.GetImageAlias(image)
+			if err == nil {
+				image = alias.Target
+			}
+
+			// Get the image info
+			imgInfo, _, err = d.GetImage(image)
+			if err != nil {
+				return err
+			}
 		}
 
 		// Setup the copy arguments
@@ -414,7 +427,7 @@ func (c *imageCmd) run(conf *config.Config, args []string) error {
 		}
 
 		// Do the copy
-		op, err := dest.CopyImage(d, *image, &args)
+		op, err := dest.CopyImage(d, *imgInfo, &args)
 		if err != nil {
 			return err
 		}


More information about the lxc-devel mailing list