@@ -125,7 +125,7 @@ func validateTaintEffect(effect corev1.TaintEffect) error {
125
125
return nil
126
126
}
127
127
128
- // ReorganizeTaints returns the updated set of taints, taking into account old taints that were not updated,
128
+ // reorganizeTaints returns the updated set of taints, taking into account old taints that were not updated,
129
129
// old taints that were updated, old taints that were deleted, and new taints.
130
130
func reorganizeTaints (node * corev1.Node , overwrite bool , taintsToAdd []corev1.Taint , taintsToRemove []corev1.Taint ) (string , []corev1.Taint , error ) {
131
131
newTaints := append ([]corev1.Taint {}, taintsToAdd ... )
@@ -177,7 +177,7 @@ func addTaints(oldTaints []corev1.Taint, newTaints *[]corev1.Taint) bool {
177
177
return len (oldTaints ) != len (* newTaints )
178
178
}
179
179
180
- // CheckIfTaintsAlreadyExists checks if the node already has taints that we want to add and returns a string with taint keys.
180
+ // checkIfTaintsAlreadyExists checks if the node already has taints that we want to add and returns a string with taint keys.
181
181
func checkIfTaintsAlreadyExists (oldTaints []corev1.Taint , taints []corev1.Taint ) string {
182
182
var existingTaintList = make ([]string , 0 )
183
183
for _ , taint := range taints {
@@ -190,30 +190,26 @@ func checkIfTaintsAlreadyExists(oldTaints []corev1.Taint, taints []corev1.Taint)
190
190
return strings .Join (existingTaintList , "," )
191
191
}
192
192
193
- // DeleteTaintsByKey removes all the taints that have the same key to given taintKey
193
+ // deleteTaintsByKey removes all the taints that have the same key to given taintKey
194
194
func deleteTaintsByKey (taints []corev1.Taint , taintKey string ) ([]corev1.Taint , bool ) {
195
195
newTaints := []corev1.Taint {}
196
- deleted := false
197
196
for i := range taints {
198
197
if taintKey == taints [i ].Key {
199
- deleted = true
200
198
continue
201
199
}
202
200
newTaints = append (newTaints , taints [i ])
203
201
}
204
- return newTaints , deleted
202
+ return newTaints , len ( taints ) != len ( newTaints )
205
203
}
206
204
207
- // DeleteTaint removes all the taints that have the same key and effect to given taintToDelete.
205
+ // deleteTaint removes all the taints that have the same key and effect to given taintToDelete.
208
206
func deleteTaint (taints []corev1.Taint , taintToDelete * corev1.Taint ) ([]corev1.Taint , bool ) {
209
207
newTaints := []corev1.Taint {}
210
- deleted := false
211
208
for i := range taints {
212
209
if taintToDelete .MatchTaint (& taints [i ]) {
213
- deleted = true
214
210
continue
215
211
}
216
212
newTaints = append (newTaints , taints [i ])
217
213
}
218
- return newTaints , deleted
214
+ return newTaints , len ( taints ) != len ( newTaints )
219
215
}
0 commit comments