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

kubectl: eliminate unnecessary blank ending line #81229

Merged
merged 2 commits into from Aug 13, 2019

Conversation

@Huang-Wei
Copy link
Member

commented Aug 9, 2019

What type of PR is this?

/kind bug

What this PR does / why we need it:

The background is that even with #78774, kubectl get all (or kubectl get res1,res2) still outputs a blank line if the last resource(res2) has no elements.

⇒  _output/local/bin/darwin/amd64/kubectl get svc,po                                                                                      local-up-cluster
NAME                 TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE
service/kubernetes   ClusterIP   10.0.0.1     <none>        443/TCP   64m
<empty line here>

Which issue(s) this PR fixes:

Supplement of #78774.

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

kubectl: eliminate unnecessary blank ending line.

/sig cli
/assign @liggitt

@@ -552,7 +554,7 @@ func (o *GetOptions) Run(f cmdutil.Factory, cmd *cobra.Command, args []string) e
if lastMapping != nil && !o.NoHeaders {
// If we've written output since the last time we started a new set of headers, write an empty line to separate object types
if written != trackingWriter.Written {

This comment has been minimized.

Copy link
@liggitt

liggitt Aug 9, 2019

Member

I think we can replace all of this with resetting the separatorWriter if any output has ever been written

- // If we've written output since the last time we started a new set of headers, write an empty line to separate object types
- if written != trackingWriter.Written {
-   fmt.Fprintln(w)
-   written = trackingWriter.Written
- }
+ if trackingWriter.Written > 0 {
+   separatorWriter.SetReady(true)
+ }

This comment has been minimized.

Copy link
@Huang-Wei

Huang-Wei Aug 9, 2019

Author Member

That's neat. Thanks.

Updated the logic, comments and added a testcase. PTAL.

@k8s-ci-robot k8s-ci-robot added size/L and removed size/M labels Aug 9, 2019

@Huang-Wei

This comment has been minimized.

Copy link
Member Author

commented Aug 9, 2019

TestPreemptWithPermitPlugin flake: #81238

/retest

// 2) it has row header
// 3) we've written output since the last time we started a new set of headers
if lastMapping != nil && !o.NoHeaders && trackingWriter.Written > 0 {
if trackingWriter.Written > 0 {

This comment has been minimized.

Copy link
@liggitt

liggitt Aug 9, 2019

Member

no need to check trackingWriter.Written > 0 twice

This comment has been minimized.

Copy link
@Huang-Wei

Huang-Wei Aug 9, 2019

Author Member

Forgot to remove the original line when I moved it up.. Updated.

@Huang-Wei Huang-Wei force-pushed the Huang-Wei:kubectl-empty-line branch from 2d0cb1b to 6a0d563 Aug 9, 2019

@dims

This comment has been minimized.

Copy link
Member

commented Aug 10, 2019

/uncc

@k8s-ci-robot k8s-ci-robot removed the request for review from dims Aug 10, 2019

@liggitt

This comment has been minimized.

Copy link
Member

commented Aug 13, 2019

/lgtm
/approve

@k8s-ci-robot

This comment has been minimized.

Copy link
Contributor

commented Aug 13, 2019

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Huang-Wei, liggitt

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-ci-robot k8s-ci-robot merged commit a4d97cc into kubernetes:master Aug 13, 2019

23 checks passed

cla/linuxfoundation Huang-Wei authorized
Details
pull-kubernetes-bazel-build Job succeeded.
Details
pull-kubernetes-bazel-test Job succeeded.
Details
pull-kubernetes-conformance-image-test Skipped.
pull-kubernetes-cross Skipped.
pull-kubernetes-dependencies Job succeeded.
Details
pull-kubernetes-e2e-gce Job succeeded.
Details
pull-kubernetes-e2e-gce-100-performance Job succeeded.
Details
pull-kubernetes-e2e-gce-csi-serial Skipped.
pull-kubernetes-e2e-gce-device-plugin-gpu Job succeeded.
Details
pull-kubernetes-e2e-gce-iscsi Skipped.
pull-kubernetes-e2e-gce-iscsi-serial Skipped.
pull-kubernetes-e2e-gce-storage-slow Skipped.
pull-kubernetes-godeps Skipped.
pull-kubernetes-integration Job succeeded.
Details
pull-kubernetes-kubemark-e2e-gce-big Job succeeded.
Details
pull-kubernetes-local-e2e Skipped.
pull-kubernetes-node-e2e Job succeeded.
Details
pull-kubernetes-node-e2e-containerd Job succeeded.
Details
pull-kubernetes-typecheck Job succeeded.
Details
pull-kubernetes-verify Job succeeded.
Details
pull-publishing-bot-validate Skipped.
tide In merge pool.
Details

@k8s-ci-robot k8s-ci-robot added this to the v1.16 milestone Aug 13, 2019

@Huang-Wei Huang-Wei deleted the Huang-Wei:kubectl-empty-line branch Aug 13, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.