25
25
import io .javaoperatorsdk .operator .processing .dependent .kubernetes .KubernetesDependent ;
26
26
import io .javaoperatorsdk .operator .processing .dependent .kubernetes .KubernetesDependentResource ;
27
27
import io .javaoperatorsdk .operator .processing .dependent .kubernetes .KubernetesDependentResourceConfig ;
28
+ import io .javaoperatorsdk .operator .processing .dependent .workflow .Condition ;
28
29
import io .javaoperatorsdk .operator .processing .event .rate .RateLimiter ;
29
30
import io .javaoperatorsdk .operator .processing .event .source .controller .ResourceEventFilter ;
30
31
import io .javaoperatorsdk .operator .processing .event .source .controller .ResourceEventFilters ;
@@ -262,9 +263,9 @@ public List<DependentResourceSpec> getDependentResources() {
262
263
}
263
264
spec = new DependentResourceSpec (dependentType , config , name ,
264
265
Set .of (dependent .dependsOn ()),
265
- instantiateIfNotVoid (dependent .readyPostcondition (), VoidCondition . class ),
266
- instantiateIfNotVoid (dependent .reconcilePrecondition (), VoidCondition . class ),
267
- instantiateIfNotVoid (dependent .deletePostcondition (), VoidCondition . class ));
266
+ instantiateConditionIfNotVoid (dependent .readyPostcondition ()),
267
+ instantiateConditionIfNotVoid (dependent .reconcilePrecondition ()),
268
+ instantiateConditionIfNotVoid (dependent .deletePostcondition ()));
268
269
specsMap .put (name , spec );
269
270
}
270
271
@@ -325,8 +326,8 @@ private Object createKubernetesResourceConfig(Class<? extends DependentResource>
325
326
createFilter (kubeDependent .genericFilter (), FilterType .generic , kubeDependentName )
326
327
.orElse (null );
327
328
328
- resourceDiscriminator = instantiateIfNotVoid ( kubeDependent . resourceDiscriminator (),
329
- VoidResourceDiscriminator . class );
329
+ resourceDiscriminator =
330
+ instantiateDiscriminatorIfNotVoid ( kubeDependent . resourceDiscriminator () );
330
331
}
331
332
332
333
config =
@@ -337,6 +338,15 @@ private Object createKubernetesResourceConfig(Class<? extends DependentResource>
337
338
return config ;
338
339
}
339
340
341
+ @ SuppressWarnings ({"unchecked" })
342
+ private ResourceDiscriminator <?, ? extends HasMetadata > instantiateDiscriminatorIfNotVoid (
343
+ Class <? extends ResourceDiscriminator > discriminator ) {
344
+ if (discriminator != VoidResourceDiscriminator .class ) {
345
+ return instantiateAndConfigureIfNeeded (discriminator , ResourceDiscriminator .class );
346
+ }
347
+ return null ;
348
+ }
349
+
340
350
public static <T > T valueOrDefault (
341
351
ControllerConfiguration controllerConfiguration ,
342
352
Function <ControllerConfiguration , T > mapper ,
0 commit comments