Skip to content

Commit

Permalink
chore: update to josdk v5.0.0-beta1 and fabric8-client v7.0.0 and rel…
Browse files Browse the repository at this point in the history
…ated fixes (#191)

* chore: update to josdk v5.0.0-beta1 and fabric8 kubernetes-client v7.0.0 and related fixes

* fix: apply spotless plugin to reformat code

* fix: remove dependency jetbrains-annotations from pom files

* fix: remove unnecessary jetbrain-annotation from CRDApplier.java
  • Loading branch information
ebma16 authored Dec 10, 2024
1 parent 9d69dd0 commit 334da33
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 26 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@
<maven.compiler.release>17</maven.compiler.release>
<spotless.version>2.43.0</spotless.version>
<spring-boot.version>3.3.6</spring-boot.version>
<josdk.version>4.9.7</josdk.version>
<josdk.version>5.0.0-beta1</josdk.version>
<surefire.version>3.5.2</surefire.version>
<fabric8-client.version>6.13.4</fabric8-client.version>
<fabric8-client.version>7.0.0</fabric8-client.version>
<jenvtest.version>0.9.7</jenvtest.version>
<nexus-staging-maven-plugin.version>1.7.0</nexus-staging-maven-plugin.version>
<maven-javadoc-plugin.version>3.11.2</maven-javadoc-plugin.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
import io.fabric8.kubernetes.api.model.ConfigMap;
import io.fabric8.kubernetes.api.model.ConfigMapBuilder;
import io.fabric8.kubernetes.api.model.ObjectMetaBuilder;
import io.javaoperatorsdk.operator.api.config.informer.Informer;
import io.javaoperatorsdk.operator.api.reconciler.Context;
import io.javaoperatorsdk.operator.processing.dependent.kubernetes.CRUDKubernetesDependentResource;
import io.javaoperatorsdk.operator.processing.dependent.kubernetes.KubernetesDependent;

@KubernetesDependent(labelSelector = "app.kubernetes.io/managed-by=custom-service-operator")
public class ConfigMapDpendentResource
@KubernetesDependent(
informer = @Informer(labelSelector = "app.kubernetes.io/managed-by=custom-service-operator"))
public class ConfigMapDependentResource
extends CRUDKubernetesDependentResource<ConfigMap, CustomService> {
public ConfigMapDpendentResource() {
public ConfigMapDependentResource() {
super(ConfigMap.class);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
import io.javaoperatorsdk.operator.api.reconciler.dependent.Dependent;

/** A very simple sample controller that creates a service with a label. */
@ControllerConfiguration(dependents = {
@Dependent(name = "config", type = ConfigMapDpendentResource.class)
@Workflow(dependents = {
@Dependent(name = "config", type = ConfigMapDependentResource.class)
})
@ControllerConfiguration
public class CustomServiceReconciler implements Reconciler<CustomService> {

private static final Logger log = LoggerFactory.getLogger(CustomServiceReconciler.class);
Expand Down Expand Up @@ -57,6 +58,6 @@ public UpdateControl<CustomService> reconcile(
.inNamespace(resource.getMetadata().getNamespace())
.createOrReplace(service);

return UpdateControl.updateResource(resource);
return UpdateControl.patchResource(resource);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@
import io.fabric8.kubernetes.client.server.mock.KubernetesMockServer;
import io.fabric8.kubernetes.client.utils.Serialization;
import io.fabric8.mockwebserver.Context;
import io.fabric8.mockwebserver.MockWebServer;
import io.javaoperatorsdk.operator.springboot.starter.OperatorAutoConfiguration;

import okhttp3.mockwebserver.MockWebServer;

@Configuration
@ImportAutoConfiguration(OperatorAutoConfiguration.class)
@EnableConfigurationProperties(TestConfigurationProperties.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import java.util.List;
import java.util.function.UnaryOperator;

import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;

import io.fabric8.kubernetes.api.model.HasMetadata;
Expand All @@ -27,7 +26,7 @@ public interface CRDApplier {
void apply();

interface CRDTransformer extends UnaryOperator<HasMetadata> {
default CRDTransformer thenTransform(@NotNull CRDApplier.CRDTransformer after) {
default CRDTransformer thenTransform(CRDApplier.CRDTransformer after) {
return t -> after.apply(apply(t));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@
import io.fabric8.openshift.client.OpenShiftClient;
import io.javaoperatorsdk.operator.Operator;
import io.javaoperatorsdk.operator.ReconcilerUtils;
import io.javaoperatorsdk.operator.api.config.*;
import io.javaoperatorsdk.operator.api.config.Cloner;
import io.javaoperatorsdk.operator.api.config.ConfigurationServiceOverrider;
import io.javaoperatorsdk.operator.api.config.ControllerConfigurationOverrider;
import io.javaoperatorsdk.operator.api.config.DefaultResourceClassResolver;
import io.javaoperatorsdk.operator.api.config.ResourceClassResolver;
import io.javaoperatorsdk.operator.api.monitoring.Metrics;
import io.javaoperatorsdk.operator.api.reconciler.Reconciler;
import io.javaoperatorsdk.operator.processing.retry.GenericRetry;
Expand Down Expand Up @@ -93,7 +97,7 @@ public Operator operator(
KubernetesClient kubernetesClient,
List<Reconciler<?>> reconcilers) {

var operator = new Operator(kubernetesClient, compositeConfigurationServiceOverrider);
var operator = new Operator(compositeConfigurationServiceOverrider);
reconcilers.forEach(reconciler -> reconcilerRegisterer.accept(operator, reconciler));

return operator;
Expand Down Expand Up @@ -122,14 +126,9 @@ public Consumer<ConfigurationServiceOverrider> compositeConfigurationServiceOver
@Order(0)
public Consumer<ConfigurationServiceOverrider> defaultConfigServiceOverrider(
@Autowired(required = false) Cloner cloner,
ResourceClassResolver resourceClassResolver,
Metrics metrics) {
Metrics metrics, KubernetesClient kubernetesClient) {
return overrider -> {
doIfPresent(cloner, overrider::withResourceCloner);
doIfPresent(configuration.getMinConcurrentWorkflowExecutorThreads(),
overrider::withMinConcurrentWorkflowExecutorThreads);
doIfPresent(configuration.getMinConcurrentReconciliationThreads(),
overrider::withMinConcurrentReconciliationThreads);
doIfPresent(configuration.getStopOnInformerErrorDuringStartup(),
overrider::withStopOnInformerErrorDuringStartup);
doIfPresent(configuration.getConcurrentWorkflowExecutorThreads(),
Expand All @@ -139,8 +138,8 @@ public Consumer<ConfigurationServiceOverrider> defaultConfigServiceOverrider(
overrider
.withConcurrentReconciliationThreads(configuration.getConcurrentReconciliationThreads())
.withMetrics(metrics)
.withResourceClassResolver(resourceClassResolver)
.checkingCRDAndValidateLocalModel(configuration.getCheckCrdAndValidateLocalModel());
.checkingCRDAndValidateLocalModel(configuration.getCheckCrdAndValidateLocalModel())
.withKubernetesClient(kubernetesClient);
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,13 @@ void appliesConfigPropertiesToControllers() {
.satisfies(controller -> {
assertThat((ControllerConfiguration<?>) controller.getConfiguration())
.satisfies(config -> {
assertThat(config.getNamespaces()).containsExactlyInAnyOrder("ns1", "ns2");
assertThat(config.getInformerConfig().getNamespaces())
.containsExactlyInAnyOrder("ns1", "ns2");
assertThat(config.isGenerationAware()).isTrue();
assertThat(config.getName()).isEqualTo("not-a-test-reconciler");
assertThat(config.getFinalizerName()).isEqualTo("barton.fink/1991");
assertThat(config.getLabelSelector()).isEqualTo("version in (v1)");
assertThat(config.getInformerConfig().getLabelSelector())
.isEqualTo("version in (v1)");
assertThat(config.maxReconciliationInterval()).hasValue(Duration.ofMinutes(3));
});
assertThat(controller.getConfiguration().getRetry())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.javaoperatorsdk.operator.springboot.starter.model;

import io.fabric8.kubernetes.client.CustomResourceList;
import io.fabric8.kubernetes.api.model.DefaultKubernetesResourceList;

public class TestResourceList extends CustomResourceList<TestResource> {
public class TestResourceList extends DefaultKubernetesResourceList<TestResource> {
}

0 comments on commit 334da33

Please sign in to comment.