3
3
import java .lang .reflect .InvocationTargetException ;
4
4
import java .util .Set ;
5
5
6
+ import io .fabric8 .kubernetes .api .model .GenericKubernetesResource ;
6
7
import io .fabric8 .kubernetes .api .model .HasMetadata ;
7
8
import io .javaoperatorsdk .operator .api .config .ControllerConfiguration ;
8
9
import io .javaoperatorsdk .operator .api .config .Utils ;
@@ -60,12 +61,14 @@ private InformerConfiguration<R> createInformerConfiguration(KubernetesDependent
60
61
var resourceType = dependentInstance .resourceType ();
61
62
62
63
InformerConfiguration .InformerConfigurationBuilder informerConfig ;
63
- if (resourceType .isAssignableFrom (GenericKubernetesDependentResource .class )) {
64
- if (configAnnotation .informerConfig () == null ||
65
- Constants .NO_VALUE_SET .equals (configAnnotation .informerConfig ().groupVersionKind ())) {
66
- throw new IllegalStateException (
67
- "Set groupVersionKind should be set when using GenericKubernetesResource" );
64
+ if (configAnnotation != null && configAnnotation .informerConfig () != null &&
65
+ !Constants .NO_VALUE_SET .equals (configAnnotation .informerConfig ().groupVersionKind ())) {
66
+
67
+ if (!GenericKubernetesResource .class .isAssignableFrom (resourceType )) {
68
+ throw new IllegalStateException ("If GroupVersionKind is set the resource type must be " +
69
+ "GenericKubernetesDependentResource. For: " + originatingClass .getName ());
68
70
}
71
+
69
72
informerConfig = InformerConfiguration .from (
70
73
GroupVersionKind .fromString (configAnnotation .informerConfig ().groupVersionKind ()),
71
74
controllerConfig .getResourceClass ());
@@ -77,7 +80,7 @@ private InformerConfiguration<R> createInformerConfiguration(KubernetesDependent
77
80
informerConfig .withSecondaryToPrimaryMapper (
78
81
dependentInstance .getSecondaryToPrimaryMapper ().orElse (null ));
79
82
80
- if (configAnnotation != null ) {
83
+ if (configAnnotation != null && configAnnotation . informerConfig () != null ) {
81
84
82
85
if (!Constants .NO_VALUE_SET .equals (configAnnotation .informerConfig ().name ())) {
83
86
informerConfig .withName (dependentInstance .name ());
0 commit comments