Skip to content

Commit b75ff27

Browse files
committed
fix: do not output warning when resolving a configuration
Signed-off-by: Chris Laprun <[email protected]>
1 parent 03a0949 commit b75ff27

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/BaseConfigurationService.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@
3030

3131
import static io.javaoperatorsdk.operator.api.config.ControllerConfiguration.CONTROLLER_NAME_AS_FIELD_MANAGER;
3232

33+
/**
34+
* A default {@link ConfigurationService} implementation, resolving {@link Reconciler}s
35+
* configuration when it has already been resolved before. If this behavior is not adequate, please
36+
* use {@link AbstractConfigurationService} instead as a base for your {@code ConfigurationService}
37+
* implementation.
38+
*/
3339
public class BaseConfigurationService extends AbstractConfigurationService {
3440

3541
private static final String LOGGER_NAME = "Default ConfigurationService implementation";
@@ -149,10 +155,12 @@ private static void configureFromAnnotatedReconciler(
149155

150156
@Override
151157
protected void logMissingReconcilerWarning(String reconcilerKey, String reconcilersNameMessage) {
152-
logger.warn(
153-
"Configuration for reconciler '{}' was not found. {}",
154-
reconcilerKey,
155-
reconcilersNameMessage);
158+
if (!createIfNeeded()) {
159+
logger.warn(
160+
"Configuration for reconciler '{}' was not found. {}",
161+
reconcilerKey,
162+
reconcilersNameMessage);
163+
}
156164
}
157165

158166
@SuppressWarnings("unused")
@@ -318,6 +326,13 @@ private <P extends HasMetadata> ResolvedControllerConfiguration<P> controllerCon
318326
informerConfig);
319327
}
320328

329+
/**
330+
* @deprecated This method was meant to allow subclasses to prevent automatic creation of the
331+
* configuration when not found. This functionality is now removed, if you want to be able to
332+
* prevent automated, on-demand creation of a reconciler's configuration, please use the
333+
* {@link AbstractConfigurationService} implementation instead as base for your extension.
334+
*/
335+
@Deprecated(forRemoval = true)
321336
protected boolean createIfNeeded() {
322337
return true;
323338
}

operator-framework/src/test/java/io/javaoperatorsdk/operator/config/BaseConfigurationServiceTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,13 @@ private static KubernetesDependentResourceConfig extractDependentKubernetesResou
8181
return (KubernetesDependentResourceConfig) configuration.getConfigurationFor(spec);
8282
}
8383

84+
@Test
85+
void test() {
86+
final var service = new BaseConfigurationService();
87+
final var config = service.getConfigurationFor(new NoDepReconciler());
88+
System.out.println(config);
89+
}
90+
8491
@Test
8592
@SuppressWarnings({"rawtypes", "unchecked"})
8693
void getDependentResources() {

0 commit comments

Comments
 (0)