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

[WIP] Improve kubectl.GetPrinter #39095

Conversation

juanvallejo
Copy link
Contributor

@juanvallejo juanvallejo commented Dec 21, 2016

Fixes: #38779
Addresses an item from: #38768

Release note:

release-note-none

This patch prevents potential panics by callers of kubectl.GetPrinter by avoiding returning both a nil error and printer when the specified output format is wide.

I am hoping this can at least serve to start a discussion for how to handle this case in kubectl.GetPrinter. Both PrinterForMapping and PrinterForCommand make a call to kubectl.GetPrinter (PrinterForMapping calls this indirectly through a call to PrinterForCommand) and only avoid dealing with both a nil printer and nil error (when output format == wide) due to PrinterForCommand simply returning the results it receives from kubectl.GetPrinter, and PrinterForMapping creating an entirely new printer when this is the case.

An alternative solution to this could be to still return a nil printer in kubectl.GetPrinter, but return an error (such as unsupported output format) and have PrinterForCommand handle this error by either creating a NewHumanReadablePrinter at this point, or delegating the error to PrinterForMapping which already creates a NewHumanReadable printer when generic == false for kubectl.GetPrinter.

@fabianofranz

@k8s-ci-robot
Copy link
Contributor

Hi @juanvallejo. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with @k8s-bot ok to test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

If you have questions or suggestions related to this bot's behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Dec 21, 2016
@k8s-reviewable
Copy link

This change is Reviewable

@k8s-github-robot k8s-github-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Dec 21, 2016
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] Needs approval from an approver in each of these OWNERS Files:

We suggest the following people:
cc @sig-cli-maintainers
You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot
Copy link

@juanvallejo PR needs rebase

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 27, 2017
@k8s-github-robot
Copy link

This PR hasn't been active in 92 days. Closing this PR. Please reopen if you would like to work towards merging this change, if/when the PR is ready for the next round of review.

cc @adohe @fabianofranz @juanvallejo @smarterclayton

You can add 'keep-open' label to prevent this from happening again, or add a comment to keep it open another 90 days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants