-
Notifications
You must be signed in to change notification settings - Fork 40k
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
Fix forbidden message format #49006
Fix forbidden message format #49006
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 I understand the commands that are listed here. 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. |
/ok-to-test |
/test pull-kubernetes-bazel |
unit tests that check exact messages need updating (see unit test failures) LGTM otherwise |
e61e960
to
9776580
Compare
9776580
to
82a3dd7
Compare
I did a little more change after I see the unit tests. |
@@ -128,6 +128,15 @@ func NewUnauthorized(reason string) *StatusError { | |||
|
|||
// NewForbidden returns an error indicating the requested action was forbidden | |||
func NewForbidden(qualifiedResource schema.GroupResource, name string, err error) *StatusError { | |||
var message string | |||
res := qualifiedResource.String() | |||
if res == "" { |
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.
better to check qualifiedResource.Empty()
than rely on specific string serialization
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
2eeaa38
to
ab09186
Compare
Before this change: # kubectl get pods --as=tom Error from server (Forbidden): pods "" is forbidden: User "tom" cannot list pods in the namespace "default". After this change: # kubectl get pods --as=tom Error from server (Forbidden): pods is forbidden: User "tom" cannot list pods in the namespace "default".
/test pull-kubernetes-unit |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: CaoShuFeng, liggitt Associated issue requirement bypassed by: liggitt The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
/retest Review the full test history for this PR. |
/test pull-kubernetes-e2e-gce-etcd3 |
/test all [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue |
Before this change:
$ kubectl get pods --as=tom
Error from server (Forbidden): pods "" is forbidden: User "tom" cannot list pods in the namespace "default".
After this change:
$ kubectl get pods --as=tom
Error from server (Forbidden): pods is forbidden: User "tom" cannot list pods in the namespace "default".
What this PR does / why we need it:
Which issue this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close that issue when PR gets merged): fixes #Special notes for your reviewer:
Release note: