From 0d365357ab2a4df7ac511cde91f31d5500fdba90 Mon Sep 17 00:00:00 2001 From: hamistao Date: Fri, 6 Dec 2024 02:50:21 -0300 Subject: [PATCH] lxc: Update `cmpStoragePoolVolumes` usage On attach and detach commands, only include custom volumes as those are the only ones attachable. Signed-off-by: hamistao --- lxc/completion.go | 6 ++---- lxc/storage_volume.go | 9 +++++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lxc/completion.go b/lxc/completion.go index 9bbf707a41ad..f8fc443d7a40 100644 --- a/lxc/completion.go +++ b/lxc/completion.go @@ -1369,10 +1369,8 @@ func (g *cmdGlobal) cmpStoragePoolWithVolume(toComplete string) ([]string, cobra var results []string for _, volume := range volumes { - volName, volType := parseVolume("custom", volume) - if volType == "custom" { - results = append(results, pool+"/"+volName) - } + volName, _ := parseVolume("custom", volume) + results = append(results, pool+"/"+volName) } return results, cobra.ShellCompDirectiveNoFileComp diff --git a/lxc/storage_volume.go b/lxc/storage_volume.go index ed51fd7287b0..8c0aff211a87 100644 --- a/lxc/storage_volume.go +++ b/lxc/storage_volume.go @@ -17,6 +17,7 @@ import ( "gopkg.in/yaml.v2" "github.com/canonical/lxd/client" + storageDrivers "github.com/canonical/lxd/lxd/storage/drivers" "github.com/canonical/lxd/shared" "github.com/canonical/lxd/shared/api" cli "github.com/canonical/lxd/shared/cmd" @@ -177,7 +178,7 @@ func (c *cmdStorageVolumeAttach) command() *cobra.Command { } if len(args) == 1 { - return c.global.cmpStoragePoolVolumes(args[0]) + return c.global.cmpStoragePoolVolumes(args[0], storageDrivers.VolumeTypeCustom) } if len(args) == 2 { @@ -292,7 +293,7 @@ func (c *cmdStorageVolumeAttachProfile) command() *cobra.Command { } if len(args) == 1 { - return c.global.cmpStoragePoolVolumes(args[0]) + return c.global.cmpStoragePoolVolumes(args[0], storageDrivers.VolumeTypeCustom) } if len(args) == 2 { @@ -816,7 +817,7 @@ func (c *cmdStorageVolumeDetach) command() *cobra.Command { } if len(args) == 1 { - return c.global.cmpStoragePoolVolumes(args[0]) + return c.global.cmpStoragePoolVolumes(args[0], storageDrivers.VolumeTypeCustom) } if len(args) == 2 { @@ -919,7 +920,7 @@ func (c *cmdStorageVolumeDetachProfile) command() *cobra.Command { } if len(args) == 1 { - return c.global.cmpStoragePoolVolumes(args[0]) + return c.global.cmpStoragePoolVolumes(args[0], storageDrivers.VolumeTypeCustom) } if len(args) == 2 {