|
4 | 4 | "context" |
5 | 5 | "encoding/json" |
6 | 6 | "fmt" |
| 7 | + "strings" |
7 | 8 |
|
8 | 9 | "github.com/goccy/go-yaml" |
9 | 10 | "github.com/spf13/cobra" |
@@ -122,18 +123,29 @@ func outputResult(p *print.Printer, outputFormat string, snapshot *iaas.Snapshot |
122 | 123 |
|
123 | 124 | default: |
124 | 125 | table := tables.NewTable() |
125 | | - table.SetHeader("ID", "NAME", "SIZE", "STATUS", "VOLUME ID", "LABELS", "CREATED AT", "UPDATED AT") |
126 | | - |
127 | | - table.AddRow( |
128 | | - utils.PtrString(snapshot.Id), |
129 | | - utils.PtrString(snapshot.Name), |
130 | | - utils.PtrByteSizeDefault((*int64)(snapshot.Size), ""), |
131 | | - utils.PtrString(snapshot.Status), |
132 | | - utils.PtrString(snapshot.VolumeId), |
133 | | - utils.PtrStringDefault(snapshot.Labels, ""), |
134 | | - utils.ConvertTimePToDateTimeString(snapshot.CreatedAt), |
135 | | - utils.ConvertTimePToDateTimeString(snapshot.UpdatedAt), |
136 | | - ) |
| 126 | + table.AddRow("ID", utils.PtrString(snapshot.Id)) |
| 127 | + table.AddSeparator() |
| 128 | + table.AddRow("NAME", utils.PtrString(snapshot.Name)) |
| 129 | + table.AddSeparator() |
| 130 | + table.AddRow("SIZE", utils.PtrByteSizeDefault((*int64)(snapshot.Size), "")) |
| 131 | + table.AddSeparator() |
| 132 | + table.AddRow("STATUS", utils.PtrString(snapshot.Status)) |
| 133 | + table.AddSeparator() |
| 134 | + table.AddRow("VOLUME ID", utils.PtrString(snapshot.VolumeId)) |
| 135 | + table.AddSeparator() |
| 136 | + |
| 137 | + if snapshot.Labels != nil && len(*snapshot.Labels) > 0 { |
| 138 | + labels := []string{} |
| 139 | + for key, value := range *snapshot.Labels { |
| 140 | + labels = append(labels, fmt.Sprintf("%s: %s", key, value)) |
| 141 | + } |
| 142 | + table.AddRow("LABELS", strings.Join(labels, "\n")) |
| 143 | + table.AddSeparator() |
| 144 | + } |
| 145 | + |
| 146 | + table.AddRow("CREATED AT", utils.ConvertTimePToDateTimeString(snapshot.CreatedAt)) |
| 147 | + table.AddSeparator() |
| 148 | + table.AddRow("UPDATED AT", utils.ConvertTimePToDateTimeString(snapshot.UpdatedAt)) |
137 | 149 |
|
138 | 150 | err := table.Display(p) |
139 | 151 | if err != nil { |
|
0 commit comments