diff --git a/build.gradle b/build.gradle index f0744e0..724b625 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { id 'java-library' id 'org.springframework.boot' version '3.3.0' apply false id 'io.spring.dependency-management' version '1.1.5' - id 'com.diffplug.spotless' version '7.0.0.BETA2' + id 'com.diffplug.spotless' version '6.25.0' id 'maven-publish' id 'signing' id 'net.thebugmc.gradle.sonatype-central-portal-publisher' version '1.2.4' @@ -61,8 +61,6 @@ tasks.withType(JavaCompile).configureEach { apply plugin: "com.diffplug.spotless" spotless { - ratchetFrom 'origin/main' - format 'misc', { target '*.gradle', '.gitattributes', '.gitignore' diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a441313..9355b41 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/src/main/java/io/k8swatcher/annotation/EventType.java b/src/main/java/io/k8swatcher/annotation/EventType.java index 8e70e23..f2b1579 100644 --- a/src/main/java/io/k8swatcher/annotation/EventType.java +++ b/src/main/java/io/k8swatcher/annotation/EventType.java @@ -1,7 +1,6 @@ package io.k8swatcher.annotation; public enum EventType { - ADD, UPDATE, DELETE diff --git a/src/main/java/io/k8swatcher/annotation/Watch.java b/src/main/java/io/k8swatcher/annotation/Watch.java index 071757d..0a957bd 100644 --- a/src/main/java/io/k8swatcher/annotation/Watch.java +++ b/src/main/java/io/k8swatcher/annotation/Watch.java @@ -1,8 +1,6 @@ package io.k8swatcher.annotation; - import io.fabric8.kubernetes.api.model.KubernetesResource; - import java.lang.annotation.*; @Target(ElementType.METHOD) @@ -11,5 +9,6 @@ public @interface Watch { EventType event(); + Class resource(); } diff --git a/src/main/java/io/k8swatcher/annotation/cfg/InformerContext.java b/src/main/java/io/k8swatcher/annotation/cfg/InformerContext.java index 2f2bedf..9f17b38 100644 --- a/src/main/java/io/k8swatcher/annotation/cfg/InformerContext.java +++ b/src/main/java/io/k8swatcher/annotation/cfg/InformerContext.java @@ -11,7 +11,6 @@ @AllArgsConstructor public class InformerContext { - @Setter(AccessLevel.NONE) private Class beanClass; diff --git a/src/main/java/io/k8swatcher/annotation/processor/InformerCreator.java b/src/main/java/io/k8swatcher/annotation/processor/InformerCreator.java index 455cfd6..f6aed76 100644 --- a/src/main/java/io/k8swatcher/annotation/processor/InformerCreator.java +++ b/src/main/java/io/k8swatcher/annotation/processor/InformerCreator.java @@ -57,7 +57,8 @@ List createInformers() { List informers = namespaces.stream() .map(nsName -> (NonNamespaceOperation) client.resources(resource).inNamespace(nsName)) - .map(nsOperation -> createSharedIndexInformer(nsOperation, resLabels)) + .map(nsOperation -> createSharedIndexInformer( + nsOperation, resLabels, informerConfiguration.getResyncPeriod())) .map(sharedIndexInformer -> sharedIndexInformer.addEventHandlerWithResyncPeriod( new IndexInformerResHandler(ctx, watchMethod, beanClass), informerConfiguration.getResyncPeriod())) @@ -89,13 +90,13 @@ private List getNamespaces(KubernetesClient client, InformerConfiguratio } private SharedIndexInformer createSharedIndexInformer( - NonNamespaceOperation nsOperation, Map resLabels) { + NonNamespaceOperation nsOperation, Map resLabels, long resyncPeriod) { log.debug("resLabels={}", resLabels); if (resLabels.isEmpty()) { - return nsOperation.inform(); + return nsOperation.runnableInformer(resyncPeriod); } - return ((FilterWatchListDeletable) nsOperation.withLabels(resLabels)).inform(); + return ((FilterWatchListDeletable) nsOperation.withLabels(resLabels)).runnableInformer(resyncPeriod); } private List getInformerContextList() { diff --git a/src/main/java/io/k8swatcher/annotation/processor/K8InformerEntrypoint.java b/src/main/java/io/k8swatcher/annotation/processor/K8InformerEntrypoint.java index e068c5e..4060155 100644 --- a/src/main/java/io/k8swatcher/annotation/processor/K8InformerEntrypoint.java +++ b/src/main/java/io/k8swatcher/annotation/processor/K8InformerEntrypoint.java @@ -15,8 +15,8 @@ @SuppressWarnings("rawtypes") public class K8InformerEntrypoint { - private AnnotationValidator validator; - private InformerCreator informerCreator; + private final AnnotationValidator validator; + private final InformerCreator informerCreator; private List informerList; public K8InformerEntrypoint(AnnotationValidator validator, InformerCreator informerCreator) { @@ -29,6 +29,7 @@ public K8InformerEntrypoint(AnnotationValidator validator, InformerCreator infor public void onStartUp(ApplicationReadyEvent event) { validateAnnotations(); this.informerList = informerCreator.createInformers(); + informerList.forEach(SharedIndexInformer::start); } private void validateAnnotations() {