Skip to content

Commit 782edd0

Browse files
committed
fix: spotless plugin activation issue
Signed-off-by: xstefank <[email protected]>
1 parent 2d9d57c commit 782edd0

File tree

9 files changed

+118
-125
lines changed

9 files changed

+118
-125
lines changed

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

+2-13
Original file line numberDiff line numberDiff line change
@@ -97,19 +97,8 @@ public static boolean debugThreadPool() {
9797
return getBooleanFromSystemPropsOrDefault(DEBUG_THREAD_POOL_ENV_KEY, false);
9898
}
9999

100-
static boolean getBooleanFromSystemPropsOrDefault(String propertyName, boolean defaultValue) {
101-
var property = System.getProperty(propertyName);
102-
if (property == null) {
103-
return defaultValue;
104-
} else {
105-
property = property.trim().toLowerCase();
106-
return switch (property) {
107-
case "true" -> true;
108-
case "false" -> false;
109-
default -> defaultValue;
110-
};
111-
}
112-
}
100+
static boolean getBooleanFromSystemPropsOrDefault(String propertyName,
101+
boolean defaultValue) {var property=System.getProperty(propertyName);if(property==null){return defaultValue;}else{property=property.trim().toLowerCase();return switch(property){case"true"->true;case"false"->false;default->defaultValue;};}}
113102

114103
public static Class<?> getFirstTypeArgumentFromExtendedClass(Class<?> clazz) {
115104
return getTypeArgumentFromExtendedClassByIndex(clazz, 0);

Diff for: operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/workflow/BaseWorkflowResult.java

+20-14
Original file line numberDiff line numberDiff line change
@@ -168,19 +168,26 @@ DetailBuilder<R> markForDelete() {
168168
}
169169

170170

171-
record Detail<R>(Exception error, ReconcileResult<R> reconcileResult,
172-
DetailedCondition.Result activationConditionResult,
173-
DetailedCondition.Result deletePostconditionResult,
174-
DetailedCondition.Result readyPostconditionResult,
175-
DetailedCondition.Result reconcilePostconditionResult,
176-
boolean deleted, boolean visited, boolean markedForDelete) {
177-
178-
boolean isConditionWithTypeMet(Condition.Type conditionType) {
179-
return getResultForConditionWithType(conditionType).map(DetailedCondition.Result::isSuccess)
180-
.orElse(true);
181-
}
171+
record Detail<R>(
172+
Exception error, ReconcileResult<R>reconcileResult,
173+
DetailedCondition.Result activationConditionResult,
174+
DetailedCondition.
175+
Result deletePostconditionResult,
176+
DetailedCondition.
177+
Result readyPostconditionResult,
178+
DetailedCondition.
179+
Result reconcilePostconditionResult,
180+
boolean deleted,
181+
boolean visited,
182+
boolean markedForDelete)
183+
{
184+
185+
boolean isConditionWithTypeMet(Condition.Type conditionType) {
186+
return getResultForConditionWithType(conditionType).map(DetailedCondition.Result::isSuccess)
187+
.orElse(true);
188+
}
182189

183-
Optional<DetailedCondition.Result<?>> getResultForConditionWithType(
190+
Optional<DetailedCondition.Result<?>> getResultForConditionWithType(
184191
Condition.Type conditionType) {
185192
return switch (conditionType) {
186193
case ACTIVATION -> Optional.ofNullable(activationConditionResult);
@@ -189,5 +196,4 @@ Optional<DetailedCondition.Result<?>> getResultForConditionWithType(
189196
case RECONCILE -> Optional.ofNullable(reconcilePostconditionResult);
190197
};
191198
}
192-
}
193-
}
199+
}}

Diff for: operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/ReconciliationDispatcher.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class ReconciliationDispatcher<P extends HasMetadata> {
5959
public ReconciliationDispatcher(Controller<P> controller) {
6060
this(controller,
6161
new CustomResourceFacade<>(controller.getCRClient(), controller.getConfiguration(),
62-
controller.getConfiguration().getConfigurationService().getResourceCloner()));
62+
controller.getConfiguration().getConfigurationService().getResourceCloner()));
6363
}
6464

6565
public PostExecutionControl<P> handleExecution(ExecutionScope<P> executionScope) {
@@ -368,8 +368,8 @@ static class CustomResourceFacade<R extends HasMetadata> {
368368
private final Cloner cloner;
369369

370370
public CustomResourceFacade(
371-
MixedOperation<R, KubernetesResourceList<R>, Resource<R>> resourceOperation,
372-
ControllerConfiguration<R> configuration, Cloner cloner) {
371+
MixedOperation<R, KubernetesResourceList<R>, Resource<R>> resourceOperation,
372+
ControllerConfiguration<R> configuration, Cloner cloner) {
373373
this.resourceOperation = resourceOperation;
374374
this.useSSA =
375375
configuration.getConfigurationService().useSSAToPatchPrimaryResource();

Diff for: operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/informer/Mappers.java

+2-9
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,9 @@ private static <T extends HasMetadata> SecondaryToPrimaryMapper<T> fromMetadata(
119119
}
120120

121121
public static ResourceID fromString(String cacheKey) {
122-
if (cacheKey == null) {
123-
return null;
124-
}
122+
if(cacheKey==null){return null;}
125123

126-
final String[] split = cacheKey.split("/");
127-
return switch (split.length) {
128-
case 1 -> new ResourceID(split[0]);
129-
case 2 -> new ResourceID(split[1], split[0]);
130-
default -> throw new IllegalArgumentException("Cannot extract a ResourceID from " + cacheKey);
131-
};
124+
final String[]split=cacheKey.split("/");return switch(split.length){case 1->new ResourceID(split[0]);case 2->new ResourceID(split[1],split[0]);default->throw new IllegalArgumentException("Cannot extract a ResourceID from "+cacheKey);};
132125
}
133126

134127
/**

Diff for: operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/dependent/workflow/CRDPresentActivationConditionTest.java

+13-13
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ void setup() {
3737

3838

3939
@Test
40-
void checkCRDIfNotCheckedBefore() {
41-
when(checkerMock.checkIfCRDPresent(any(),any())).thenReturn(true);
40+
void checkCRDIfNotCheckedBefore() {
41+
when(checkerMock.checkIfCRDPresent(any(), any())).thenReturn(true);
4242

43-
assertThat(condition.isMet(dr,null,context)).isTrue();
44-
verify(checkerMock, times(1)).checkIfCRDPresent(any(),any());
45-
}
43+
assertThat(condition.isMet(dr, null, context)).isTrue();
44+
verify(checkerMock, times(1)).checkIfCRDPresent(any(), any());
45+
}
4646

4747
@Test
4848
void instantMetCallSkipsApiCall() {
@@ -65,17 +65,17 @@ void intervalExpiredAPICheckedAgain() throws InterruptedException {
6565
}
6666

6767
@Test
68-
void crdIsNotCheckedAnymoreIfIfOnceFound() throws InterruptedException {
69-
when(checkerMock.checkIfCRDPresent(any(),any())).thenReturn(true);
68+
void crdIsNotCheckedAnymoreIfIfOnceFound() throws InterruptedException {
69+
when(checkerMock.checkIfCRDPresent(any(), any())).thenReturn(true);
7070

71-
condition.isMet(dr,null,context);
72-
verify(checkerMock, times(1)).checkIfCRDPresent(any(),any());
71+
condition.isMet(dr, null, context);
72+
verify(checkerMock, times(1)).checkIfCRDPresent(any(), any());
7373

74-
Thread.sleep(TEST_CHECK_INTERVAL_WITH_SLACK);
74+
Thread.sleep(TEST_CHECK_INTERVAL_WITH_SLACK);
7575

76-
condition.isMet(dr,null,context);
77-
verify(checkerMock, times(1)).checkIfCRDPresent(any(),any());
78-
}
76+
condition.isMet(dr, null, context);
77+
verify(checkerMock, times(1)).checkIfCRDPresent(any(), any());
78+
}
7979

8080
@Test
8181
void crdNotCheckedAnymoreIfCountExpires() throws InterruptedException {

Diff for: operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/EventProcessorTest.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -421,13 +421,13 @@ void executionOfReconciliationShouldNotStartIfProcessorStopped() throws Interrup
421421
o.withConcurrentReconciliationThreads(1);
422422
});
423423
eventProcessor =
424-
spy(new EventProcessor(controllerConfiguration(null, rateLimiterMock, configurationService),
425-
reconciliationDispatcherMock,
426-
eventSourceManagerMock, null));
424+
spy(new EventProcessor(controllerConfiguration(null, rateLimiterMock, configurationService),
425+
reconciliationDispatcherMock,
426+
eventSourceManagerMock, null));
427427
eventProcessor.start();
428428

429-
eventProcessor.handleEvent(prepareCREvent(new ResourceID("test1","default")));
430-
eventProcessor.handleEvent(prepareCREvent(new ResourceID("test1","default")));
429+
eventProcessor.handleEvent(prepareCREvent(new ResourceID("test1", "default")));
430+
eventProcessor.handleEvent(prepareCREvent(new ResourceID("test1", "default")));
431431
eventProcessor.stop();
432432

433433
// wait until both event should be handled

Diff for: operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/source/polling/PerResourcePollingEventSourceTest.java

+21-21
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ public void setup() {
4444
when(context.getPrimaryCache()).thenReturn(resourceCache);
4545

4646
setUpSource(new PerResourcePollingEventSource<>(SampleExternalResource.class, context,
47-
new PerResourcePollingConfigurationBuilder<>(supplier, Duration.ofMillis(PERIOD))
48-
.withCacheKeyMapper(r -> r.getName() + "#" + r.getValue())
49-
.build()));
47+
new PerResourcePollingConfigurationBuilder<>(supplier, Duration.ofMillis(PERIOD))
48+
.withCacheKeyMapper(r -> r.getName() + "#" + r.getValue())
49+
.build()));
5050
}
5151

5252
@Test
@@ -147,44 +147,44 @@ void getsValueFromCacheOrSupplier() {
147147
@Test
148148
void supportsDynamicPollingDelay() {
149149
when(supplier.fetchResources(any()))
150-
.thenReturn(Set.of(SampleExternalResource.testResource1()));
151-
when(supplier.fetchDelay(any(),any()))
152-
.thenReturn(Optional.of(Duration.ofMillis(PERIOD)))
153-
.thenReturn(Optional.of(Duration.ofMillis(PERIOD*2)));
150+
.thenReturn(Set.of(SampleExternalResource.testResource1()));
151+
when(supplier.fetchDelay(any(), any()))
152+
.thenReturn(Optional.of(Duration.ofMillis(PERIOD)))
153+
.thenReturn(Optional.of(Duration.ofMillis(PERIOD * 2)));
154154

155155
source.onResourceCreated(testCustomResource);
156156

157157
await().pollDelay(Duration.ofMillis(PERIOD)).atMost(Duration.ofMillis((long) (1.5 * PERIOD)))
158-
.pollInterval(Duration.ofMillis(20))
159-
.untilAsserted(() -> verify(supplier,times(1)).fetchResources(any()));
158+
.pollInterval(Duration.ofMillis(20))
159+
.untilAsserted(() -> verify(supplier, times(1)).fetchResources(any()));
160160
// verifying that it is not called as with normal interval
161-
await().pollDelay(Duration.ofMillis(PERIOD)).atMost(Duration.ofMillis((long) (1.5*PERIOD)))
162-
.pollInterval(Duration.ofMillis(20))
163-
.untilAsserted(() -> verify(supplier,times(1)).fetchResources(any()));
161+
await().pollDelay(Duration.ofMillis(PERIOD)).atMost(Duration.ofMillis((long) (1.5 * PERIOD)))
162+
.pollInterval(Duration.ofMillis(20))
163+
.untilAsserted(() -> verify(supplier, times(1)).fetchResources(any()));
164164
await().pollDelay(Duration.ofMillis(PERIOD)).atMost(Duration.ofMillis(2 * PERIOD))
165-
.pollInterval(Duration.ofMillis(20))
166-
.untilAsserted(() -> verify(supplier,times(2)).fetchResources(any()));
165+
.pollInterval(Duration.ofMillis(20))
166+
.untilAsserted(() -> verify(supplier, times(2)).fetchResources(any()));
167167
}
168168

169169
@Test
170170
void deleteEventCancelsTheScheduling() {
171171
when(supplier.fetchResources(any()))
172-
.thenReturn(Set.of(SampleExternalResource.testResource1()));
172+
.thenReturn(Set.of(SampleExternalResource.testResource1()));
173173

174174
source.onResourceCreated(testCustomResource);
175175

176176
await().pollDelay(Duration.ofMillis(PERIOD))
177-
.atMost(Duration.ofMillis((2* PERIOD)))
178-
.pollInterval(Duration.ofMillis(20))
179-
.untilAsserted(() -> verify(supplier,times(1)).fetchResources(any()));
177+
.atMost(Duration.ofMillis((2 * PERIOD)))
178+
.pollInterval(Duration.ofMillis(20))
179+
.untilAsserted(() -> verify(supplier, times(1)).fetchResources(any()));
180180

181181
when(resourceCache.get(any())).thenReturn(Optional.empty());
182182
source.onResourceDeleted(testCustomResource);
183183

184184
// check if not called again
185-
await().pollDelay(Duration.ofMillis(2*PERIOD))
186-
.atMost(Duration.ofMillis((4* PERIOD)))
187-
.untilAsserted(() -> verify(supplier,times(1)).fetchResources(any()));
185+
await().pollDelay(Duration.ofMillis(2 * PERIOD))
186+
.atMost(Duration.ofMillis((4 * PERIOD)))
187+
.untilAsserted(() -> verify(supplier, times(1)).fetchResources(any()));
188188
}
189189

190190
}

Diff for: operator-framework/src/test/java/io/javaoperatorsdk/operator/baseapi/changenamespace/ChangeNamespaceTestReconciler.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ public UpdateControl<ChangeNamespaceTestCustomResource> reconcile(
5252

5353
var statusPatchResource = new ChangeNamespaceTestCustomResource();
5454
statusPatchResource.setMetadata(new ObjectMetaBuilder()
55-
.withName(primary.getMetadata().getName())
56-
.withNamespace(primary.getMetadata().getNamespace())
57-
.build());
55+
.withName(primary.getMetadata().getName())
56+
.withNamespace(primary.getMetadata().getNamespace())
57+
.build());
5858
statusPatchResource.setStatus(new ChangeNamespaceTestCustomResourceStatus());
5959
var statusUpdates = primary.getStatus().getNumberOfStatusUpdates();
6060
statusPatchResource.getStatus().setNumberOfStatusUpdates(statusUpdates + 1);

Diff for: pom.xml

+49-44
Original file line numberDiff line numberDiff line change
@@ -327,53 +327,58 @@
327327
<excludedGroups>WatchPermissionAwareTest</excludedGroups>
328328
</configuration>
329329
</plugin>
330+
<plugin>
331+
<groupId>org.commonjava.maven.plugins</groupId>
332+
<artifactId>directory-maven-plugin</artifactId>
333+
<version>0.1</version>
334+
<executions>
335+
<execution>
336+
<id>directories</id>
337+
<goals>
338+
<goal>highest-basedir</goal>
339+
</goals>
340+
<phase>initialize</phase>
341+
<configuration>
342+
<property>highest-basedir</property>
343+
</configuration>
344+
</execution>
345+
</executions>
346+
</plugin>
347+
<plugin>
348+
<groupId>com.diffplug.spotless</groupId>
349+
<artifactId>spotless-maven-plugin</artifactId>
350+
<configuration>
351+
<pom>
352+
<includes>
353+
<include>pom.xml</include>
354+
<include>./**/pom.xml</include>
355+
</includes>
356+
<sortPom>
357+
<expandEmptyElements>false</expandEmptyElements>
358+
</sortPom>
359+
</pom>
360+
<java>
361+
<eclipse>
362+
<file>${highest-basedir}/contributing/eclipse-google-style.xml</file>
363+
</eclipse>
364+
<importOrder>
365+
<file>${highest-basedir}/contributing/eclipse.importorder</file>
366+
</importOrder>
367+
<removeUnusedImports/>
368+
</java>
369+
</configuration>
370+
<executions>
371+
<execution>
372+
<goals>
373+
<goal>apply</goal>
374+
</goals>
375+
<phase>compile</phase>
376+
</execution>
377+
</executions>
378+
</plugin>
330379
</plugins>
331380
</build>
332381
<profiles>
333-
<profile>
334-
<id>spotless</id>
335-
<activation>
336-
<file>
337-
<exists>contributing</exists>
338-
</file>
339-
</activation>
340-
<build>
341-
<plugins>
342-
<plugin>
343-
<groupId>com.diffplug.spotless</groupId>
344-
<artifactId>spotless-maven-plugin</artifactId>
345-
<configuration>
346-
<pom>
347-
<includes>
348-
<include>pom.xml</include>
349-
<include>./**/pom.xml</include>
350-
</includes>
351-
<sortPom>
352-
<expandEmptyElements>false</expandEmptyElements>
353-
</sortPom>
354-
</pom>
355-
<java>
356-
<eclipse>
357-
<file>contributing/eclipse-google-style.xml</file>
358-
</eclipse>
359-
<importOrder>
360-
<file>contributing/eclipse.importorder</file>
361-
</importOrder>
362-
<removeUnusedImports/>
363-
</java>
364-
</configuration>
365-
<executions>
366-
<execution>
367-
<goals>
368-
<goal>apply</goal>
369-
</goals>
370-
<phase>compile</phase>
371-
</execution>
372-
</executions>
373-
</plugin>
374-
</plugins>
375-
</build>
376-
</profile>
377382
<profile>
378383
<id>integration-tests</id>
379384
<build>

0 commit comments

Comments
 (0)