fix sorting tolerations in case the keys are equal

pull/8/head
Di Xu 2018-03-16 10:19:22 +08:00
parent 9f77657538
commit 3df1b30d27
1 changed files with 18 additions and 25 deletions

View File

@ -3829,15 +3829,11 @@ func printTolerationsMultilineWithIndent(w PrefixWriter, initialIndent, title, i
}
// to print tolerations in the sorted order
keys := make([]string, 0, len(tolerations))
for _, toleration := range tolerations {
keys = append(keys, toleration.Key)
}
sort.Strings(keys)
sort.Slice(tolerations, func(i, j int) bool {
return tolerations[i].Key < tolerations[j].Key
})
for i, key := range keys {
for _, toleration := range tolerations {
if toleration.Key == key {
for i, toleration := range tolerations {
if i != 0 {
w.Write(LEVEL_0, "%s", initialIndent)
w.Write(LEVEL_0, "%s", innerIndent)
@ -3853,9 +3849,6 @@ func printTolerationsMultilineWithIndent(w PrefixWriter, initialIndent, title, i
w.Write(LEVEL_0, " for %ds", *toleration.TolerationSeconds)
}
w.Write(LEVEL_0, "\n")
i++
}
}
}
}