diff --git a/.changelog/12153.txt b/.changelog/12153.txt new file mode 100644 index 0000000000..6ab9893891 --- /dev/null +++ b/.changelog/12153.txt @@ -0,0 +1,3 @@ +```release-note:improvement +csi: Respect the verbose flag in the output of `volume status` +``` diff --git a/command/volume_deregister.go b/command/volume_deregister.go index 5dc067d50d..4842aae517 100644 --- a/command/volume_deregister.go +++ b/command/volume_deregister.go @@ -106,7 +106,7 @@ func (c *VolumeDeregisterCommand) Run(args []string) int { if len(vols) > 1 { if (volID != vols[0].ID) || (c.allNamespaces() && vols[0].ID == vols[1].ID) { sort.Slice(vols, func(i, j int) bool { return vols[i].ID < vols[j].ID }) - out, err := csiFormatSortedVolumes(vols, fullId) + out, err := csiFormatSortedVolumes(vols) 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 2de8e1d970..aeea784c4a 100644 --- a/command/volume_detach.go +++ b/command/volume_detach.go @@ -128,7 +128,7 @@ func (c *VolumeDetachCommand) Run(args []string) int { if len(vols) > 1 { if (volID != vols[0].ID) || (c.allNamespaces() && vols[0].ID == vols[1].ID) { sort.Slice(vols, func(i, j int) bool { return vols[i].ID < vols[j].ID }) - out, err := csiFormatSortedVolumes(vols, fullId) + out, err := csiFormatSortedVolumes(vols) if err != nil { c.Ui.Error(fmt.Sprintf("Error formatting: %s", err)) return 1 diff --git a/command/volume_status.go b/command/volume_status.go index f89ac87ffc..39157af39a 100644 --- a/command/volume_status.go +++ b/command/volume_status.go @@ -109,6 +109,11 @@ func (c *VolumeStatusCommand) Run(args []string) int { return 1 } + // Truncate alloc and node IDs unless full length is requested + c.length = shortId + if c.verbose { + c.length = fullId + } c.length = fullId // Get the HTTP client diff --git a/command/volume_status_csi.go b/command/volume_status_csi.go index bce7379cc2..36724d34ab 100644 --- a/command/volume_status_csi.go +++ b/command/volume_status_csi.go @@ -160,16 +160,16 @@ func (c *VolumeStatusCommand) csiFormatVolumes(vols []*api.CSIVolumeListStub) (s return out, nil } - return csiFormatSortedVolumes(vols, c.length) + return csiFormatSortedVolumes(vols) } // Format the volumes, assumes that we're already sorted by volume ID -func csiFormatSortedVolumes(vols []*api.CSIVolumeListStub, length int) (string, error) { +func csiFormatSortedVolumes(vols []*api.CSIVolumeListStub) (string, error) { rows := make([]string, len(vols)+1) rows[0] = "ID|Name|Plugin ID|Schedulable|Access Mode" for i, v := range vols { rows[i+1] = fmt.Sprintf("%s|%s|%s|%t|%s", - limit(v.ID, length), + v.ID, v.Name, v.PluginID, v.Schedulable,