Stabilize order of rows in origin node

This commit is contained in:
Peter Bourgon
2015-05-22 15:57:52 +02:00
parent 24df95f132
commit 7427467363

View File

@@ -33,13 +33,13 @@ func originNodeForProcess(node report.NodeMetadata) OriginNode {
{Key: "PID", ValueMajor: node["pid"], ValueMinor: ""},
{Key: "Process name", ValueMajor: node["name"], ValueMinor: ""},
}
for key, human := range map[string]string{
"docker_id": "Container ID",
"docker_name": "Container name",
"cgroup": "cgroup",
for _, tuple := range []struct{ key, human string }{
{"docker_id", "Container ID"},
{"docker_name", "Container name"},
{"cgroup", "cgroup"},
} {
if val, ok := node[key]; ok {
rows = append(rows, report.Row{Key: human, ValueMajor: val, ValueMinor: ""})
if val, ok := node[tuple.key]; ok {
rows = append(rows, report.Row{Key: tuple.human, ValueMajor: val, ValueMinor: ""})
}
}
return OriginNode{