Skip to content

Sort yaml/json fields more helpfully when printing objects #10311

Closed
@erictune

Description

When I do kubectl get foo/bar -o yaml, I see things like this:

apiVersion: v1beta3
foo: blah     <------------- why is this before kind and metadata?
kind: bar
metadata:
  creationTimestamp: 2015-06-24T21:09:17Z  
  name: myregistrykey  <----- why isn't this first because it is the most important metadata.
  namespace: default
  resourceVersion: "1497"
  selfLink: /api/v1beta3/namespaces/default/secrets/myregistrykey
  uid: 46703fde-1ab5-11e5-b558-42010af0cf71
zlist:
  - property: foo   
    name: bar   <---------- why isn't name always first?

It appears that tags are sorted alphabetically.
I'd rather always see fields that are in all objects at the top, so apiVersion, kind, and metadata should come before any kind-specific fields. (In the above example, field foo comes before metadata).

And I'd rather see name as the first property in a list for which name is the merge key.

Maybe this is just my opinion.

Metadata

Assignees

No one assigned

    Labels

    area/kubectlarea/usabilitylifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.priority/backlogHigher priority than priority/awaiting-more-evidence.sig/cliCategorizes an issue or PR as relevant to SIG CLI.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions