mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-04 15:05:20 +00:00
Merge pull request #46946 from kellycampbell/sort-contexts
Automatic merge from submit-queue (batch tested with PRs 46946, 45792). 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>. kubectl config get-contexts: sort output This sorts the output of kubectl config get-contexts because the ordering is otherwise non-stable and makes it harder to find the context you're looking for when you have more than a few. ```release-note The output of kubectl config get-contexts is now sorted alphabetically by the context name. ```
This commit is contained in:
@@ -19,6 +19,7 @@ package config
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"sort"
|
||||
"strings"
|
||||
"text/tabwriter"
|
||||
|
||||
@@ -138,6 +139,7 @@ func (o GetContextsOptions) RunGetContexts() error {
|
||||
}
|
||||
}
|
||||
|
||||
sort.Strings(toPrint)
|
||||
for _, name := range toPrint {
|
||||
err = printContext(name, config.Contexts[name], out, o.nameOnly, config.CurrentContext == name)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user