Cleanup WhoAmI sorting code
Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com> Kubernetes-commit: b81b422a70ec6ab1bbdacae56bbe3ccd0daef5a6
This commit is contained in:
parent
32368908af
commit
254147c688
|
@ -20,13 +20,13 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"sort"
|
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
authenticationv1alpha1 "k8s.io/api/authentication/v1alpha1"
|
authenticationv1alpha1 "k8s.io/api/authentication/v1alpha1"
|
||||||
"k8s.io/apimachinery/pkg/api/errors"
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||||
"k8s.io/cli-runtime/pkg/printers"
|
"k8s.io/cli-runtime/pkg/printers"
|
||||||
authenticationv1alpha1client "k8s.io/client-go/kubernetes/typed/authentication/v1alpha1"
|
authenticationv1alpha1client "k8s.io/client-go/kubernetes/typed/authentication/v1alpha1"
|
||||||
|
@ -192,13 +192,7 @@ func printTableSelfSubjectAccessReview(obj runtime.Object, out io.Writer) error
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(ui.Extra) > 0 {
|
if len(ui.Extra) > 0 {
|
||||||
sortedKeys := make([]string, 0, len(ui.Extra))
|
for _, k := range sets.StringKeySet(ui.Extra).List() {
|
||||||
for k := range ui.Extra {
|
|
||||||
sortedKeys = append(sortedKeys, k)
|
|
||||||
}
|
|
||||||
sort.Strings(sortedKeys)
|
|
||||||
|
|
||||||
for _, k := range sortedKeys {
|
|
||||||
v := ui.Extra[k]
|
v := ui.Extra[k]
|
||||||
_, err := fmt.Fprintf(w, "Extra: %s\t%v\n", k, v)
|
_, err := fmt.Fprintf(w, "Extra: %s\t%v\n", k, v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue