Skip to content

Commit 8bebad0

Browse files
committed
chore: re-format
1 parent 53fccb9 commit 8bebad0

File tree

38 files changed

+911
-841
lines changed

38 files changed

+911
-841
lines changed

api/src/main/java/io/javaoperatorsdk/operator/api/Controller.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,26 @@
88
@Retention(RetentionPolicy.RUNTIME)
99
@Target({ElementType.TYPE})
1010
public @interface Controller {
11-
String NULL = "";
12-
13-
String crdName();
14-
15-
String name() default NULL;
16-
17-
/**
18-
* Optional finalizer name, if it is not,
19-
the crdName will be used as the name of the finalizer
11+
String NULL = "";
12+
13+
String crdName();
14+
15+
String name() default NULL;
16+
17+
/**
18+
* Optional finalizer name, if it is not, the crdName will be used as the name of the finalizer
2019
* too.
21-
*/
22-
String finalizerName() default NULL;
23-
24-
/**
25-
* If true, will dispatch new event to the controller if generation increased since the last* processing, otherwise will process all events. See generation meta attribute <a
20+
*/
21+
String finalizerName() default NULL;
22+
23+
/**
24+
* If true, will dispatch new event to the controller if generation increased since the last
25+
* processing, otherwise will process all events. See generation meta attribute <a
2626
* href="https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/#status-subresource">here</a>
2727
*/
2828
boolean generationAwareEventProcessing() default true;
29-
30-
boolean isClusterScoped() default false;
31-
32-
String[] namespaces() default {};
29+
30+
boolean isClusterScoped() default false;
31+
32+
String[] namespaces() default {};
3333
}
Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,34 @@
11
package io.javaoperatorsdk.operator.api;
22

3+
import io.fabric8.kubernetes.client.CustomResource;
34
import java.util.Locale;
45

5-
import io.fabric8.kubernetes.client.CustomResource;
6+
public class ControllerUtils {
67

8+
private static final String FINALIZER_NAME_SUFFIX = "/finalizer";
79

8-
public class ControllerUtils {
9-
10-
private static final String FINALIZER_NAME_SUFFIX = "/finalizer";
11-
12-
public static String getDefaultFinalizerName(String crdName) {
13-
return crdName + FINALIZER_NAME_SUFFIX;
14-
}
15-
16-
public static boolean hasGivenFinalizer(CustomResource resource, String finalizer) {
17-
return resource.getMetadata().getFinalizers() != null && resource.getMetadata().getFinalizers().contains(finalizer);
18-
}
19-
20-
public static String getDefaultNameFor(ResourceController controller) {
21-
return getDefaultNameFor(controller.getClass());
22-
}
23-
24-
public static String getDefaultNameFor(Class<? extends ResourceController> controllerClass) {
25-
return getDefaultResourceControllerName(controllerClass.getSimpleName());
26-
}
27-
28-
public static String getDefaultResourceControllerName(String rcControllerClassName) {
29-
final var lastDot = rcControllerClassName.lastIndexOf('.');
30-
if (lastDot > 0) {
31-
rcControllerClassName = rcControllerClassName.substring(lastDot);
32-
}
33-
return rcControllerClassName.toLowerCase(Locale.ROOT);
10+
public static String getDefaultFinalizerName(String crdName) {
11+
return crdName + FINALIZER_NAME_SUFFIX;
12+
}
13+
14+
public static boolean hasGivenFinalizer(CustomResource resource, String finalizer) {
15+
return resource.getMetadata().getFinalizers() != null
16+
&& resource.getMetadata().getFinalizers().contains(finalizer);
17+
}
18+
19+
public static String getDefaultNameFor(ResourceController controller) {
20+
return getDefaultNameFor(controller.getClass());
21+
}
22+
23+
public static String getDefaultNameFor(Class<? extends ResourceController> controllerClass) {
24+
return getDefaultResourceControllerName(controllerClass.getSimpleName());
25+
}
26+
27+
public static String getDefaultResourceControllerName(String rcControllerClassName) {
28+
final var lastDot = rcControllerClassName.lastIndexOf('.');
29+
if (lastDot > 0) {
30+
rcControllerClassName = rcControllerClassName.substring(lastDot);
3431
}
32+
return rcControllerClassName.toLowerCase(Locale.ROOT);
33+
}
3534
}
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package io.javaoperatorsdk.operator.api;
22

33
public interface EventHandler {
4-
5-
void handleEvent(Event event);
6-
4+
5+
void handleEvent(Event event);
76
}
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
package io.javaoperatorsdk.operator.api;
22

33
public interface EventSource {
4-
5-
void setEventHandler(EventHandler eventHandler);
6-
7-
void eventSourceDeRegisteredForResource(String customResourceUid);
8-
4+
5+
void setEventHandler(EventHandler eventHandler);
6+
7+
void eventSourceDeRegisteredForResource(String customResourceUid);
98
}

api/src/main/java/io/javaoperatorsdk/operator/api/EventSourceManager.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
import java.util.Optional;
55

66
public interface EventSourceManager {
7-
8-
<T extends EventSource> void registerEventSource(String name, T eventSource);
9-
10-
Optional<EventSource> deRegisterCustomResourceFromEventSource(String name, String customResourceUid);
11-
12-
Map<String, EventSource> getRegisteredEventSources();
13-
7+
8+
<T extends EventSource> void registerEventSource(String name, T eventSource);
9+
10+
Optional<EventSource> deRegisterCustomResourceFromEventSource(
11+
String name, String customResourceUid);
12+
13+
Map<String, EventSource> getRegisteredEventSources();
1414
}

api/src/main/java/io/javaoperatorsdk/operator/api/ResourceController.java

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
package io.javaoperatorsdk.operator.api;
22

3-
import java.util.Locale;
4-
53
import io.fabric8.kubernetes.client.CustomResource;
4+
import java.util.Locale;
65

76
public interface ResourceController<R extends CustomResource> {
8-
7+
98
/**
109
* The implementation should delete the associated component(s). Note that this is method is
1110
* called when an object is marked for deletion. After its executed the custom resource finalizer
@@ -38,20 +37,20 @@ public interface ResourceController<R extends CustomResource> {
3837
* @param eventSourceManager
3938
*/
4039
default void init(EventSourceManager eventSourceManager) {}
41-
40+
4241
default String getName() {
43-
final var clazz = getClass();
44-
45-
// if the controller annotation has a name attribute, use it
46-
final var annotation = clazz.getAnnotation(Controller.class);
47-
if (annotation != null) {
48-
final var name = annotation.name();
49-
if (!Controller.NULL.equals(name)) {
50-
return name;
51-
}
52-
}
53-
54-
// otherwise, use the lower-cased class name
55-
return clazz.getSimpleName().toLowerCase(Locale.ROOT);
42+
final var clazz = getClass();
43+
44+
// if the controller annotation has a name attribute, use it
45+
final var annotation = clazz.getAnnotation(Controller.class);
46+
if (annotation != null) {
47+
final var name = annotation.name();
48+
if (!Controller.NULL.equals(name)) {
49+
return name;
50+
}
5651
}
52+
53+
// otherwise, use the lower-cased class name
54+
return clazz.getSimpleName().toLowerCase(Locale.ROOT);
55+
}
5756
}

api/src/main/java/io/javaoperatorsdk/operator/api/config/ConfigurationService.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
import io.javaoperatorsdk.operator.api.ResourceController;
66

77
public interface ConfigurationService {
8-
<R extends CustomResource> ControllerConfiguration<R> getConfigurationFor(ResourceController<R> controller);
9-
10-
default Config getClientConfiguration() {
11-
return Config.autoConfigure(null);
12-
}
8+
<R extends CustomResource> ControllerConfiguration<R> getConfigurationFor(
9+
ResourceController<R> controller);
10+
11+
default Config getClientConfiguration() {
12+
return Config.autoConfigure(null);
13+
}
1314
}
Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,38 @@
11
package io.javaoperatorsdk.operator.api.config;
22

3-
import java.util.Collections;
4-
import java.util.Set;
5-
63
import io.fabric8.kubernetes.client.CustomResource;
74
import io.fabric8.kubernetes.client.CustomResourceDoneable;
5+
import java.util.Collections;
6+
import java.util.Set;
87

98
public interface ControllerConfiguration<R extends CustomResource> {
10-
String WATCH_ALL_NAMESPACES_MARKER = "ALL_NAMESPACES";
11-
12-
String getName();
13-
14-
String getCRDName();
15-
16-
String getFinalizer();
17-
18-
boolean isGenerationAware();
19-
20-
Class<R> getCustomResourceClass();
21-
22-
Class<? extends CustomResourceDoneable<R>> getDoneableClass();
23-
24-
default boolean isClusterScoped() {
25-
return false;
26-
}
27-
28-
default Set<String> getNamespaces() {
29-
return Collections.emptySet();
30-
}
31-
32-
default boolean watchAllNamespaces() {
33-
return getNamespaces().contains(WATCH_ALL_NAMESPACES_MARKER);
34-
}
35-
36-
default RetryConfiguration getRetryConfiguration() {
37-
return RetryConfiguration.DEFAULT;
38-
}
9+
String WATCH_ALL_NAMESPACES_MARKER = "ALL_NAMESPACES";
10+
11+
String getName();
12+
13+
String getCRDName();
14+
15+
String getFinalizer();
16+
17+
boolean isGenerationAware();
18+
19+
Class<R> getCustomResourceClass();
20+
21+
Class<? extends CustomResourceDoneable<R>> getDoneableClass();
22+
23+
default boolean isClusterScoped() {
24+
return false;
25+
}
26+
27+
default Set<String> getNamespaces() {
28+
return Collections.emptySet();
29+
}
30+
31+
default boolean watchAllNamespaces() {
32+
return getNamespaces().contains(WATCH_ALL_NAMESPACES_MARKER);
33+
}
34+
35+
default RetryConfiguration getRetryConfiguration() {
36+
return RetryConfiguration.DEFAULT;
37+
}
3938
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
package io.javaoperatorsdk.operator.api.config;
22

3-
public class DefaultRetryConfiguration implements RetryConfiguration {
4-
}
3+
public class DefaultRetryConfiguration implements RetryConfiguration {}
Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
package io.javaoperatorsdk.operator.api.config;
22

33
public interface RetryConfiguration {
4-
RetryConfiguration DEFAULT = new DefaultRetryConfiguration();
5-
6-
int DEFAULT_MAX_ATTEMPTS = 5;
7-
long DEFAULT_INITIAL_INTERVAL = 2000L;
8-
double DEFAULT_MULTIPLIER = 1.5D;
9-
10-
default int getMaxAttempts() {
11-
return DEFAULT_MAX_ATTEMPTS;
12-
}
13-
14-
default long getInitialInterval() {
15-
return DEFAULT_INITIAL_INTERVAL;
16-
}
17-
18-
default double getIntervalMultiplier() {
19-
return DEFAULT_MULTIPLIER;
20-
}
21-
22-
default long getMaxInterval() {
23-
return (long) (DEFAULT_INITIAL_INTERVAL * Math.pow(DEFAULT_MULTIPLIER, DEFAULT_MAX_ATTEMPTS));
24-
}
4+
RetryConfiguration DEFAULT = new DefaultRetryConfiguration();
5+
6+
int DEFAULT_MAX_ATTEMPTS = 5;
7+
long DEFAULT_INITIAL_INTERVAL = 2000L;
8+
9+
double DEFAULT_MULTIPLIER = 1.5D;
10+
11+
default int getMaxAttempts() {
12+
return DEFAULT_MAX_ATTEMPTS;
13+
}
14+
15+
default long getInitialInterval() {
16+
return DEFAULT_INITIAL_INTERVAL;
17+
}
18+
19+
default double getIntervalMultiplier() {
20+
return DEFAULT_MULTIPLIER;
21+
}
22+
23+
default long getMaxInterval() {
24+
return (long) (DEFAULT_INITIAL_INTERVAL * Math.pow(DEFAULT_MULTIPLIER, DEFAULT_MAX_ATTEMPTS));
25+
}
2526
}

0 commit comments

Comments
 (0)