Merge pull request #19761 from HackToday/enhancesortattr

Sort the attributes for events
Upstream-commit: 1bc4c99372fa458c70eeb411575a1c538912521d
Component: engine
This commit is contained in:
Alexander Morozov
2016-02-02 16:08:23 -08:00
2 changed files with 35 additions and 1 deletions

View File

@ -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, ", "))