-
Notifications
You must be signed in to change notification settings - Fork 39.8k
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
add kubectl api-resources command #42873
add kubectl api-resources command #42873
Conversation
Hi @xilabao. 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 Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
f523c7e
to
31aebf6
Compare
pkg/kubectl/cmd/apiresources.go
Outdated
Example: apiresources_example, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
err := RunApiResources(f, out) | ||
cmdutil.CheckErr(err) |
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.
I think we can move those two lines into one
pkg/kubectl/cmd/apiresources.go
Outdated
|
||
func RunApiResources(f cmdutil.Factory, output io.Writer) error { | ||
w := tabwriter.NewWriter(output, 10, 4, 3, ' ', 0) | ||
fmt.Fprintln(w, "NAME\tNAMESPACED\tKIND\tVERBS") |
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.
why not add to HumanReadablePrinter
?
pkg/kubectl/cmd/apiresources.go
Outdated
} | ||
sort.Strings(resources) | ||
for _, r := range resources { | ||
if _, err := fmt.Fprintf(w, "%s\t%v\t%s\t%v\n", m[r].Name, m[r].Namespaced, m[r].Kind, m[r].Verbs); err != nil { |
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.
should we also support other format of output like json, yaml ?
cc @kubernetes/sig-cli-feature-requests @kubernetes/sig-cli-pr-reviews @deads2k @smarterclayton @xilabao is there a proposal or issue related to this? |
31aebf6
to
9fbe191
Compare
you would also need to know the API group showing a resource that allows no verbs is debatable |
Please also take aggregated api-servers into consideration @xilabao |
If you use discovery data, aggregated servers and TPR data will automatically work |
API group |
I would not expect someone to use this as an API… if they want that, they should use the actual discovery API |
This is exactly what I expect, we should figure out the real use case of this command. |
9fbe191
to
7af26ec
Compare
7af26ec
to
5421370
Compare
@ALL PTAL |
pkg/kubectl/cmd/apiresources.go
Outdated
|
||
func RunApiResources(f cmdutil.Factory, output io.Writer) error { | ||
w := printers.GetNewTabWriter(output) | ||
fmt.Fprintln(w, "NAME\tNAMESPACED\tAPIGROUP\tKIND\tVERBS") |
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.
I would expect we move this down before where we really need to output.
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.
Done.
5421370
to
bd86db0
Compare
/assign @adohe |
/test pull-kubernetes-e2e-kops-aws |
@tengqm: you can't request testing unless you are a kubernetes member. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
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.
/lgtm
/approve no-issue
/retest |
[MILESTONENOTIFIER] Milestone Pull Request: Up-to-date for process Pull Request Labels
|
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: adohe, smarterclayton, soltysh, xilabao 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 |
/test all [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here. |
Automatic merge from submit-queue (batch tested with PRs 63589, 63644, 63861, 63872, 63847). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. cleanup kubectl apiresources **What this PR does / why we need it**: #42873 introduce this new subcommand. This PR does * binding flags to struct * some code cleanups **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes # **Special notes for your reviewer**: /cc soltysh juanvallejo **Release note**: ```release-note None ```
Is there a way to query for sub resource like pods/log, pods/status etc? |
there is not currently |
What this PR does / why we need it:
As the RBAC role need to be related to resources. I think we can use the command to get the supported resources.
Which issue this PR fixes: fixes #42932
Special notes for your reviewer:
Release note: