Skip to content

Commit

Permalink
lxc storage volume copy/move shell completion fixes (#14288)
Browse files Browse the repository at this point in the history
This PR partially fixes #14264.
I'll spend some more time trying to figure out why the completions
generated during the snap build include an erroneous space, but a fix
for that will likely land in the lxd snap repo.
  • Loading branch information
tomponline authored Oct 17, 2024
2 parents dcd70b1 + f86417b commit f98c8b4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lxc/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion lxc/storage_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f98c8b4

Please sign in to comment.