csi: respect -verbose flag for allocs in volume status (#12153)
This commit is contained in:
parent
166011237b
commit
02ae95ab22
|
@ -0,0 +1,3 @@
|
||||||
|
```release-note:improvement
|
||||||
|
csi: Respect the verbose flag in the output of `volume status`
|
||||||
|
```
|
|
@ -106,7 +106,7 @@ func (c *VolumeDeregisterCommand) Run(args []string) int {
|
||||||
if len(vols) > 1 {
|
if len(vols) > 1 {
|
||||||
if (volID != vols[0].ID) || (c.allNamespaces() && vols[0].ID == vols[1].ID) {
|
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 })
|
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 {
|
if err != nil {
|
||||||
c.Ui.Error(fmt.Sprintf("Error formatting: %s", err))
|
c.Ui.Error(fmt.Sprintf("Error formatting: %s", err))
|
||||||
return 1
|
return 1
|
||||||
|
|
|
@ -128,7 +128,7 @@ func (c *VolumeDetachCommand) Run(args []string) int {
|
||||||
if len(vols) > 1 {
|
if len(vols) > 1 {
|
||||||
if (volID != vols[0].ID) || (c.allNamespaces() && vols[0].ID == vols[1].ID) {
|
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 })
|
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 {
|
if err != nil {
|
||||||
c.Ui.Error(fmt.Sprintf("Error formatting: %s", err))
|
c.Ui.Error(fmt.Sprintf("Error formatting: %s", err))
|
||||||
return 1
|
return 1
|
||||||
|
|
|
@ -109,6 +109,11 @@ func (c *VolumeStatusCommand) Run(args []string) int {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Truncate alloc and node IDs unless full length is requested
|
||||||
|
c.length = shortId
|
||||||
|
if c.verbose {
|
||||||
|
c.length = fullId
|
||||||
|
}
|
||||||
c.length = fullId
|
c.length = fullId
|
||||||
|
|
||||||
// Get the HTTP client
|
// Get the HTTP client
|
||||||
|
|
|
@ -160,16 +160,16 @@ func (c *VolumeStatusCommand) csiFormatVolumes(vols []*api.CSIVolumeListStub) (s
|
||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return csiFormatSortedVolumes(vols, c.length)
|
return csiFormatSortedVolumes(vols)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Format the volumes, assumes that we're already sorted by volume ID
|
// 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 := make([]string, len(vols)+1)
|
||||||
rows[0] = "ID|Name|Plugin ID|Schedulable|Access Mode"
|
rows[0] = "ID|Name|Plugin ID|Schedulable|Access Mode"
|
||||||
for i, v := range vols {
|
for i, v := range vols {
|
||||||
rows[i+1] = fmt.Sprintf("%s|%s|%s|%t|%s",
|
rows[i+1] = fmt.Sprintf("%s|%s|%s|%t|%s",
|
||||||
limit(v.ID, length),
|
v.ID,
|
||||||
v.Name,
|
v.Name,
|
||||||
v.PluginID,
|
v.PluginID,
|
||||||
v.Schedulable,
|
v.Schedulable,
|
||||||
|
|
Loading…
Reference in New Issue