-
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
This change add nonResourceURL to kubectl auth cani #46432
This change add nonResourceURL to kubectl auth cani #46432
Conversation
Hi @CaoShuFeng. 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. |
5b5dfba
to
2741590
Compare
pkg/kubectl/cmd/auth/cani.go
Outdated
errors := []error{} | ||
return utilerrors.NewAggregate(errors) | ||
if o.NonResourceURL != "" && o.Subresource != "" { | ||
return fmt.Errorf("--subresource can not be used with nonResourceURL") |
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.
neither can resources or resourceNames
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.
pkg/kubectl/cmd/auth/cani.go
Outdated
Subresource: o.Subresource, | ||
Name: o.ResourceName, | ||
var sar *authorizationapi.SelfSubjectAccessReview | ||
if o.Resource != (schema.GroupVersionResource{}) { |
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.
Seems like we should check for the presence of a nonresourceurl instead.
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.
Minor comments. I like the way it works. @fabianofranz any comment on usage? |
pkg/kubectl/cmd/auth/cani.go
Outdated
@@ -57,7 +57,7 @@ var ( | |||
Check whether an action is allowed. | |||
|
|||
VERB is a logical Kubernetes API verb like 'get', 'list', 'watch', 'delete', etc. | |||
TYPE is a Kubernetes resource. Shortcuts and groups will be resolved. | |||
TYPE is a Kubernetes resource. Shortcuts and groups will be resolved. If start with "/", TYPE will be treated as nonResourceURL. |
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.
Need to adjust the command usage to add the new arg type, something like:
kubectl auth can-i VERB [TYPE | TYPE/NAME | NONRESOURCEURL]
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.
pkg/kubectl/cmd/auth/cani.go
Outdated
# Check to see if I can read pod logs | ||
kubectl auth can-i get pods --subresource=log | ||
|
||
# Check to see if I can access url /logs/ |
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.
Check to see if I can access the URL "/logs"
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.
pkg/kubectl/cmd/auth/cani.go
Outdated
@@ -57,7 +57,7 @@ var ( | |||
Check whether an action is allowed. | |||
|
|||
VERB is a logical Kubernetes API verb like 'get', 'list', 'watch', 'delete', etc. | |||
TYPE is a Kubernetes resource. Shortcuts and groups will be resolved. | |||
TYPE is a Kubernetes resource. Shortcuts and groups will be resolved. If start with "/", TYPE will be treated as nonResourceURL. |
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.
Here in the description refer to it as a "Non-Resource URL".
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.
2741590
to
3bf3a03
Compare
@k8s-bot ok to test |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: CaoShuFeng, deads2k
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
@k8s-bot pull-kubernetes-e2e-gce-etcd3 test this |
@k8s-bot test this [submit-queue is verifying that this PR is safe to merge] |
@CaoShuFeng: The following test(s) failed:
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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. |
Automatic merge from submit-queue (batch tested with PRs 46432, 46701, 46326, 40848, 46396) |
Release note: