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

Improve custom-columns option of kubectl get command #73063

Merged

Conversation

WanLinghao
Copy link
Contributor

/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

@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. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Jan 18, 2019
@k8s-ci-robot k8s-ci-robot added area/kubectl sig/cli Categorizes an issue or PR as relevant to SIG CLI. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jan 18, 2019
@WanLinghao WanLinghao force-pushed the kubectl_get_custom_clomuns_fix branch from ac3acec to 103f421 Compare January 18, 2019 07:08
// {
// name: "containers[-1], it equals containers[4]",
// spec: "CONTAINER:.spec.containers[-1].name",
// expectedOutput: `CONTAINER
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you mean to remove this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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>
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

@juanvallejo
Copy link
Contributor

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

lgtm
Questions about a few commented-out cases.

cc @soltysh

@WanLinghao WanLinghao force-pushed the kubectl_get_custom_clomuns_fix branch from 103f421 to 89fd3f4 Compare January 19, 2019 06:27
@neolit123
Copy link
Member

/kind cleanup
/priority backlog

@k8s-ci-robot k8s-ci-robot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. priority/backlog Higher priority than priority/awaiting-more-evidence. and removed needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Jan 27, 2019
@WanLinghao
Copy link
Contributor Author

@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], ":")
Copy link
Member

Choose a reason for hiding this comment

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

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

…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 kubectl_get_custom_clomuns_fix branch from 89fd3f4 to 97ec74d Compare January 31, 2019 01:39
@WanLinghao
Copy link
Contributor Author

@liggitt comments addressed, PTAL

@liggitt
Copy link
Member

liggitt commented Jan 31, 2019

/approve
/lgtm

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

[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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 31, 2019
@fejta-bot
Copy link

/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
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. area/kubectl cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/backlog Higher priority than priority/awaiting-more-evidence. 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

6 participants