From 529cb36759bb9cfb0f5d8c976d68aba8a0e94700 Mon Sep 17 00:00:00 2001 From: Tim Gross Date: Fri, 25 Jun 2021 15:34:21 -0400 Subject: [PATCH] csi: fix CLI panic when formatting volume status with -verbose flag When the `-verbose` flag is passed to the `nomad volume status` command, we hit a code path where the rows of text to be formatted were not initialized correctly, resulting in a panic in the CLI. --- command/volume_status_csi.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/command/volume_status_csi.go b/command/volume_status_csi.go index 0bf08dd45ce3..9b17e6cda42f 100644 --- a/command/volume_status_csi.go +++ b/command/volume_status_csi.go @@ -119,19 +119,17 @@ NEXT_PLUGIN: // rather than an empty list continue NEXT_PLUGIN } - rows := []string{} - rows[0] = "External ID|Condition|Nodes" - for i, v := range externalList.Volumes { + rows := []string{"External ID|Condition|Nodes"} + for _, v := range externalList.Volumes { condition := "OK" if v.IsAbnormal { condition = fmt.Sprintf("Abnormal (%v)", v.Status) } - - rows[i+1] = fmt.Sprintf("%s|%s|%s", + rows = append(rows, fmt.Sprintf("%s|%s|%s", limit(v.ExternalID, c.length), limit(condition, 20), strings.Join(v.PublishedExternalNodeIDs, ","), - ) + )) } c.Ui.Output(formatList(rows))