22
22
import io .kubernetes .client .openapi .models .V1HostPathVolumeSource ;
23
23
import io .kubernetes .client .openapi .models .V1NodeAffinity ;
24
24
import io .kubernetes .client .openapi .models .V1NodeSelector ;
25
+ import io .kubernetes .client .openapi .models .V1NodeSelectorTerm ;
25
26
import io .kubernetes .client .openapi .models .V1PersistentVolumeClaimVolumeSource ;
26
27
import io .kubernetes .client .openapi .models .V1PodAffinity ;
28
+ import io .kubernetes .client .openapi .models .V1PodAffinityTerm ;
27
29
import io .kubernetes .client .openapi .models .V1PodAntiAffinity ;
28
30
import io .kubernetes .client .openapi .models .V1PodReadinessGate ;
29
31
import io .kubernetes .client .openapi .models .V1PodSecurityContext ;
32
+ import io .kubernetes .client .openapi .models .V1PreferredSchedulingTerm ;
30
33
import io .kubernetes .client .openapi .models .V1ResourceRequirements ;
31
34
import io .kubernetes .client .openapi .models .V1SecurityContext ;
32
35
import io .kubernetes .client .openapi .models .V1Toleration ;
33
36
import io .kubernetes .client .openapi .models .V1Volume ;
34
37
import io .kubernetes .client .openapi .models .V1VolumeMount ;
38
+ import io .kubernetes .client .openapi .models .V1WeightedPodAffinityTerm ;
35
39
import oracle .kubernetes .json .Description ;
36
40
import org .apache .commons .lang3 .builder .EqualsBuilder ;
37
41
import org .apache .commons .lang3 .builder .HashCodeBuilder ;
@@ -266,25 +270,15 @@ private void copyValues(V1SecurityContext to, V1SecurityContext from) {
266
270
267
271
private void copyValues (V1Capabilities to , V1Capabilities from ) {
268
272
if (from .getAdd () != null ) {
269
- List <String > allAddCapabilities = new ArrayList <>();
270
- if (to .getAdd () != null ) {
271
- allAddCapabilities =
272
- Stream .concat (to .getAdd ().stream (), from .getAdd ().stream ())
273
- .distinct ()
274
- .collect (Collectors .toList ());
275
- }
276
- to .setAdd (allAddCapabilities );
273
+ Stream <String > stream = (to .getAdd () != null )
274
+ ? Stream .concat (to .getAdd ().stream (), from .getAdd ().stream ()) : from .getAdd ().stream ();
275
+ to .setAdd (stream .distinct ().collect (Collectors .toList ()));
277
276
}
278
277
279
278
if (from .getDrop () != null ) {
280
- List <String > allDropCapabilities = new ArrayList <>();
281
- if (to .getDrop () != null ) {
282
- allDropCapabilities =
283
- Stream .concat (to .getDrop ().stream (), from .getDrop ().stream ())
284
- .distinct ()
285
- .collect (Collectors .toList ());
286
- }
287
- to .setDrop (allDropCapabilities );
279
+ Stream <String > stream = (to .getDrop () != null )
280
+ ? Stream .concat (to .getDrop ().stream (), from .getDrop ().stream ()) : from .getDrop ().stream ();
281
+ to .setDrop (stream .distinct ().collect (Collectors .toList ()));
288
282
}
289
283
}
290
284
@@ -307,12 +301,14 @@ private void copyValues(V1Affinity to, V1Affinity from) {
307
301
}
308
302
309
303
private void copyValues (V1NodeAffinity to , V1NodeAffinity from ) {
310
- if (to .getPreferredDuringSchedulingIgnoredDuringExecution () == null ) {
311
- to .setPreferredDuringSchedulingIgnoredDuringExecution (from .getPreferredDuringSchedulingIgnoredDuringExecution ());
312
- } else if (from .getPreferredDuringSchedulingIgnoredDuringExecution () != null ) {
313
- from .getPreferredDuringSchedulingIgnoredDuringExecution ()
314
- .forEach (to ::addPreferredDuringSchedulingIgnoredDuringExecutionItem );
304
+ if (from .getPreferredDuringSchedulingIgnoredDuringExecution () != null ) {
305
+ Stream <V1PreferredSchedulingTerm > stream = (to .getPreferredDuringSchedulingIgnoredDuringExecution () != null )
306
+ ? Stream .concat (to .getPreferredDuringSchedulingIgnoredDuringExecution ().stream (),
307
+ from .getPreferredDuringSchedulingIgnoredDuringExecution ().stream ())
308
+ : from .getPreferredDuringSchedulingIgnoredDuringExecution ().stream ();
309
+ to .setPreferredDuringSchedulingIgnoredDuringExecution (stream .distinct ().collect (Collectors .toList ()));
315
310
}
311
+
316
312
if (to .getRequiredDuringSchedulingIgnoredDuringExecution () == null ) {
317
313
to .setRequiredDuringSchedulingIgnoredDuringExecution (from .getRequiredDuringSchedulingIgnoredDuringExecution ());
318
314
} else if (from .getRequiredDuringSchedulingIgnoredDuringExecution () != null ) {
@@ -321,41 +317,49 @@ private void copyValues(V1NodeAffinity to, V1NodeAffinity from) {
321
317
}
322
318
}
323
319
324
- private void copyValues (V1NodeSelector to ,V1NodeSelector from ) {
325
- if (to .getNodeSelectorTerms () == null ) {
326
- to .setNodeSelectorTerms (from .getNodeSelectorTerms ());
327
- } else if (from .getNodeSelectorTerms () != null ) {
328
- from .getNodeSelectorTerms ().forEach (to ::addNodeSelectorTermsItem );
320
+ private void copyValues (V1NodeSelector to , V1NodeSelector from ) {
321
+ if (from .getNodeSelectorTerms () != null ) {
322
+ Stream <V1NodeSelectorTerm > stream = (to .getNodeSelectorTerms () != null )
323
+ ? Stream .concat (to .getNodeSelectorTerms ().stream (),
324
+ from .getNodeSelectorTerms ().stream ())
325
+ : from .getNodeSelectorTerms ().stream ();
326
+ to .setNodeSelectorTerms (stream .distinct ().collect (Collectors .toList ()));
329
327
}
330
328
}
331
329
332
330
private void copyValues (V1PodAffinity to , V1PodAffinity from ) {
333
- if (to .getPreferredDuringSchedulingIgnoredDuringExecution () == null ) {
334
- to .setPreferredDuringSchedulingIgnoredDuringExecution (from .getPreferredDuringSchedulingIgnoredDuringExecution ());
335
- } else if (from .getPreferredDuringSchedulingIgnoredDuringExecution () != null ) {
336
- from .getPreferredDuringSchedulingIgnoredDuringExecution ()
337
- .forEach (to ::addPreferredDuringSchedulingIgnoredDuringExecutionItem );
331
+ if (from .getPreferredDuringSchedulingIgnoredDuringExecution () != null ) {
332
+ Stream <V1WeightedPodAffinityTerm > stream = (to .getPreferredDuringSchedulingIgnoredDuringExecution () != null )
333
+ ? Stream .concat (to .getPreferredDuringSchedulingIgnoredDuringExecution ().stream (),
334
+ from .getPreferredDuringSchedulingIgnoredDuringExecution ().stream ())
335
+ : from .getPreferredDuringSchedulingIgnoredDuringExecution ().stream ();
336
+ to .setPreferredDuringSchedulingIgnoredDuringExecution (stream .distinct ().collect (Collectors .toList ()));
338
337
}
339
- if (to .getRequiredDuringSchedulingIgnoredDuringExecution () == null ) {
340
- to .setRequiredDuringSchedulingIgnoredDuringExecution (from .getRequiredDuringSchedulingIgnoredDuringExecution ());
341
- } else if (from .getRequiredDuringSchedulingIgnoredDuringExecution () != null ) {
342
- from .getRequiredDuringSchedulingIgnoredDuringExecution ()
343
- .forEach (to ::addRequiredDuringSchedulingIgnoredDuringExecutionItem );
338
+
339
+ if (from .getRequiredDuringSchedulingIgnoredDuringExecution () != null ) {
340
+ Stream <V1PodAffinityTerm > stream = (to .getRequiredDuringSchedulingIgnoredDuringExecution () != null )
341
+ ? Stream .concat (to .getRequiredDuringSchedulingIgnoredDuringExecution ().stream (),
342
+ from .getRequiredDuringSchedulingIgnoredDuringExecution ().stream ())
343
+ : from .getRequiredDuringSchedulingIgnoredDuringExecution ().stream ();
344
+ to .setRequiredDuringSchedulingIgnoredDuringExecution (stream .distinct ().collect (Collectors .toList ()));
344
345
}
345
346
}
346
347
347
348
private void copyValues (V1PodAntiAffinity to , V1PodAntiAffinity from ) {
348
- if (to .getPreferredDuringSchedulingIgnoredDuringExecution () == null ) {
349
- to .setPreferredDuringSchedulingIgnoredDuringExecution (from .getPreferredDuringSchedulingIgnoredDuringExecution ());
350
- } else if (from .getPreferredDuringSchedulingIgnoredDuringExecution () != null ) {
351
- from .getPreferredDuringSchedulingIgnoredDuringExecution ()
352
- .forEach (to ::addPreferredDuringSchedulingIgnoredDuringExecutionItem );
349
+ if (from .getPreferredDuringSchedulingIgnoredDuringExecution () != null ) {
350
+ Stream <V1WeightedPodAffinityTerm > stream = (to .getPreferredDuringSchedulingIgnoredDuringExecution () != null )
351
+ ? Stream .concat (to .getPreferredDuringSchedulingIgnoredDuringExecution ().stream (),
352
+ from .getPreferredDuringSchedulingIgnoredDuringExecution ().stream ())
353
+ : from .getPreferredDuringSchedulingIgnoredDuringExecution ().stream ();
354
+ to .setPreferredDuringSchedulingIgnoredDuringExecution (stream .distinct ().collect (Collectors .toList ()));
353
355
}
354
- if (to .getRequiredDuringSchedulingIgnoredDuringExecution () == null ) {
355
- to .setRequiredDuringSchedulingIgnoredDuringExecution (from .getRequiredDuringSchedulingIgnoredDuringExecution ());
356
- } else if (from .getRequiredDuringSchedulingIgnoredDuringExecution () != null ) {
357
- from .getRequiredDuringSchedulingIgnoredDuringExecution ()
358
- .forEach (to ::addRequiredDuringSchedulingIgnoredDuringExecutionItem );
356
+
357
+ if (from .getRequiredDuringSchedulingIgnoredDuringExecution () != null ) {
358
+ Stream <V1PodAffinityTerm > stream = (to .getRequiredDuringSchedulingIgnoredDuringExecution () != null )
359
+ ? Stream .concat (to .getRequiredDuringSchedulingIgnoredDuringExecution ().stream (),
360
+ from .getRequiredDuringSchedulingIgnoredDuringExecution ().stream ())
361
+ : from .getRequiredDuringSchedulingIgnoredDuringExecution ().stream ();
362
+ to .setRequiredDuringSchedulingIgnoredDuringExecution (stream .distinct ().collect (Collectors .toList ()));
359
363
}
360
364
}
361
365
@@ -811,4 +815,4 @@ public int hashCode() {
811
815
.append (serviceAccountName )
812
816
.toHashCode ();
813
817
}
814
- }
818
+ }
0 commit comments