cscli: sort meta by key in alerts inspect output (#762)
This commit is contained in:
parent
430b4bafbc
commit
5e2412cc5d
1 changed files with 5 additions and 0 deletions
|
@ -6,6 +6,7 @@ import (
|
|||
"fmt"
|
||||
"net/url"
|
||||
"os"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
@ -178,12 +179,16 @@ func DisplayOneAlert(alert *models.Alert, withDetail bool) error {
|
|||
fmt.Printf("\n- Date: %s\n", *event.Timestamp)
|
||||
table = tablewriter.NewWriter(os.Stdout)
|
||||
table.SetHeader([]string{"Key", "Value"})
|
||||
sort.Slice(event.Meta, func(i, j int) bool {
|
||||
return event.Meta[i].Key < event.Meta[j].Key
|
||||
})
|
||||
for _, meta := range event.Meta {
|
||||
table.Append([]string{
|
||||
meta.Key,
|
||||
meta.Value,
|
||||
})
|
||||
}
|
||||
|
||||
table.Render() // Send output
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue