Skip to content

Commit 4b5eff8

Browse files
committed
fix: format and EventDispatcherTest
1 parent 685ee12 commit 4b5eff8

35 files changed

+422
-405
lines changed

Diff for: operator-framework-core/src/main/java/io/javaoperatorsdk/operator/ControllerUtils.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package io.javaoperatorsdk.operator;
22

3+
import java.util.Locale;
4+
35
import io.javaoperatorsdk.operator.api.Controller;
46
import io.javaoperatorsdk.operator.api.ResourceController;
57

6-
import java.util.Locale;
7-
88
@SuppressWarnings("rawtypes")
99
public class ControllerUtils {
1010

Diff for: operator-framework-core/src/main/java/io/javaoperatorsdk/operator/Operator.java

+24-23
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
package io.javaoperatorsdk.operator;
22

3+
import java.net.ConnectException;
4+
import java.util.ArrayList;
5+
import java.util.HashMap;
6+
import java.util.List;
7+
import java.util.Map;
8+
9+
import org.slf4j.Logger;
10+
import org.slf4j.LoggerFactory;
11+
312
import io.fabric8.kubernetes.client.CustomResource;
413
import io.fabric8.kubernetes.client.DefaultKubernetesClient;
514
import io.fabric8.kubernetes.client.KubernetesClient;
@@ -10,14 +19,6 @@
1019
import io.javaoperatorsdk.operator.api.config.ControllerConfiguration;
1120
import io.javaoperatorsdk.operator.api.config.ExecutorServiceManager;
1221
import io.javaoperatorsdk.operator.processing.ConfiguredController;
13-
import org.slf4j.Logger;
14-
import org.slf4j.LoggerFactory;
15-
16-
import java.net.ConnectException;
17-
import java.util.ArrayList;
18-
import java.util.HashMap;
19-
import java.util.List;
20-
import java.util.Map;
2122

2223
@SuppressWarnings("rawtypes")
2324
public class Operator implements AutoCloseable, LifecycleAware {
@@ -110,12 +111,12 @@ public void close() {
110111
* registration of the controller is delayed till the operator is started.
111112
*
112113
* @param controller the controller to register
113-
* @param <R> the {@code CustomResource} type associated with the controller
114+
* @param <R> the {@code CustomResource} type associated with the controller
114115
* @throws OperatorException if a problem occurred during the registration process
115116
*/
116117
public <R extends CustomResource<?, ?>> void register(ResourceController<R> controller)
117-
throws OperatorException {
118-
register(controller, null);
118+
throws OperatorException {
119+
register(controller, null);
119120
}
120121

121122
/**
@@ -132,22 +133,22 @@ public void close() {
132133
* @throws OperatorException if a problem occurred during the registration process
133134
*/
134135
public <R extends CustomResource<?, ?>> void register(
135-
ResourceController<R> controller, ControllerConfiguration<R> configuration)
136-
throws OperatorException {
137-
final var existing = configurationService.getConfigurationFor(controller);
138-
if (existing == null) {
139-
log.warn(
140-
"Skipping registration of {} controller named {} because its configuration cannot be found.\n"
141-
+ "Known controllers are: {}",
142-
controller.getClass().getCanonicalName(),
143-
ControllerUtils.getNameFor(controller),
144-
configurationService.getKnownControllerNames());
136+
ResourceController<R> controller, ControllerConfiguration<R> configuration)
137+
throws OperatorException {
138+
final var existing = configurationService.getConfigurationFor(controller);
139+
if (existing == null) {
140+
log.warn(
141+
"Skipping registration of {} controller named {} because its configuration cannot be found.\n"
142+
+ "Known controllers are: {}",
143+
controller.getClass().getCanonicalName(),
144+
ControllerUtils.getNameFor(controller),
145+
configurationService.getKnownControllerNames());
145146
} else {
146147
if (configuration == null) {
147148
configuration = existing;
148149
}
149-
final var configuredController =
150-
new ConfiguredController<>(controller, configuration, kubernetesClient);
150+
final var configuredController =
151+
new ConfiguredController<>(controller, configuration, kubernetesClient);
151152
controllers.add(configuredController);
152153

153154
final var watchedNS =

Diff for: operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/BaseControl.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55

66
public abstract class BaseControl<T extends BaseControl<T>> {
77

8-
private Long scheduleDelay = null;
8+
private Long scheduleDelay = null;
99

10-
public T rescheduleAfter(long delay) {
11-
this.scheduleDelay = delay;
12-
return (T) this;
13-
}
10+
public T rescheduleAfter(long delay) {
11+
this.scheduleDelay = delay;
12+
return (T) this;
13+
}
1414

15-
public T rescheduleAfter(long delay, TimeUnit timeUnit) {
16-
return rescheduleAfter(timeUnit.toMillis(delay));
15+
public T rescheduleAfter(long delay, TimeUnit timeUnit) {
16+
return rescheduleAfter(timeUnit.toMillis(delay));
1717
}
1818

1919
public Optional<Long> getScheduleDelay() {

Diff for: operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/Context.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44

55
public interface Context {
66

7-
Optional<RetryInfo> getRetryInfo();
7+
Optional<RetryInfo> getRetryInfo();
88

99
}

Diff for: operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/DefaultContext.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
public class DefaultContext implements Context {
66

7-
private final RetryInfo retryInfo;
7+
private final RetryInfo retryInfo;
88

9-
public DefaultContext(RetryInfo retryInfo) {
10-
this.retryInfo = retryInfo;
11-
}
9+
public DefaultContext(RetryInfo retryInfo) {
10+
this.retryInfo = retryInfo;
11+
}
1212

13-
@Override
14-
public Optional<RetryInfo> getRetryInfo() {
15-
return Optional.ofNullable(retryInfo);
13+
@Override
14+
public Optional<RetryInfo> getRetryInfo() {
15+
return Optional.ofNullable(retryInfo);
1616
}
1717
}

Diff for: operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/DeleteControl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public boolean isRemoveFinalizer() {
2323
@Override
2424
public DeleteControl rescheduleAfter(long delay) {
2525
if (removeFinalizer) {
26-
throw new IllegalStateException("Cannot reschedule deleteResource if removing finalizer");
26+
throw new IllegalStateException("Cannot reschedule deleteResource if removing finalizer");
2727
}
2828
return super.rescheduleAfter(delay);
2929
}

Diff for: operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/ResourceController.java

+22-22
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,33 @@
44

55
public interface ResourceController<R extends CustomResource<?, ?>> {
66

7-
/**
8-
* Note that this method is used in combination of finalizers. If automatic finalizer handling is
9-
* turned off for the controller, this method is not called.
10-
*
11-
* The implementation should delete the associated component(s). Note that this is method is
12-
* called when an object is marked for deletion. After it's executed the custom resource finalizer
13-
* is automatically removed by the framework; unless the return value is
14-
* {@link DeleteControl#noFinalizerRemoval()}, which indicates that the controller has determined
15-
* that the resource should not be deleted yet. This is usually a corner case, when a cleanup is
7+
/**
8+
* Note that this method is used in combination of finalizers. If automatic finalizer handling is
9+
* turned off for the controller, this method is not called.
10+
*
11+
* The implementation should delete the associated component(s). Note that this is method is
12+
* called when an object is marked for deletion. After it's executed the custom resource finalizer
13+
* is automatically removed by the framework; unless the return value is
14+
* {@link DeleteControl#noFinalizerRemoval()}, which indicates that the controller has determined
15+
* that the resource should not be deleted yet. This is usually a corner case, when a cleanup is
1616
* tried again eventually.
1717
*
1818
* <p>
1919
* It's important that this method be idempotent, as it could be called several times, depending
2020
* on the conditions and the controller's configuration (for example, if the controller is
21-
* configured to not use a finalizer but the resource does have finalizers, it might be be
22-
* "offered" again for deletion several times until the finalizers are all removed.
23-
*
24-
* @param resource the resource that is marked for deletion
25-
* @param context the context with which the operation is executed
26-
* @return {@link DeleteControl#defaultDelete()} - so the finalizer is automatically removed after
27-
* the call. {@link DeleteControl#noFinalizerRemoval()} if you don't want to remove the
28-
* finalizer to indicate that the resource should not be deleted after all, in which case
29-
* the controller should restore the resource's state appropriately.
30-
*/
31-
default DeleteControl deleteResource(R resource, Context context) {
32-
return DeleteControl.defaultDelete();
33-
}
21+
* configured to not use a finalizer but the resource does have finalizers, it might be be
22+
* "offered" again for deletion several times until the finalizers are all removed.
23+
*
24+
* @param resource the resource that is marked for deletion
25+
* @param context the context with which the operation is executed
26+
* @return {@link DeleteControl#defaultDelete()} - so the finalizer is automatically removed after
27+
* the call. {@link DeleteControl#noFinalizerRemoval()} if you don't want to remove the
28+
* finalizer to indicate that the resource should not be deleted after all, in which case
29+
* the controller should restore the resource's state appropriately.
30+
*/
31+
default DeleteControl deleteResource(R resource, Context context) {
32+
return DeleteControl.defaultDelete();
33+
}
3434

3535
/**
3636
* The implementation of this operation is required to be idempotent. Always use the UpdateControl

Diff for: operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/UpdateControl.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class UpdateControl<T extends CustomResource> extends BaseControl<UpdateC
1010
private final boolean updateCustomResource;
1111

1212
private UpdateControl(
13-
T customResource, boolean updateStatusSubResource, boolean updateCustomResource) {
13+
T customResource, boolean updateStatusSubResource, boolean updateCustomResource) {
1414
if ((updateCustomResource || updateStatusSubResource) && customResource == null) {
1515
throw new IllegalArgumentException("CustomResource cannot be null in case of update");
1616
}
@@ -24,7 +24,7 @@ public static <T extends CustomResource> UpdateControl<T> updateCustomResource(T
2424
}
2525

2626
public static <T extends CustomResource> UpdateControl<T> updateStatusSubResource(
27-
T customResource) {
27+
T customResource) {
2828
return new UpdateControl<>(customResource, true, false);
2929
}
3030

@@ -36,7 +36,7 @@ public static <T extends CustomResource> UpdateControl<T> updateStatusSubResourc
3636
* @return UpdateControl instance
3737
*/
3838
public static <T extends CustomResource<?, ?>> UpdateControl<T> updateCustomResourceAndStatus(
39-
T customResource) {
39+
T customResource) {
4040
return new UpdateControl<>(customResource, true, true);
4141
}
4242

Diff for: operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/AbstractConfigurationService.java

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package io.javaoperatorsdk.operator.api.config;
22

3-
import io.fabric8.kubernetes.client.CustomResource;
4-
import io.javaoperatorsdk.operator.ControllerUtils;
5-
import io.javaoperatorsdk.operator.api.ResourceController;
6-
73
import java.util.Map;
84
import java.util.Set;
95
import java.util.concurrent.ConcurrentHashMap;
106
import java.util.stream.Stream;
117

8+
import io.fabric8.kubernetes.client.CustomResource;
9+
import io.javaoperatorsdk.operator.ControllerUtils;
10+
import io.javaoperatorsdk.operator.api.ResourceController;
11+
1212
@SuppressWarnings("rawtypes")
1313
public class AbstractConfigurationService implements ConfigurationService {
1414
private final Map<String, ControllerConfiguration> configurations = new ConcurrentHashMap<>();
@@ -27,7 +27,7 @@ public AbstractConfigurationService(Version version) {
2727
}
2828

2929
private <R extends CustomResource<?, ?>> void put(
30-
ControllerConfiguration<R> config, boolean failIfExisting) {
30+
ControllerConfiguration<R> config, boolean failIfExisting) {
3131
final var name = config.getName();
3232
if (failIfExisting) {
3333
final var existing = configurations.get(name);
@@ -40,19 +40,19 @@ public AbstractConfigurationService(Version version) {
4040
}
4141

4242
protected <R extends CustomResource<?, ?>> void throwExceptionOnNameCollision(
43-
String newControllerClassName, ControllerConfiguration<R> existing) {
43+
String newControllerClassName, ControllerConfiguration<R> existing) {
4444
throw new IllegalArgumentException(
45-
"Controller name '"
46-
+ existing.getName()
47-
+ "' is used by both "
48-
+ existing.getAssociatedControllerClassName()
49-
+ " and "
50-
+ newControllerClassName);
45+
"Controller name '"
46+
+ existing.getName()
47+
+ "' is used by both "
48+
+ existing.getAssociatedControllerClassName()
49+
+ " and "
50+
+ newControllerClassName);
5151
}
5252

5353
@Override
5454
public <R extends CustomResource<?, ?>> ControllerConfiguration<R> getConfigurationFor(
55-
ResourceController<R> controller) {
55+
ResourceController<R> controller) {
5656
final var key = keyFor(controller);
5757
final var configuration = configurations.get(key);
5858
if (configuration == null) {

Diff for: operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ConfigurationService.java

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
package io.javaoperatorsdk.operator.api.config;
22

3-
import com.fasterxml.jackson.core.JsonProcessingException;
4-
import com.fasterxml.jackson.databind.ObjectMapper;
3+
import java.util.Set;
4+
import java.util.concurrent.ExecutorService;
5+
import java.util.concurrent.Executors;
6+
57
import io.fabric8.kubernetes.client.Config;
68
import io.fabric8.kubernetes.client.CustomResource;
79
import io.javaoperatorsdk.operator.api.ResourceController;
810
import io.javaoperatorsdk.operator.api.monitoring.Metrics;
911

10-
import java.util.Set;
11-
import java.util.concurrent.ExecutorService;
12-
import java.util.concurrent.Executors;
12+
import com.fasterxml.jackson.core.JsonProcessingException;
13+
import com.fasterxml.jackson.databind.ObjectMapper;
1314

1415
/** An interface from which to retrieve configuration information. */
1516
public interface ConfigurationService {
@@ -31,12 +32,12 @@ public interface ConfigurationService {
3132
* Retrieves the configuration associated with the specified controller
3233
*
3334
* @param controller the controller we want the configuration of
34-
* @param <R> the {@code CustomResource} type associated with the specified controller
35+
* @param <R> the {@code CustomResource} type associated with the specified controller
3536
* @return the {@link ControllerConfiguration} associated with the specified controller or {@code
3637
* null} if no configuration exists for the controller
3738
*/
3839
<R extends CustomResource<?, ?>> ControllerConfiguration<R> getConfigurationFor(
39-
ResourceController<R> controller);
40+
ResourceController<R> controller);
4041

4142
/**
4243
* Retrieves the Kubernetes client configuration

Diff for: operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ConfigurationServiceOverrider.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package io.javaoperatorsdk.operator.api.config;
22

3+
import java.util.Set;
4+
35
import io.fabric8.kubernetes.client.Config;
46
import io.fabric8.kubernetes.client.CustomResource;
57
import io.javaoperatorsdk.operator.api.ResourceController;
68
import io.javaoperatorsdk.operator.api.monitoring.Metrics;
79

8-
import java.util.Set;
9-
1010
public class ConfigurationServiceOverrider {
1111
private final ConfigurationService original;
1212
private Metrics metrics;
@@ -62,7 +62,7 @@ public ConfigurationService build() {
6262
return new ConfigurationService() {
6363
@Override
6464
public <R extends CustomResource<?, ?>> ControllerConfiguration<R> getConfigurationFor(
65-
ResourceController<R> controller) {
65+
ResourceController<R> controller) {
6666
return original.getConfigurationFor(controller);
6767
}
6868

Diff for: operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ControllerConfiguration.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package io.javaoperatorsdk.operator.api.config;
22

3+
import java.lang.reflect.ParameterizedType;
4+
import java.util.Collections;
5+
import java.util.Set;
6+
37
import io.fabric8.kubernetes.client.CustomResource;
48
import io.javaoperatorsdk.operator.ControllerUtils;
59
import io.javaoperatorsdk.operator.api.Controller;
610
import io.javaoperatorsdk.operator.processing.event.internal.CustomResourceEventFilter;
711
import io.javaoperatorsdk.operator.processing.event.internal.CustomResourceEventFilters;
812

9-
import java.lang.reflect.ParameterizedType;
10-
import java.util.Collections;
11-
import java.util.Set;
12-
1313
public interface ControllerConfiguration<R extends CustomResource<?, ?>> {
1414

1515
default String getName() {

0 commit comments

Comments
 (0)