Skip to content

Commit

Permalink
csi: when warning for multiple prefix matches, use full ID (#11853)
Browse files Browse the repository at this point in the history
When the `volume deregister` or `volume detach` commands get an ID
prefix that matches multiple volumes, show the full length of the
volume IDs in the list of volumes shown so so that the user can select
the correct one.
  • Loading branch information
tgross authored Jan 14, 2022
1 parent 6b7ecb2 commit e14c10e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .changelog/11853.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```bug
csi: Fixed a bug in `volume deregister` and `volume detach` commands where volume IDs were truncated when asking the user to select one of several prefix matches
```
2 changes: 1 addition & 1 deletion command/volume_deregister.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (c *VolumeDeregisterCommand) Run(args []string) int {
}
if len(vols) > 1 {
sort.Slice(vols, func(i, j int) bool { return vols[i].ID < vols[j].ID })
out, err := csiFormatSortedVolumes(vols, shortId)
out, err := csiFormatSortedVolumes(vols, fullId)
if err != nil {
c.Ui.Error(fmt.Sprintf("Error formatting: %s", err))
return 1
Expand Down
2 changes: 1 addition & 1 deletion command/volume_detach.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (c *VolumeDetachCommand) Run(args []string) int {
}
if len(vols) > 1 {
sort.Slice(vols, func(i, j int) bool { return vols[i].ID < vols[j].ID })
out, err := csiFormatSortedVolumes(vols, shortId)
out, err := csiFormatSortedVolumes(vols, fullId)
if err != nil {
c.Ui.Error(fmt.Sprintf("Error formatting: %s", err))
return 1
Expand Down

0 comments on commit e14c10e

Please sign in to comment.