From 33f7c6cba42c014767d54ca2c2bb893135904b49 Mon Sep 17 00:00:00 2001 From: Tim Gross Date: Fri, 14 Jan 2022 12:25:48 -0500 Subject: [PATCH] csi: when warning for multiple prefix matches, use full ID (#11853) 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. --- .changelog/11853.txt | 3 +++ command/volume_deregister.go | 2 +- command/volume_detach.go | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 .changelog/11853.txt diff --git a/.changelog/11853.txt b/.changelog/11853.txt new file mode 100644 index 000000000..78592bfe1 --- /dev/null +++ b/.changelog/11853.txt @@ -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 +``` diff --git a/command/volume_deregister.go b/command/volume_deregister.go index 622739bad..512f8426b 100644 --- a/command/volume_deregister.go +++ b/command/volume_deregister.go @@ -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 diff --git a/command/volume_detach.go b/command/volume_detach.go index 16e453a43..b88047ad9 100644 --- a/command/volume_detach.go +++ b/command/volume_detach.go @@ -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