mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 10:51:29 +00:00
Merge pull request #61255 from dixudx/fix_describe_taint
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. fix sorting taints in case the sorting keys are equal **What this PR does / why we need it**: /kind bug /sig cli When describing node taints, the similar issue mentioned in #61250 also exists. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: xref #61250 **Special notes for your reviewer**: /cc @kubernetes/sig-cli-bugs @kubernetes/sig-cli-api-reviews **Release note**: ```release-note fix sorting taints in case the sorting keys are equal ```
This commit is contained in:
commit
83a4f278ef
@ -3808,23 +3808,19 @@ func printTaintsMultilineWithIndent(w PrefixWriter, initialIndent, title, innerI
|
||||
}
|
||||
|
||||
// to print taints in the sorted order
|
||||
keys := make([]string, 0, len(taints))
|
||||
for _, taint := range taints {
|
||||
keys = append(keys, string(taint.Effect)+","+taint.Key)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
|
||||
for i, key := range keys {
|
||||
for _, taint := range taints {
|
||||
if string(taint.Effect)+","+taint.Key == key {
|
||||
if i != 0 {
|
||||
w.Write(LEVEL_0, "%s", initialIndent)
|
||||
w.Write(LEVEL_0, "%s", innerIndent)
|
||||
}
|
||||
w.Write(LEVEL_0, "%s\n", taint.ToString())
|
||||
i++
|
||||
}
|
||||
sort.Slice(taints, func(i, j int) bool {
|
||||
cmpKey := func(taint api.Taint) string {
|
||||
return string(taint.Effect) + "," + taint.Key
|
||||
}
|
||||
return cmpKey(taints[i]) < cmpKey(taints[j])
|
||||
})
|
||||
|
||||
for i, taint := range taints {
|
||||
if i != 0 {
|
||||
w.Write(LEVEL_0, "%s", initialIndent)
|
||||
w.Write(LEVEL_0, "%s", innerIndent)
|
||||
}
|
||||
w.Write(LEVEL_0, "%s\n", taint.ToString())
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user