THIS IS ONLY A TEST INSTANCE. DON'T DO IMPORTANT WORK HERE!

Commit 5bca78f9 authored by David Festal's avatar David Festal Committed by Dmytro Nochevnov
Browse files

Order the map when converting it to a string


Signed-off-by: default avatarDavid Festal <dfestal@redhat.com>
parent 76ba7b51
......@@ -12,6 +12,7 @@
package util
import (
"sort"
"crypto/tls"
"encoding/json"
"errors"
......@@ -65,8 +66,16 @@ func GeneratePasswd(stringLength int) (passwd string) {
func MapToKeyValuePairs(m map[string]string) string {
buff := new(bytes.Buffer)
for key, value := range m {
fmt.Fprintf(buff, "%s=%s,", key, value)
keys := make([]string, 0, len(m))
for key := range m {
keys = append(keys, key)
}
sort.Strings(keys) //sort keys alphabetically
for _, key := range keys {
fmt.Fprintf(buff, "%s=%s,", key, m[key])
}
return strings.TrimSuffix(buff.String(), ",")
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment