[lxc-devel] [lxd/master] lxd/images: Fix parsing of public property

stgraber on Github lxc-bot at linuxcontainers.org
Wed Oct 10 15:00:18 UTC 2018


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/20181010/aa1fd21d/attachment.bin>
-------------- next part --------------
From b6ffbe0fcb11d8218bb4c227e031ca6916f115ad Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 10 Oct 2018 10:55:06 -0400
Subject: [PATCH] lxd/images: Fix parsing of public property
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #5131

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/images.go        | 3 +--
 test/suites/basic.sh | 3 ++-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lxd/images.go b/lxd/images.go
index 716fa797bd..d82c42f998 100644
--- a/lxd/images.go
+++ b/lxd/images.go
@@ -385,8 +385,7 @@ func getImgPostInfo(d *Daemon, r *http.Request, builddir string, project string,
 	var imageMeta *api.ImageMetadata
 	logger := logging.AddContext(logger.Log, log.Ctx{"function": "getImgPostInfo"})
 
-	public, _ := strconv.Atoi(r.Header.Get("X-LXD-public"))
-	info.Public = public == 1
+	info.Public = shared.IsTrue(r.Header.Get("X-LXD-public"))
 	propHeaders := r.Header[http.CanonicalHeaderKey("X-LXD-properties")]
 	ctype, ctypeParams, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
 	if err != nil {
diff --git a/test/suites/basic.sh b/test/suites/basic.sh
index dec56abbd3..e21f8424f9 100644
--- a/test/suites/basic.sh
+++ b/test/suites/basic.sh
@@ -47,8 +47,9 @@ test_basic_usage() {
 
   # Re-import the image
   mv "${LXD_DIR}/${sum}.tar.xz" "${LXD_DIR}/testimage.tar.xz"
-  lxc image import "${LXD_DIR}/testimage.tar.xz" --alias testimage user.foo=bar
+  lxc image import "${LXD_DIR}/testimage.tar.xz" --alias testimage user.foo=bar --public
   lxc image show testimage | grep -q "user.foo: bar"
+  lxc image show testimage | grep -q "public: true"
   lxc image delete testimage
   lxc image import "${LXD_DIR}/testimage.tar.xz" --alias testimage
   rm "${LXD_DIR}/testimage.tar.xz"


More information about the lxc-devel mailing list