open-consul/command/catalog/helpers.go
Dhia Ayachi 8e2de60b87
add partition flag to catalog commands (#10949)
* add partition flag to catalog commands

* add missing files
2021-08-27 16:34:45 -04:00

24 lines
448 B
Go

package catalog
import (
"fmt"
"sort"
"strings"
)
// mapToKV converts a map[string]string into a human-friendly key=value list,
// sorted by name.
func mapToKV(m map[string]string, joiner string) string {
keys := make([]string, 0, len(m))
for k := range m {
keys = append(keys, k)
}
sort.Strings(keys)
r := make([]string, len(keys))
for i, k := range keys {
r[i] = fmt.Sprintf("%s=%s", k, m[k])
}
return strings.Join(r, joiner)
}