File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed
cmd/compute-domain-daemon Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change 1717package main
1818
1919import (
20+ "cmp"
2021 "fmt"
2122 "maps"
2223 "os"
@@ -110,13 +111,20 @@ func (m *DNSNameManager) LogDNSNameMappings() {
110111 return
111112 }
112113
113- klog .Infof ("Current compute-domain-daemon mappings:" )
114+ // Sort alphabetically by DNS name (map value) -> sort ips (map keys) based
115+ // on their corresponding values.
116+ var ips []string
117+ for ip := range m .ipToDNSName {
118+ ips = append (ips , ip )
119+ }
120+
121+ slices .SortFunc (ips , func (a , b string ) int {
122+ return cmp .Compare (m .ipToDNSName [a ], m .ipToDNSName [b ])
123+ })
114124
115- // Sort alphabetically by DNS name. Right-justify DNS names by adding
116- // whitespace to the left.
117- for _ , ip := range slices .Sorted (maps .Keys (m .ipToDNSName )) {
125+ for _ , ip := range ips {
118126 dnsname := m .ipToDNSName [ip ]
119- klog .Infof ("%26s -> %s" , dnsname , ip )
127+ klog .Infof ("%s -> %s" , dnsname , ip )
120128 }
121129}
122130
You can’t perform that action at this time.
0 commit comments