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