-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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 taint: copy core taintutil dependency into kubectl #69446
Conversation
/kind cleanup |
/sig cli |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: seans3 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 |
/cc @soltysh |
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.
/hold
I'm putting together a PR reshuffling all the commands into separate directories. Then copy only the necessary utils for taint command into that dir.
See #69464 for the restructuring. |
/hold |
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've left you some comments. The rule of thumb is these should be private helpers to a specific command. We are already risking quite a bit by copying them, but we need to ensure that they should not escape from outside this command dir.
pkg/kubectl/cmd/taint/utils.go
Outdated
) | ||
|
||
// ParseTaints takes a spec which is an array and creates slices for new taints to be added, taints to be deleted. | ||
func ParseTaints(spec []string) ([]corev1.Taint, []corev1.Taint, error) { |
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.
Can you make it private?
pkg/kubectl/cmd/taint/utils.go
Outdated
|
||
// ReorganizeTaints returns the updated set of taints, taking into account old taints that were not updated, | ||
// old taints that were updated, old taints that were deleted, and new taints. | ||
func ReorganizeTaints(node *corev1.Node, overwrite bool, taintsToAdd []corev1.Taint, taintsToRemove []corev1.Taint) (string, []corev1.Taint, error) { |
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.
Ditto?
pkg/kubectl/cmd/taint/utils.go
Outdated
} | ||
|
||
// CheckIfTaintsAlreadyExists checks if the node already has taints that we want to add and returns a string with taint keys. | ||
func CheckIfTaintsAlreadyExists(oldTaints []corev1.Taint, taints []corev1.Taint) string { |
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.
Same here
pkg/kubectl/cmd/taint/utils.go
Outdated
} | ||
|
||
// DeleteTaintsByKey removes all the taints that have the same key to given taintKey | ||
func DeleteTaintsByKey(taints []corev1.Taint, taintKey string) ([]corev1.Taint, bool) { |
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.
And here.
pkg/kubectl/cmd/taint/utils.go
Outdated
} | ||
|
||
// DeleteTaint removes all the taints that have the same key and effect to given taintToDelete. | ||
func DeleteTaint(taints []corev1.Taint, taintToDelete *corev1.Taint) ([]corev1.Taint, bool) { |
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.
That too.
pkg/kubectl/cmd/taint/utils.go
Outdated
@@ -0,0 +1,209 @@ | |||
/* | |||
Copyright 2016 The Kubernetes Authors. |
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.
Since this is a new file you might need to update the date to current year.
8431a4f
to
8f57054
Compare
/lgtm |
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
/hold cancel |
/lgtm |
Helps address:
kubernetes/kubectl#80