[lxc-devel] [lxd/master] lxd: Don't regress URLs for default project

stgraber on Github lxc-bot at linuxcontainers.org
Wed Oct 10 16:22:19 UTC 2018


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/20181010/d1b33a78/attachment.bin>
-------------- next part --------------
From 2378825adde759981e6eb5461debd03827f1e596 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 10 Oct 2018 12:21:57 -0400
Subject: [PATCH] lxd: Don't regress URLs for default project
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>
---
 lxd/db/cluster/constants.go | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/lxd/db/cluster/constants.go b/lxd/db/cluster/constants.go
index a1c47310a3..395837afe7 100644
--- a/lxd/db/cluster/constants.go
+++ b/lxd/db/cluster/constants.go
@@ -2,6 +2,7 @@ package cluster
 
 import (
 	"fmt"
+	"strings"
 
 	"github.com/lxc/lxd/shared/version"
 )
@@ -37,10 +38,20 @@ var EntityURIs = map[int]string{
 // used to format its URI.
 var EntityFormatURIs = map[int]func(a ...interface{}) string{
 	TypeContainer: func(a ...interface{}) string {
-		return fmt.Sprintf(EntityURIs[TypeContainer], a[1], a[0])
+		uri := fmt.Sprintf(EntityURIs[TypeContainer], a[1], a[0])
+		if a[0] == "default" {
+			return strings.Split(uri, fmt.Sprintf("?project=%s", a[0]))[0]
+		}
+
+		return uri
 	},
 	TypeProfile: func(a ...interface{}) string {
-		return fmt.Sprintf(EntityURIs[TypeProfile], a[1], a[0])
+		uri := fmt.Sprintf(EntityURIs[TypeProfile], a[1], a[0])
+		if a[0] == "default" {
+			return strings.Split(uri, fmt.Sprintf("?project=%s", a[0]))[0]
+		}
+
+		return uri
 	},
 }
 


More information about the lxc-devel mailing list