[lxc-devel] [lxd/master] lxc/project: Fix remote handling
stgraber on Github
lxc-bot at linuxcontainers.org
Mon May 11 16:24:14 UTC 2020
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/20200511/3a95dc6d/attachment.bin>
-------------- next part --------------
From 5799eea6a617e02f49e22bd7438d7ba0406dd5e5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Mon, 11 May 2020 12:24:00 -0400
Subject: [PATCH] lxc/project: Fix remote handling
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/project.go | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/lxc/project.go b/lxc/project.go
index 0978b9a832..b6a0fc6c61 100644
--- a/lxc/project.go
+++ b/lxc/project.go
@@ -404,6 +404,7 @@ func (c *cmdProjectList) Run(cmd *cobra.Command, args []string) error {
if len(args) > 0 {
remote = args[0]
}
+ remoteName := strings.TrimSuffix(remote, ":")
resources, err := c.global.ParseServers(remote)
if err != nil {
@@ -418,7 +419,7 @@ func (c *cmdProjectList) Run(cmd *cobra.Command, args []string) error {
return err
}
- currentProject := conf.Remotes[remote].Project
+ currentProject := conf.Remotes[remoteName].Project
if currentProject == "" {
currentProject = "default"
}
@@ -681,16 +682,15 @@ func (c *cmdProjectSwitch) Run(cmd *cobra.Command, args []string) error {
conf := c.global.conf
// Sanity checks
- exit, err := c.global.CheckArgs(cmd, args, 1, 2)
+ exit, err := c.global.CheckArgs(cmd, args, 1, 1)
if exit {
return err
}
- remote := conf.DefaultRemote
- project := args[0]
- if len(args) > 1 {
- remote = args[0]
- project = args[1]
+ // Parse the remote
+ remote, project, err := conf.ParseRemote(args[0])
+ if err != nil {
+ return err
}
// Make sure the remote exists
More information about the lxc-devel
mailing list