-
Notifications
You must be signed in to change notification settings - Fork 40.7k
Support kubectl more flexible matching method to match whether the current resource type is node #88723
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
Support kubectl more flexible matching method to match whether the current resource type is node #88723
Conversation
/assign @mengqiy |
/lgtm Thanks for this fix. |
@@ -219,7 +219,7 @@ func (o TaintOptions) validateFlags() error { | |||
// Validate checks to the TaintOptions to see if there is sufficient information run the command. | |||
func (o TaintOptions) Validate() error { | |||
resourceType := strings.ToLower(o.resources[0]) | |||
validResources, isValidResource := []string{"node", "nodes"}, false | |||
validResources, isValidResource := []string{"node", "nodes", "no"}, false |
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.
This is very hacky, I'd prefer you use o.Mapper.KindFor
instead and then just verify if that's node or not. That's the preferred approach.
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.
Sorry, I have some doubts, can you describe the details
b4044b5
to
21bafa5
Compare
af2fe86
to
147bde6
Compare
147bde6
to
7d66a0b
Compare
c5c8295
to
a5c2529
Compare
|
||
gvk, _ := o.Mapper.KindFor(fullySpecifiedGVR) | ||
if gvk.Empty() { | ||
gvk, err = o.Mapper.KindFor(fullySpecifiedGVR.GroupResource().WithVersion("")) |
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.
You don't need that fallback, it will either match or not so you should check error from KindFor
execution.
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.
a5c2529
to
5549527
Compare
5549527
to
8fda1f3
Compare
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
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: soltysh, wawa0210 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 |
/priority backlog |
/retest Review the full test history for this PR. Silence the bot with an |
/test pull-kubernetes-integration |
What type of PR is this?
/kind feature
What this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Before the
kubectl taint
command only supported ["node", "nodes"], Now supports substitution byo.Mapper.KindFor
, more flexibleDoes this PR introduce a user-facing change?:
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: