-
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
kubectl create {clusterrole,role}
's --resources
flag support asterisk to specify all resources
#62945
kubectl create {clusterrole,role}
's --resources
flag support asterisk to specify all resources
#62945
Conversation
@@ -288,6 +293,9 @@ func (o *CreateRoleOptions) validateResource() error { | |||
} | |||
|
|||
if err != nil { | |||
if r.Resource == "*" && meta.IsNoMatchError(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.
Check this first, rather than in response to an error
@@ -192,6 +192,11 @@ func (o *CreateRoleOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args | |||
} | |||
resource.Resource = parts[0] | |||
|
|||
if resource.Resource == "*" && len(parts) == 1 && len(sections) == 1 { |
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 this before splitting into sections
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.
Hmm, actually, we probably want to allow * within a specific group
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.
Yes, I think that this line is better to put here to support specific groups like *.extensions
.
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 want to add a test for *.extensions
?
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.
Yes, I added it now.
Updated (leave Line#195 as it is). I hope that I didn't misunderstand your second comment regarding |
/ok-to-test |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
@@ -287,6 +292,9 @@ func (o *CreateRoleOptions) validateResource() error { | |||
} | |||
} | |||
|
|||
if r.Resource == "*" && meta.IsNoMatchError(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.
skip the lookup above if resource is "*"?
Thank you @liggitt Updated. |
please squash, then lgtm |
…risk to specify all resources
Sure, thank you. Squashed. |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: liggitt, nak3 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 |
Automatic merge from submit-queue (batch tested with PRs 67026, 62945, 66917). If you want to cherry-pick this change to another branch, please follow the instructions here. |
/sig cli |
@liggitt could you please tell which release this feature will be in? |
1.12 |
What this PR does / why we need it:
Currently
kubectl create (cluster)role
's--resources
flag does not support asterisk to specify all resources.As an user, we create a role with
--resources=*
sometimes, so this PR supports it.Fixes #62989
Special notes for your reviewer:
--resource=*
forSpecialVerbs
- e.gkubectl create role foo --verb=impersonate --resource=*
, because current code also does not supportkubectl create role foo --verb=impersonate --resource=users,pods
Release note: