Skip to content

Commit ba6106e

Browse files
chore: use formatter-maven-plugin to automatic code formatting (#505)
Fixes #504 Co-authored-by: Chris Laprun <[email protected]>
1 parent 44b42a1 commit ba6106e

File tree

49 files changed

+185
-173
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+185
-173
lines changed

.github/workflows/master-snapshot-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616
strategy:
1717
matrix:
18-
java: [11, 15]
18+
java: [11, 16]
1919
distribution: [adopt, adopt-openj9]
2020
kubernetes: ['v1.17.13','v1.18.20','v1.19.14','v1.20.10','v1.21.4']
2121
steps:

.github/workflows/pr.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616
strategy:
1717
matrix:
18-
java: [11, 15]
18+
java: [11, 16]
1919
distribution: [ adopt, adopt-openj9 ]
2020
kubernetes: ['v1.17.13','v1.18.20','v1.19.14','v1.20.10','v1.21.4']
2121
steps:
@@ -32,7 +32,7 @@ jobs:
3232
distribution: ${{ matrix.distribution }}
3333
java-version: ${{ matrix.java }}
3434
- name: Check code format
35-
run: ./mvnw ${MAVEN_ARGS} fmt:check --file pom.xml
35+
run: ./mvnw ${MAVEN_ARGS} formatter:validate -Dconfigfile=$PWD/contributing/eclipse-google-style.xml --file pom.xml
3636
- name: Run unit tests
3737
run: ./mvnw ${MAVEN_ARGS} -B test --file pom.xml
3838
- name: Set up Minikube

contributing/eclipse-google-style.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="true"/>
6666
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="do not insert"/>
6767
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
68-
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true"/>
68+
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="false"/>
6969
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
7070
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/>
7171
<setting id="org.eclipse.jdt.core.formatter.wrap_non_simple_local_variable_annotation" value="true"/>

operator-framework-core/pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
</plugins>
5858
</build>
5959

60-
6160
<dependencies>
6261
<dependency>
6362
<groupId>io.fabric8</groupId>

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ public <R extends CustomResource> void register(ResourceController<R> controller
124124

125125
/**
126126
* Add a registration requests for the specified controller with this operator, overriding its
127-
* default configuration by the specified one (usually created via {@link
128-
* io.javaoperatorsdk.operator.api.config.ControllerConfigurationOverrider#override(ControllerConfiguration)},
127+
* default configuration by the specified one (usually created via
128+
* {@link io.javaoperatorsdk.operator.api.config.ControllerConfigurationOverrider#override(ControllerConfiguration)},
129129
* passing it the controller's original configuration. The effective registration of the
130130
* controller is delayed till the operator is started.
131131
*
@@ -150,8 +150,8 @@ public <R extends CustomResource> void register(
150150

151151
/**
152152
* Registers the specified controller with this operator, overriding its default configuration by
153-
* the specified one (usually created via {@link
154-
* io.javaoperatorsdk.operator.api.config.ControllerConfigurationOverrider#override(ControllerConfiguration)},
153+
* the specified one (usually created via
154+
* {@link io.javaoperatorsdk.operator.api.config.ControllerConfigurationOverrider#override(ControllerConfiguration)},
155155
* passing it the controller's original configuration.
156156
*
157157
* @param controller the controller to register
@@ -241,7 +241,7 @@ private void throwMissingCRDException(String crdName, String specVersion, String
241241
* but is missing
242242
*
243243
* @return {@code true} if the current namespace is requested but is missing, {@code false}
244-
* otherwise
244+
* otherwise
245245
*/
246246
private static <R extends CustomResource> boolean failOnMissingCurrentNS(
247247
ControllerConfiguration<R> configuration) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626

2727
/**
2828
* If true, will dispatch new event to the controller if generation increased since the last
29-
* processing, otherwise will process all events. See generation meta attribute <a
30-
* href="https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/#status-subresource">here</a>
29+
* processing, otherwise will process all events. See generation meta attribute <a href=
30+
* "https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/#status-subresource">here</a>
3131
*
3232
* @return whether the controller takes generation into account to process events
3333
*/
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package io.javaoperatorsdk.operator.api;
22

33
public enum DeleteControl {
4-
DEFAULT_DELETE,
5-
NO_FINALIZER_REMOVAL
4+
DEFAULT_DELETE, NO_FINALIZER_REMOVAL
65
}

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

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,23 @@ public interface ResourceController<R extends CustomResource> {
88
/**
99
* The implementation should delete the associated component(s). Note that this is method is
1010
* called when an object is marked for deletion. After it's executed the custom resource finalizer
11-
* is automatically removed by the framework; unless the return value is {@link
12-
* DeleteControl#NO_FINALIZER_REMOVAL}, which indicates that the controller has determined that
13-
* the resource should not be deleted yet, in which case it is up to the controller to restore the
14-
* resource's status so that it's not marked for deletion anymore.
11+
* is automatically removed by the framework; unless the return value is
12+
* {@link DeleteControl#NO_FINALIZER_REMOVAL}, which indicates that the controller has determined
13+
* that the resource should not be deleted yet, in which case it is up to the controller to
14+
* restore the resource's status so that it's not marked for deletion anymore.
1515
*
16-
* <p>It's important that this method be idempotent, as it could be called several times,
17-
* depending on the conditions and the controller's configuration (for example, if the controller
18-
* is configured to not use a finalizer but the resource does have finalizers, it might be be
16+
* <p>
17+
* It's important that this method be idempotent, as it could be called several times, depending
18+
* on the conditions and the controller's configuration (for example, if the controller is
19+
* configured to not use a finalizer but the resource does have finalizers, it might be be
1920
* "offered" again for deletion several times until the finalizers are all removed.
2021
*
2122
* @param resource the resource that is marked for deletion
2223
* @param context the context with which the operation is executed
2324
* @return {@link DeleteControl#DEFAULT_DELETE} - so the finalizer is automatically removed after
24-
* the call. {@link DeleteControl#NO_FINALIZER_REMOVAL} if you don't want to remove the
25-
* finalizer to indicate that the resource should not be deleted after all, in which case the
26-
* controller should restore the resource's state appropriately.
25+
* the call. {@link DeleteControl#NO_FINALIZER_REMOVAL} if you don't want to remove the
26+
* finalizer to indicate that the resource should not be deleted after all, in which case
27+
* the controller should restore the resource's state appropriately.
2728
*/
2829
default DeleteControl deleteResource(R resource, Context<R> context) {
2930
return DeleteControl.DEFAULT_DELETE;
@@ -36,20 +37,20 @@ default DeleteControl deleteResource(R resource, Context<R> context) {
3637
*
3738
* @param resource the resource that has been created or updated
3839
* @param context the context with which the operation is executed
39-
* @return The resource is updated in api server if the return value is not {@link
40-
* UpdateControl#noUpdate()}. This the common use cases. However in cases, for example the
41-
* operator is restarted, and we don't want to have an update call to k8s api to be made
42-
* unnecessarily, by returning {@link UpdateControl#noUpdate()} this update can be skipped.
43-
* <b>However we will always call an update if there is no finalizer on object and it's not
44-
* marked for deletion.</b>
40+
* @return The resource is updated in api server if the return value is not
41+
* {@link UpdateControl#noUpdate()}. This the common use cases. However in cases, for
42+
* example the operator is restarted, and we don't want to have an update call to k8s api
43+
* to be made unnecessarily, by returning {@link UpdateControl#noUpdate()} this update can
44+
* be skipped. <b>However we will always call an update if there is no finalizer on object
45+
* and it's not marked for deletion.</b>
4546
*/
4647
UpdateControl<R> createOrUpdateResource(R resource, Context<R> context);
4748

4849
/**
4950
* In init typically you might want to register event sources.
5051
*
5152
* @param eventSourceManager the {@link EventSourceManager} which handles this controller and with
52-
* which event sources can be registered
53+
* which event sources can be registered
5354
*/
5455
default void init(EventSourceManager eventSourceManager) {}
5556
}

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ <R extends CustomResource> ControllerConfiguration<R> getConfigurationFor(
2424
* Retrieves the Kubernetes client configuration
2525
*
2626
* @return the configuration of the Kubernetes client, defaulting to the provided
27-
* auto-configuration
27+
* auto-configuration
2828
*/
2929
default Config getClientConfiguration() {
3030
return Config.autoConfigure(null);
@@ -45,11 +45,13 @@ default Config getClientConfiguration() {
4545
Version getVersion();
4646

4747
/**
48-
* Whether the operator should query the CRD to make sure it's deployed and validate {@link
49-
* CustomResource} implementations before attempting to register the associated controllers.
48+
* Whether the operator should query the CRD to make sure it's deployed and validate
49+
* {@link CustomResource} implementations before attempting to register the associated
50+
* controllers.
5051
*
51-
* <p>Note that this might require elevating the privileges associated with the operator to gain
52-
* read access on the CRD resources.
52+
* <p>
53+
* Note that this might require elevating the privileges associated with the operator to gain read
54+
* access on the CRD resources.
5355
*
5456
* @return {@code true} if CRDs should be checked (default), {@code false} otherwise
5557
*/
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
package io.javaoperatorsdk.operator.api.config;
22

3-
public class DefaultRetryConfiguration implements RetryConfiguration {}
3+
public class DefaultRetryConfiguration implements RetryConfiguration {
4+
}

0 commit comments

Comments
 (0)