Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make kubectl describe more tolerant of newlines #66841

Merged
merged 4 commits into from
Aug 3, 2018

Conversation

smarterclayton
Copy link
Contributor

@smarterclayton smarterclayton commented Jul 31, 2018

Newlines in the command, args, env.value, or annotations fields are not uncommon. Wrap and indent these fields so that describe is more readable.

Before:

    Host Port:     <none>
    Command:
      /bin/bash
      -c
      #!/bin/bash
set -euo pipefail

# set by the node image
unset KUBECONFIG

trap 'kill $(jobs -p); exit 0' TERM

# track the current state of the config

After:

    Host Port:     <none>
    Command:
      /bin/bash
      -c
      #!/bin/bash
      set -euo pipefail

      # set by the node image
      unset KUBECONFIG

      trap 'kill $(jobs -p); exit 0' TERM

      # track the current state of the config

Annotations when wrapping:

Annotations:  kubectl.kubernetes.io/desired-replicas: 1
              openshift.io/deployer-pod.completed-at: 2018-07-31 22:47:15 +0000 UTC
              openshift.io/deployer-pod.created-at: 2018-07-31 22:37:11 +0000 UTC
              openshift.io/deployer-pod.name: test-3-deploy
              openshift.io/deployment-config.latest-version: 3
              openshift.io/deployment-config.name: test
              openshift.io/deployment.phase: Failed
              openshift.io/deployment.replicas: 0
              openshift.io/deployment.status-reason: manual change
              openshift.io/encoded-deployment-config:
                {"kind":"DeploymentConfig","apiVersion":"apps.openshift.io/v1","metadata":{"name":"test","namespace":"clayton-dev","selfLink":"/apis/apps.op...
Handle newlines for `command`, `args`, `env`, and `annotations` in `kubectl describe` wrapping

Inline scripts may use newlines in these fields, and properly indenting makes the output more readable:

```
  Command:
    /bin/bash
    -c
    #!/bin/bash
    echo "inline script should be indented"
```
Break env var values with newlines so they form a consistent left alignment.
Make annotations with newlines display a more consistent left edge, and indent the value
when the annotation is too long to give the value more space. Shorten the width of the
trimmed annotation to a value more consistent with our `-o wide` value.

Instead of putting the key and value flush with a `=` separator, make annotations closer
to fields than to labels by using `: ` as a separator.
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jul 31, 2018
@smarterclayton
Copy link
Contributor Author

@kubernetes/sig-cli-bugs

@k8s-ci-robot k8s-ci-robot added sig/cli Categorizes an issue or PR as relevant to SIG CLI. kind/bug Categorizes issue or PR as related to a bug. labels Jul 31, 2018
@smarterclayton
Copy link
Contributor Author

/retest

@juanvallejo
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 3, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: juanvallejo, smarterclayton

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 66911, 66841). If you want to cherry-pick this change to another branch, please follow the instructions here.

@k8s-github-robot k8s-github-robot merged commit 284964f into kubernetes:master Aug 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/cli Categorizes an issue or PR as relevant to SIG CLI. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants