[lxc-devel] [lxd/master] Error if --columns and --fast are used together in lxc list

albertodonato on Github lxc-bot at linuxcontainers.org
Mon Jul 3 14:04:44 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 313 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170703/697b22dc/attachment.bin>
-------------- next part --------------
From 3579b2e2ed392705ed30a49e1135788dacf2eff2 Mon Sep 17 00:00:00 2001
From: Alberto Donato <alberto.donato at canonical.com>
Date: Mon, 3 Jul 2017 16:04:17 +0200
Subject: [PATCH] Error if --columns and --fast are used together in lxc list

Signed-off-by: Alberto Donato <alberto.donato at canonical.com>
---
 lxc/list.go          | 7 ++++++-
 test/suites/basic.sh | 3 +++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/lxc/list.go b/lxc/list.go
index 3aeb4457b..1ef452451 100644
--- a/lxc/list.go
+++ b/lxc/list.go
@@ -472,7 +472,12 @@ func (c *listCmd) parseColumns() ([]column, error) {
 	}
 
 	if c.fast {
-		c.columnsRaw = "nsacPt"
+		if c.columnsRaw != "ns46tS" {
+			// --columns was specified too
+			return nil, fmt.Errorf("Can't specify --fast with --columns")
+		} else {
+			c.columnsRaw = "nsacPt"
+		}
 	}
 
 	columnList := strings.Split(c.columnsRaw, ",")
diff --git a/test/suites/basic.sh b/test/suites/basic.sh
index 19b7885e3..2811ecfc2 100644
--- a/test/suites/basic.sh
+++ b/test/suites/basic.sh
@@ -91,6 +91,9 @@ test_basic_usage() {
   # Test list json format
   lxc list --format json | jq '.[]|select(.name="foo")' | grep '"name": "foo"'
 
+  # Test list with --columns and --fast
+  ! lxc list --columns=nsp --fast
+
   # Test container rename
   lxc move foo bar
   lxc list | grep -v foo


More information about the lxc-devel mailing list