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

Improve custom-columns option of `kubectl get ` command #73063

Merged
merged 1 commit into from Jan 31, 2019

Conversation

@WanLinghao
Copy link
Contributor

WanLinghao commented Jan 18, 2019

/kind bug

What this PR does / why we need it:
The client-go library supports user get Object info in the form of .spec.containers[0:3].name.
But kubectl get command doesn't support this.
This patch fix this, now users could get object info like:
a. kubectl get pod test-pod -o custom-columns=CONTAINER:.spec.containers[0:3].name
b. kubectl get pod test-pod -o custom-columns=CONTAINER:.spec.containers[-2:].name

Special notes for your reviewer:
I will uncomment the test case after patch #72952 merged. Or panic would happen

Now users could get object info like:
a. kubectl get pod test-pod -o custom-columns=CONTAINER:.spec.containers[0:3].name
b. kubectl get pod test-pod -o custom-columns=CONTAINER:.spec.containers[-2:].name
// {
// name: "containers[-1], it equals containers[4]",
// spec: "CONTAINER:.spec.containers[-1].name",
// expectedOutput: `CONTAINER

This comment has been minimized.

@juanvallejo

juanvallejo Jan 18, 2019

Member

Did you mean to remove this?

This comment has been minimized.

@WanLinghao

WanLinghao Jan 19, 2019

Author Contributor

No, I commented them because it could trigger panic during test. Patch #72952 fix the panic. Now that path has been merged, I will uncomment them right now.

// name: "containers[3:1], illegal expression",
// spec: "CONTAINER:.spec.containers[3:1].name",
// expectedOutput: `CONTAINER
// <none>

This comment has been minimized.

@juanvallejo

juanvallejo Jan 18, 2019

Member

same here

@juanvallejo

This comment has been minimized.

Copy link
Member

juanvallejo commented Jan 18, 2019

/test pull-kubernetes-e2e-gce-100-performance

lgtm
Questions about a few commented-out cases.

cc @soltysh

@WanLinghao WanLinghao force-pushed the WanLinghao:kubectl_get_custom_clomuns_fix branch from 103f421 to 89fd3f4 Jan 19, 2019

@neolit123

This comment has been minimized.

Copy link
Member

neolit123 commented Jan 27, 2019

/kind cleanup
/priority backlog

@WanLinghao

This comment has been minimized.

Copy link
Contributor Author

WanLinghao commented Jan 30, 2019

@liggitt PTAL

@@ -76,14 +76,16 @@ func NewCustomColumnsPrinterFromSpec(spec string, decoder runtime.Decoder, noHea
columns := make([]Column, len(parts))
for ix := range parts {
colSpec := strings.Split(parts[ix], ":")

This comment has been minimized.

@liggitt

liggitt Jan 30, 2019

Member

prefer SplitN(parts[ix], ":", 2), then remaining code can stay as-is

The client-go library supports user get Object info in the form of .s…
…pec.containers[0:3].name.

But kubectl get command doesn't support this.
This patch fix this, now users could get object info like:
a. kubectl get pod test-pod -o custom-columns=CONTAINER:.spec.containers[0:3].name
b. kubectl get pod test-pod -o custom-columns=CONTAINER:.spec.containers[-2:].name

@WanLinghao WanLinghao force-pushed the WanLinghao:kubectl_get_custom_clomuns_fix branch from 89fd3f4 to 97ec74d Jan 31, 2019

@WanLinghao

This comment has been minimized.

Copy link
Contributor Author

WanLinghao commented Jan 31, 2019

@liggitt comments addressed, PTAL

@liggitt

This comment has been minimized.

Copy link
Member

liggitt commented Jan 31, 2019

/approve
/lgtm

@k8s-ci-robot

This comment has been minimized.

Copy link
Contributor

k8s-ci-robot commented Jan 31, 2019

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: liggitt, WanLinghao

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

@fejta-bot

This comment has been minimized.

Copy link

fejta-bot commented Jan 31, 2019

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@k8s-ci-robot k8s-ci-robot merged commit 29e9ff3 into kubernetes:master Jan 31, 2019

16 checks passed

cla/linuxfoundation WanLinghao authorized
Details
pull-kubernetes-bazel-build Job succeeded.
Details
pull-kubernetes-bazel-test Job succeeded.
Details
pull-kubernetes-cross Skipped
pull-kubernetes-e2e-gce Job succeeded.
Details
pull-kubernetes-e2e-gce-100-performance Job succeeded.
Details
pull-kubernetes-e2e-gce-device-plugin-gpu Job succeeded.
Details
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-local-e2e-containerized Skipped
pull-kubernetes-node-e2e Job succeeded.
Details
pull-kubernetes-typecheck Job succeeded.
Details
pull-kubernetes-verify Job succeeded.
Details
tide In merge pool.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment