Skip to content

fix: spotless plugin (downgrade to 2.43.0) #2708

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/fabric8-next-version-schedule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
distribution: temurin
java-version: 17
- name: Run unit tests
run: ./mvnw ${MAVEN_ARGS} clean install --file pom.xml
run: ./mvnw ${MAVEN_ARGS} clean install --file pom.xml -Dhighest-basedir=$PWD

build:
uses: ./.github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ public static boolean debugThreadPool() {
return getBooleanFromSystemPropsOrDefault(DEBUG_THREAD_POOL_ENV_KEY, false);
}

public static boolean getBooleanFromSystemPropsOrDefault(String propertyName, boolean defaultValue) {
public static boolean getBooleanFromSystemPropsOrDefault(String propertyName,
boolean defaultValue) {
var property = System.getProperty(propertyName);
if (property == null) {
return defaultValue;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package io.javaoperatorsdk.operator.processing;

import io.fabric8.kubernetes.api.model.ObjectMeta;
import io.javaoperatorsdk.operator.api.config.Utils;
import org.slf4j.MDC;

import io.fabric8.kubernetes.api.model.HasMetadata;
import io.javaoperatorsdk.operator.api.config.Utils;
import io.javaoperatorsdk.operator.processing.event.ResourceID;

public class MDCUtils {
Expand All @@ -17,50 +16,51 @@ public class MDCUtils {
private static final String GENERATION = "resource.generation";
private static final String UID = "resource.uid";
private static final String NO_NAMESPACE = "no namespace";
private static final boolean enabled = Utils.getBooleanFromSystemPropsOrDefault(Utils.USE_MDC_ENV_KEY, true);
private static final boolean enabled =
Utils.getBooleanFromSystemPropsOrDefault(Utils.USE_MDC_ENV_KEY, true);

public static void addResourceIDInfo(ResourceID resourceID) {
if (enabled) {
MDC.put(NAME, resourceID.getName());
MDC.put(NAMESPACE, resourceID.getNamespace().orElse(NO_NAMESPACE));
}
if (enabled) {
MDC.put(NAME, resourceID.getName());
MDC.put(NAMESPACE, resourceID.getNamespace().orElse(NO_NAMESPACE));
}
}

public static void removeResourceIDInfo() {
if (enabled) {
MDC.remove(NAME);
MDC.remove(NAMESPACE);
}
if (enabled) {
MDC.remove(NAME);
MDC.remove(NAMESPACE);
}
}

public static void addResourceInfo(HasMetadata resource) {
if (enabled) {
MDC.put(API_VERSION, resource.getApiVersion());
MDC.put(KIND, resource.getKind());
final var metadata = resource.getMetadata();
if (metadata != null) {
MDC.put(NAME, metadata.getName());
if (metadata.getNamespace() != null) {
MDC.put(NAMESPACE, metadata.getNamespace());
}
MDC.put(RESOURCE_VERSION, metadata.getResourceVersion());
if (metadata.getGeneration() != null) {
MDC.put(GENERATION, metadata.getGeneration().toString());
}
MDC.put(UID, metadata.getUid());
}
if (enabled) {
MDC.put(API_VERSION, resource.getApiVersion());
MDC.put(KIND, resource.getKind());
final var metadata = resource.getMetadata();
if (metadata != null) {
MDC.put(NAME, metadata.getName());
if (metadata.getNamespace() != null) {
MDC.put(NAMESPACE, metadata.getNamespace());
}
MDC.put(RESOURCE_VERSION, metadata.getResourceVersion());
if (metadata.getGeneration() != null) {
MDC.put(GENERATION, metadata.getGeneration().toString());
}
MDC.put(UID, metadata.getUid());
}
}
}

public static void removeResourceInfo() {
if (enabled) {
MDC.remove(API_VERSION);
MDC.remove(KIND);
MDC.remove(NAME);
MDC.remove(NAMESPACE);
MDC.remove(RESOURCE_VERSION);
MDC.remove(GENERATION);
MDC.remove(UID);
}
if (enabled) {
MDC.remove(API_VERSION);
MDC.remove(KIND);
MDC.remove(NAME);
MDC.remove(NAMESPACE);
MDC.remove(RESOURCE_VERSION);
MDC.remove(GENERATION);
MDC.remove(UID);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class ReconciliationDispatcher<P extends HasMetadata> {
public ReconciliationDispatcher(Controller<P> controller) {
this(controller,
new CustomResourceFacade<>(controller.getCRClient(), controller.getConfiguration(),
controller.getConfiguration().getConfigurationService().getResourceCloner()));
controller.getConfiguration().getConfigurationService().getResourceCloner()));
}

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

public CustomResourceFacade(
MixedOperation<R, KubernetesResourceList<R>, Resource<R>> resourceOperation,
ControllerConfiguration<R> configuration, Cloner cloner) {
MixedOperation<R, KubernetesResourceList<R>, Resource<R>> resourceOperation,
ControllerConfiguration<R> configuration, Cloner cloner) {
this.resourceOperation = resourceOperation;
this.useSSA =
configuration.getConfigurationService().useSSAToPatchPrimaryResource();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public UpdateControl<ChangeNamespaceTestCustomResource> reconcile(

var statusPatchResource = new ChangeNamespaceTestCustomResource();
statusPatchResource.setMetadata(new ObjectMetaBuilder()
.withName(primary.getMetadata().getName())
.withNamespace(primary.getMetadata().getNamespace())
.build());
.withName(primary.getMetadata().getName())
.withNamespace(primary.getMetadata().getNamespace())
.build());
statusPatchResource.setStatus(new ChangeNamespaceTestCustomResourceStatus());
var statusUpdates = primary.getStatus().getNumberOfStatusUpdates();
statusPatchResource.getStatus().setNumberOfStatusUpdates(statusUpdates + 1);
Expand Down
95 changes: 50 additions & 45 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
<maven-install-plugin.version>3.1.3</maven-install-plugin.version>
<git-commit-id-maven-plugin.version>9.0.1</git-commit-id-maven-plugin.version>
<jib-maven-plugin.version>3.4.4</jib-maven-plugin.version>
<spotless.version>2.44.3</spotless.version>
<spotless.version>2.43.0</spotless.version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -327,53 +327,58 @@
<excludedGroups>WatchPermissionAwareTest</excludedGroups>
</configuration>
</plugin>
<plugin>
<groupId>org.commonjava.maven.plugins</groupId>
<artifactId>directory-maven-plugin</artifactId>
<version>0.1</version>
<executions>
<execution>
<id>directories</id>
<goals>
<goal>highest-basedir</goal>
</goals>
<phase>initialize</phase>
<configuration>
<property>highest-basedir</property>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<configuration>
<pom>
<includes>
<include>pom.xml</include>
<include>./**/pom.xml</include>
</includes>
<sortPom>
<expandEmptyElements>false</expandEmptyElements>
</sortPom>
</pom>
<java>
<eclipse>
<file>${highest-basedir}/contributing/eclipse-google-style.xml</file>
</eclipse>
<importOrder>
<order>java,javax,org,io,com,,\#</order>
</importOrder>
<removeUnusedImports/>
</java>
</configuration>
<executions>
<execution>
<goals>
<goal>apply</goal>
</goals>
<phase>compile</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>spotless</id>
<activation>
<file>
<exists>contributing</exists>
</file>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<configuration>
<pom>
<includes>
<include>pom.xml</include>
<include>./**/pom.xml</include>
</includes>
<sortPom>
<expandEmptyElements>false</expandEmptyElements>
</sortPom>
</pom>
<java>
<eclipse>
<file>contributing/eclipse-google-style.xml</file>
</eclipse>
<importOrder>
<file>contributing/eclipse.importorder</file>
</importOrder>
<removeUnusedImports/>
</java>
</configuration>
<executions>
<execution>
<goals>
<goal>apply</goal>
</goals>
<phase>compile</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>integration-tests</id>
<build>
Expand Down
Loading