Unverified Commit 787b8c0c authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #61252 from dixudx/fix_describe_toleration

Automatic merge from submit-queue (batch tested with PRs 60793, 61181, 61267, 61252, 61334). 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 tolerations in case the keys are equal **What this PR does / why we need it**: /kind bug /sig cli find a better way to sort `api.Toleration`, in case the key are the same **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes #61250 **Special notes for your reviewer**: /cc @k82cn @kubernetes/sig-cli-api-reviews **Release note**: ```release-note fix sorting tolerations in case the keys are equal ```
parents 28aa3c74 3df1b30d
...@@ -3843,15 +3843,11 @@ func printTolerationsMultilineWithIndent(w PrefixWriter, initialIndent, title, i ...@@ -3843,15 +3843,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)
...@@ -3867,9 +3863,6 @@ func printTolerationsMultilineWithIndent(w PrefixWriter, initialIndent, title, i ...@@ -3867,9 +3863,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