55import org .slf4j .Logger ;
66import org .slf4j .LoggerFactory ;
77
8+ import io .fabric8 .kubernetes .api .model .HasMetadata ;
89import io .javaoperatorsdk .operator .health .EventSourceHealthIndicator ;
910import io .javaoperatorsdk .operator .health .InformerWrappingEventSourceHealthIndicator ;
1011import io .javaoperatorsdk .operator .processing .event .source .controller .ControllerEventSource ;
@@ -22,14 +23,15 @@ public class RuntimeInfo {
2223 private final Operator operator ;
2324
2425 public RuntimeInfo (Operator operator ) {
25- this .registeredControllers = operator .getRegisteredControllers ();
26+ this .registeredControllers = Collections . unmodifiableSet ( operator .getRegisteredControllers () );
2627 this .operator = operator ;
2728 }
2829
2930 public boolean isStarted () {
3031 return operator .isStarted ();
3132 }
3233
34+ @ SuppressWarnings ("unused" )
3335 public Set <RegisteredController > getRegisteredControllers () {
3436 checkIfStarted ();
3537 return registeredControllers ;
@@ -80,4 +82,23 @@ public Map<String, Map<String, EventSourceHealthIndicator>> unhealthyEventSource
8082 }
8183 return res ;
8284 }
85+
86+ /**
87+ * Retrieves the {@link RegisteredController} associated with the specified controller name or
88+ * {@code null} if no such controller is registered.
89+ *
90+ * @param controllerName the name of the {@link RegisteredController} to retrieve
91+ * @return the {@link RegisteredController} associated with the specified controller name or
92+ * {@code null} if no such controller is registered
93+ * @since 5.1.2
94+ */
95+ @ SuppressWarnings ({"unchecked" , "unused" })
96+ public RegisteredController <? extends HasMetadata > getRegisteredController (
97+ String controllerName ) {
98+ checkIfStarted ();
99+ return registeredControllers .stream ()
100+ .filter (rc -> rc .getConfiguration ().getName ().equals (controllerName ))
101+ .findFirst ()
102+ .orElse (null );
103+ }
83104}
0 commit comments