[lxc-devel] [lxd/master] lxc/rename: Deal with remote renames

stgraber on Github lxc-bot at linuxcontainers.org
Tue Apr 24 02:20:24 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/20180424/9d1fbc52/attachment.bin>
-------------- next part --------------
From bb07131d9e9cb1312b572571c068c9d748656dc1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Mon, 23 Apr 2018 22:19:28 -0400
Subject: [PATCH] lxc/rename: Deal with remote renames
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #4486

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxc/rename.go | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lxc/rename.go b/lxc/rename.go
index fce0282b5..7a3f08c2c 100644
--- a/lxc/rename.go
+++ b/lxc/rename.go
@@ -2,6 +2,7 @@ package main
 
 import (
 	"fmt"
+	"strings"
 
 	"github.com/spf13/cobra"
 
@@ -45,7 +46,13 @@ func (c *cmdRename) Run(cmd *cobra.Command, args []string) error {
 	}
 
 	if sourceRemote != destRemote {
-		return fmt.Errorf(i18n.G("Can't specify a different remote for rename."))
+		// We just do renames
+		if strings.Contains(args[1], ":") {
+			return fmt.Errorf(i18n.G("Can't specify a different remote for rename."))
+		}
+
+		// Don't require the remote to be passed as both source and target
+		args[1] = fmt.Sprintf("%s:%s", sourceRemote, args[1])
 	}
 
 	// Call move


More information about the lxc-devel mailing list