Sort the attributes for events
This is add support for #19559 We tried sort it in client side, and it sort follow go sort : sorts a slice of strings in increasing order. Signed-off-by: Kai Qiang Wu(Kennan) <wkqwu@cn.ibm.com> Upstream-commit: 746f6af9aa2a48a8910b51ebbfafac511244fd9d Component: engine
This commit is contained in:
@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -99,7 +100,13 @@ func printOutput(event eventtypes.Message, output io.Writer) {
|
||||
|
||||
if len(event.Actor.Attributes) > 0 {
|
||||
var attrs []string
|
||||
for k, v := range event.Actor.Attributes {
|
||||
var keys []string
|
||||
for k := range event.Actor.Attributes {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
for _, k := range keys {
|
||||
v := event.Actor.Attributes[k]
|
||||
attrs = append(attrs, fmt.Sprintf("%s=%s", k, v))
|
||||
}
|
||||
fmt.Fprintf(output, " (%s)", strings.Join(attrs, ", "))
|
||||
|
||||
Reference in New Issue
Block a user