Skip to content

Commit

Permalink
lxc: Update cmpStoragePoolVolumes usage
Browse files Browse the repository at this point in the history
On attach and detach commands, only include custom volumes as those are
the only ones attachable.

Signed-off-by: hamistao <[email protected]>
  • Loading branch information
hamistao committed Dec 10, 2024
1 parent 5f78457 commit 0d36535
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
6 changes: 2 additions & 4 deletions lxc/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions lxc/storage_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 0d36535

Please sign in to comment.