[lxc-devel] [lxd/master] lxd/instances: Pick correct default type from URL

stgraber on Github lxc-bot at linuxcontainers.org
Wed Feb 19 21:37:26 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/20200219/75ae9b42/attachment.bin>
-------------- next part --------------
From 0984671bcbb4250200e26b552bda9845d0b48396 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 19 Feb 2020 16:36:50 -0500
Subject: [PATCH] lxd/instances: Pick correct default type from URL
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #6902

Signed-off-by: St├ęphane Graber <stgraber at ubuntu.com>
---
 lxd/containers_post.go | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/lxd/containers_post.go b/lxd/containers_post.go
index 376261d49e..6e02ea22cf 100644
--- a/lxd/containers_post.go
+++ b/lxd/containers_post.go
@@ -777,6 +777,16 @@ func containersPost(d *Daemon, r *http.Request) response.Response {
 		return response.BadRequest(err)
 	}
 
+	// Set type from URL if missing
+	urlType, err := urlInstanceTypeDetect(r)
+	if err != nil {
+		return response.InternalError(err)
+	}
+
+	if req.Type == "" && urlType != instancetype.Any {
+		req.Type = api.InstanceType(urlType.String())
+	}
+
 	targetNode := queryParam(r, "target")
 	if targetNode == "" {
 		// If no target node was specified, pick the node with the


More information about the lxc-devel mailing list