mcst-linux-kernel/patches-2024.06.26/lxd-3.0.0/0017-lxc-query-Fix-d-and-X....

75 lines
3.1 KiB
Diff

From f8a50382a6682b10fbfe6459e9907c5debd05a4e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber@ubuntu.com>
Date: Wed, 4 Apr 2018 12:43:43 -0400
Subject: lxc/query: Fix -d and -X
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Closes #4406
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
---
lxc/main.go | 2 +-
lxc/query.go | 4 ++--
test/main.sh | 1 +
test/suites/query.sh | 9 +++++++++
4 files changed, 13 insertions(+), 3 deletions(-)
create mode 100644 test/suites/query.sh
diff --git a/lxc/main.go b/lxc/main.go
index 70abc681..f558e479 100644
--- a/lxc/main.go
+++ b/lxc/main.go
@@ -55,7 +55,7 @@ For help with any of those, simply call them with --help.`))
app.PersistentFlags().BoolVar(&globalCmd.flagVersion, "version", false, i18n.G("Print version number"))
app.PersistentFlags().BoolVarP(&globalCmd.flagHelp, "help", "h", false, i18n.G("Print help"))
app.PersistentFlags().BoolVar(&globalCmd.flagForceLocal, "force-local", false, i18n.G("Force using the local unix socket"))
- app.PersistentFlags().BoolVarP(&globalCmd.flagLogDebug, "debug", "d", false, i18n.G("Show all debug messages"))
+ app.PersistentFlags().BoolVar(&globalCmd.flagLogDebug, "debug", false, i18n.G("Show all debug messages"))
app.PersistentFlags().BoolVarP(&globalCmd.flagLogVerbose, "verbose", "v", false, i18n.G("Show all information messages"))
// Local flags
diff --git a/lxc/query.go b/lxc/query.go
index 39881d47..1c8efc75 100644
--- a/lxc/query.go
+++ b/lxc/query.go
@@ -34,8 +34,8 @@ func (c *cmdQuery) Command() *cobra.Command {
cmd.RunE = c.Run
cmd.Flags().BoolVar(&c.flagRespWait, "wait", false, i18n.G("Wait for the operation to complete"))
cmd.Flags().BoolVar(&c.flagRespRaw, "raw", false, i18n.G("Print the raw response"))
- cmd.Flags().StringVar(&c.flagAction, "X", "GET", i18n.G("Action (defaults to GET)")+"``")
- cmd.Flags().StringVar(&c.flagData, "d", "", i18n.G("Input data")+"``")
+ cmd.Flags().StringVarP(&c.flagAction, "request", "X", "GET", i18n.G("Action (defaults to GET)")+"``")
+ cmd.Flags().StringVarP(&c.flagData, "data", "d", "", i18n.G("Input data")+"``")
return cmd
}
diff --git a/test/main.sh b/test/main.sh
index cd57cb49..be52c3b9 100755
--- a/test/main.sh
+++ b/test/main.sh
@@ -196,6 +196,7 @@ run_test test_resources "resources"
run_test test_kernel_limits "kernel limits"
run_test test_macaroon_auth "macaroon authentication"
run_test test_console "console"
+run_test test_query "query"
run_test test_proxy_device "proxy device"
run_test test_storage_local_volume_handling "storage local volume handling"
run_test test_clustering_membership "clustering membership"
diff --git a/test/suites/query.sh b/test/suites/query.sh
new file mode 100644
index 00000000..84bfee8b
--- /dev/null
+++ b/test/suites/query.sh
@@ -0,0 +1,9 @@
+test_query() {
+ ensure_import_testimage
+ ensure_has_localhost_remote "${LXD_ADDR}"
+
+ lxc init testimage querytest
+ lxc query --wait -X POST -d "{\\\"name\\\": \\\"snap-test\\\"}" /1.0/containers/querytest/snapshots
+ lxc info querytest | grep snap-test
+ lxc delete querytest
+}