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

Fix bad column alignment when using custom columns from OpenAPI schema #56629

Merged

Conversation

luksa
Copy link
Contributor

@luksa luksa commented Nov 30, 2017

Columns printed by kubectl get weren't aligned properly when they were coming from the OpenAPI schema.

This was caused by CustomColumnPrinter.PrintObj, which was creating a new tabwriter.Writer instead of re-using the tabwriter received through the out method parameter (basically, a tabwriter was writing to another tabwriter). Because the PrintObj flushed the tabwriter after writing each individual line, the column widths would reset.

What this PR does / why we need it:
This PR fixes the bad column alignment.

Which issue(s) this PR fixes
Fixes #56282

Special notes for your reviewer:
I've aligned how CustomColumnPrinter.PrintObj handles tabwriter with how HumanReadablePrinter.PrintObj does it (see https://github.com/kubernetes/kubernetes/blob/master/pkg/printers/humanreadable.go#L299-L303)

Release note:

Fixed column alignment when kubectl get is used with custom columns from OpenAPI schema

@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/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 30, 2017
@dims
Copy link
Member

dims commented Nov 30, 2017

/ok-to-test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Nov 30, 2017
@luksa
Copy link
Contributor Author

luksa commented Nov 30, 2017

/sig cli

@k8s-ci-robot k8s-ci-robot added the sig/cli Categorizes an issue or PR as relevant to SIG CLI. label Nov 30, 2017
@dims
Copy link
Member

dims commented Dec 1, 2017

/unassign @dims

@nikhita
Copy link
Member

nikhita commented Jan 16, 2018

/cc @deads2k

@deads2k
Copy link
Contributor

deads2k commented Jan 16, 2018

/assign @soltysh

@luksa
Copy link
Contributor Author

luksa commented Feb 21, 2018

/retest

Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approve

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: luksa, soltysh

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

@kubernetes kubernetes deleted a comment from k8s-github-robot Mar 21, 2018
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 21, 2018
@mvladev
Copy link

mvladev commented Apr 5, 2018

/retest

@k8s-github-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@k8s-github-robot
Copy link

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here.

@k8s-github-robot k8s-github-robot merged commit 9f4b851 into kubernetes:master Apr 5, 2018
@luksa luksa deleted the fix_custom_column_alignment branch April 10, 2018 00:35
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. 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/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bad column alignment when printing custom columns from OpenAPI schema
9 participants