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:
Kubernetes Submit Queue
2017-11-09 11:27:37 -08:00
committed by GitHub
2 changed files with 23 additions and 0 deletions

View File

@@ -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 {