From d0779108b2d87db93df0483acfe85a7f293382ac Mon Sep 17 00:00:00 2001 From: Kadin Sayani Date: Wed, 16 Oct 2024 15:32:36 -0600 Subject: [PATCH 1/2] lxc/completion: Only complete custom storage volumes for `lxc storage volume copy` Signed-off-by: Kadin Sayani --- lxc/completion.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lxc/completion.go b/lxc/completion.go index 331a60cd82ae..739cc989186b 100644 --- a/lxc/completion.go +++ b/lxc/completion.go @@ -1257,8 +1257,10 @@ func (g *cmdGlobal) cmpStoragePoolWithVolume(toComplete string) ([]string, cobra var results []string for _, volume := range volumes { - volName, _ := parseVolume("volume", volume) - results = append(results, pool+"/"+volName) + volName, volType := parseVolume("custom", volume) + if volType == "custom" { + results = append(results, pool+"/"+volName) + } } return results, cobra.ShellCompDirectiveNoFileComp From f86417bc6bc327f4dfa81d38f7c48c3e3c101da2 Mon Sep 17 00:00:00 2001 From: Kadin Sayani Date: Wed, 16 Oct 2024 15:34:08 -0600 Subject: [PATCH 2/2] lxc/completion: Fix completions for `lxc storage volume move` Signed-off-by: Kadin Sayani --- lxc/storage_volume.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lxc/storage_volume.go b/lxc/storage_volume.go index 8fe220d8e3a3..dc3804d821f7 100644 --- a/lxc/storage_volume.go +++ b/lxc/storage_volume.go @@ -1862,7 +1862,13 @@ func (c *cmdStorageVolumeMove) command() *cobra.Command { } if len(args) == 1 { - return c.global.cmpStoragePools(toComplete, false) + completions, directive := c.global.cmpStoragePools(toComplete, true) + for i, completion := range completions { + if !strings.Contains(completion, ":") { + completions[i] = completion + "/" + } + } + return completions, directive } return nil, cobra.ShellCompDirectiveNoFileComp