-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
Improve custom-columns option of kubectl get
command
#73063
Conversation
ac3acec
to
103f421
Compare
// { | ||
// name: "containers[-1], it equals containers[4]", | ||
// spec: "CONTAINER:.spec.containers[-1].name", | ||
// expectedOutput: `CONTAINER |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
/test pull-kubernetes-e2e-gce-100-performance lgtm cc @soltysh |
103f421
to
89fd3f4
Compare
/kind cleanup |
@liggitt PTAL |
pkg/kubectl/cmd/get/customcolumn.go
Outdated
@@ -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], ":") |
There was a problem hiding this comment.
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
89fd3f4
to
97ec74d
Compare
@liggitt comments addressed, PTAL |
/approve |
[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 |
/retest Review the full test history for this PR. Silence the bot with an |
/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