kubernetes/pkg/kubectl
Kubernetes Submit Queue c682496197
Merge pull request #67211 from juanvallejo/jvallejo/prototype-sorter
Automatic merge from submit-queue (batch tested with PRs 68051, 68130, 67211, 68065, 68117). If you want to cherry-pick this change to another branch, please follow the instructions here: https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md.

Update `kubectl get` sorter to deal with server-side printing

**Release note**:
```release-note
NONE
```

### Why?

Currently, we default to non-server-side printing when sorting items in `kubectl get`. This means that instead of taking advantage of having the server tell `kubectl` how to display information, `kubectl` falls back to using hardcoded resource types to figure out how to print its output. This does not really work with resources that `kubectl` does not know about, and it goes against our goal of snipping any dependencies that `kubectl` has on the core repo.

This patch adds a sorter capable of dealing with Table objects sent by the server when using "server-side printing".

A few things left to take care of:

- ~~[ ] When printing `all` resources, this implementation does not handle sorting every single Table object, but rather _only_ the rows in each object. As a result, output will contain sorted resources of the same _kind_, but the overall list of mixed resources will _not_ itself be sorted. Example:~~

```bash
$ kubectl get all --sort-by .metadata.name
NAME            READY     STATUS    RESTARTS   AGE
# pods here will be sorted:
pod/bar         0/2       Pending   0          31m
pod/foo         1/1       Running   0          37m

NAME                        DESIRED   CURRENT   READY     AGE
# replication controllers here will be sorted as well:
replicationcontroller/baz   1         1         1         37m
replicationcontroller/buz   1         1         1         37m

# ... but the overall mixed list of rc's and pods will not be sorted
```
This occurs because each Table object received from the server contains all rows for that resource _kind_. We would need a way to build an ambiguous Table object containing all rows for all objects regardless of their type to have a fully sorted mixed-object output.

- [ ] handle sorting by column-names, rather than _only_ with jsonpaths (Tracked in https://github.com/kubernetes/kubernetes/issues/68027)

cc @soltysh @kubernetes/sig-cli-maintainers @seans3 @mengqiy
2018-08-31 15:32:40 -07:00
..
apply Run hack/update-bazel.sh 2018-06-22 16:22:57 -07:00
apps Run hack/update-bazel.sh 2018-06-22 16:22:57 -07:00
cmd Merge pull request #67211 from juanvallejo/jvallejo/prototype-sorter 2018-08-31 15:32:40 -07:00
explain Run hack/update-bazel.sh 2018-06-22 16:22:57 -07:00
metricsutil Move validation dependency from pkg/apis/core/validation to staging 2018-08-09 15:52:59 -07:00
polymorphichelpers Create cli-runtime staging repository 2018-08-21 17:08:30 +02:00
proxy Enable kubectl proxy to set tcp keepalive 2018-06-25 11:03:05 +08:00
scheme Handle errors 2018-07-17 20:47:14 +10:00
util Log real file's name and line 2018-08-11 14:57:45 +02:00
validation Run hack/update-bazel.sh 2018-06-22 16:22:57 -07:00
.import-restrictions fix verify about import error 2018-07-28 07:54:16 +08:00
apply.go remove confusing flexibility for metadata interpretation 2018-04-23 13:31:55 -04:00
autoscale.go refactor kubectl autoscale to use the new generator 2017-11-20 14:12:20 +08:00
autoscale_test.go update the import file for move util/pointer to k8s.io/utils 2018-07-27 19:47:02 +08:00
BUILD add prototype sorting for table rows 2018-08-30 16:09:05 -04:00
clusterrolebinding.go add UT for pkg/kubecl clusterrolebinding 2017-08-28 15:13:15 +08:00
clusterrolebinding_test.go use subtest for table units (pkg/kubectl) 2018-05-27 10:04:55 +08:00
conditions.go switching rolling update to external clients 2018-08-03 13:18:14 -04:00
configmap.go Add support for binary file in configmap 2018-01-23 07:28:34 -05:00
configmap_test.go use subtest for table units (pkg/kubectl) 2018-05-27 10:04:55 +08:00
deployment.go Add basic generator for apps/v1 deployment 2018-04-11 00:44:29 +05:30
deployment_test.go use subtest for table units (pkg/kubectl) 2018-05-27 10:04:55 +08:00
doc.go
env_file.go fix all the typos across the project 2018-02-11 11:04:14 +08:00
env_file_test.go use subtest for table units (pkg/kubectl) 2018-05-27 10:04:55 +08:00
generate.go
generate_test.go K8s SCTP support implementation for the first pull request 2018-08-27 05:56:27 +00:00
history.go kubectl: Use apps/v1 Deployment/ReplicaSet. 2018-05-22 13:43:06 -07:00
history_test.go Refactor HistoryViewerFor to use Visitor design pattern 2017-11-09 08:11:19 +00:00
interfaces.go
namespace.go Remove kubectl create namespace dependencies on kubernetes/pkg/api 2017-10-25 20:26:11 +08:00
namespace_test.go use subtest for table units (pkg/kubectl) 2018-05-27 10:04:55 +08:00
OWNERS add labels to kubectl OWNERS files 2018-08-22 00:40:54 +03:00
pdb.go Print type representation on errors when checking parameter types 2017-11-01 10:36:17 +01:00
pdb_test.go use subtest for table units (pkg/kubectl) 2018-05-27 10:04:55 +08:00
priorityclass.go fix kubectl create priorityclass failure bug 2018-07-02 15:03:22 +08:00
priorityclass_test.go fix kubectl create priorityclass failure bug 2018-07-02 15:03:22 +08:00
quota.go switch some commands to use its own scheme 2017-10-27 18:31:42 -07:00
quota_test.go use subtest for table units (pkg/kubectl) 2018-05-27 10:04:55 +08:00
rolebinding.go switch some commands to use its own scheme 2017-10-27 18:31:42 -07:00
rolebinding_test.go use subtest for table units (pkg/kubectl) 2018-05-27 10:04:55 +08:00
rollback.go return err when Unmarshal failed 2018-07-27 20:52:00 +08:00
rollback_test.go Replace type switches in Rollback with Visitor pattern 2017-11-19 17:46:57 +00:00
rolling_updater.go switching rolling update to external clients 2018-08-03 13:18:14 -04:00
rolling_updater_test.go switching rolling update to external clients 2018-08-03 13:18:14 -04:00
rollout_status.go Better error message when checking rollout status for StatefulSet with OnDelete strategy type 2018-08-15 21:39:14 -07:00
rollout_status_test.go Better error message when checking rollout status for StatefulSet with OnDelete strategy type 2018-08-15 21:39:14 -07:00
run.go Remove an old TODO. 2018-06-11 13:04:32 -07:00
run_test.go Merge pull request #64938 from brendandburns/todo2 2018-06-21 04:15:08 -07:00
scale.go Adding scale error retries 2018-06-12 11:23:16 +02:00
scale_test.go Move dependency from k/k/pkg/apis/core to staging 2018-08-10 12:56:03 -07:00
secret.go remove versioned printer 2018-05-17 17:20:54 -04:00
secret_for_docker_registry.go add --from-file flag to docker-registry secret 2018-03-21 11:13:11 -04:00
secret_for_docker_registry_test.go use subtest for table units (pkg/kubectl) 2018-05-27 10:04:55 +08:00
secret_for_tls.go Merge pull request #67713 from liggitt/process-substitution 2018-08-22 23:04:26 -07:00
secret_for_tls_test.go use subtest for table units (pkg/kubectl) 2018-05-27 10:04:55 +08:00
secret_test.go use subtest for table units (pkg/kubectl) 2018-05-27 10:04:55 +08:00
service.go remove dependency from service generator 2017-10-31 15:35:36 +08:00
service_basic.go Make sure the ports is valid when parsing portString 2017-11-13 20:46:05 +08:00
service_basic_test.go fix failed verify misspell err 2018-03-20 11:16:51 +08:00
service_test.go K8s SCTP support implementation for the first pull request 2018-08-27 05:56:27 +00:00
serviceaccount.go switch some commands to use its own scheme 2017-10-27 18:31:42 -07:00
serviceaccount_test.go use subtest for table units (pkg/kubectl) 2018-05-27 10:04:55 +08:00
sorter.go add prototype sorting for table rows 2018-08-30 16:09:05 -04:00
sorter_test.go use subtest for table units (pkg/kubectl) 2018-05-27 10:04:55 +08:00