Commit 3df1b30d authored by Di Xu's avatar Di Xu

fix sorting tolerations in case the keys are equal

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