Skip to content

Commit

Permalink
Bump Kubernetes Client to 5.x
Browse files Browse the repository at this point in the history
  • Loading branch information
geoand committed Dec 22, 2020
1 parent 0e6213e commit d028be8
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 20 deletions.
2 changes: 1 addition & 1 deletion bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
<sentry.version>1.7.30</sentry.version>
<subethasmtp.version>3.1.7</subethasmtp.version>
<hibernate-quarkus-local-cache.version>0.1.0</hibernate-quarkus-local-cache.version>
<kubernetes-client.version>4.13.0</kubernetes-client.version>
<kubernetes-client.version>5.0.0-beta-1</kubernetes-client.version>
<flapdoodle.mongo.version>2.2.0</flapdoodle.mongo.version>
<quarkus-spring-api.version>5.2.SP4</quarkus-spring-api.version>
<quarkus-spring-data-api.version>2.1.SP1</quarkus-spring-data-api.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,6 @@ public void process(ApplicationIndexBuildItem applicationIndex, CombinedIndexBui
DotName.createSimple("io.fabric8.kubernetes.api.model.KubernetesResourceList")));
ignoredJsonDeserializationClasses.produce(new IgnoreJsonDeserializeClassBuildItem(KUBERNETES_RESOURCE));

final String[] doneables = combinedIndexBuildItem.getIndex()
.getAllKnownImplementors(DotName.createSimple("io.fabric8.kubernetes.api.model.Doneable"))
.stream()
.map(c -> c.name().toString())
.toArray(String[]::new);
reflectiveClasses.produce(ReflectiveClassBuildItem.weakClass(doneables));

final String[] deserializerClasses = combinedIndexBuildItem.getIndex()
.getAllKnownSubclasses(DotName.createSimple("com.fasterxml.jackson.databind.JsonDeserializer"))
.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
import io.fabric8.kubernetes.api.model.ConfigMap;
import io.fabric8.kubernetes.api.model.ConfigMapBuilder;
import io.fabric8.kubernetes.api.model.ConfigMapList;
import io.fabric8.kubernetes.api.model.DoneableConfigMap;
import io.fabric8.kubernetes.api.model.DoneableSecret;
import io.fabric8.kubernetes.api.model.Secret;
import io.fabric8.kubernetes.api.model.SecretBuilder;
import io.fabric8.kubernetes.api.model.SecretList;
Expand Down Expand Up @@ -166,11 +164,11 @@ public void testConfigSourcesAbsentFailOnMissing() {
}

private void stubNamespacedConfigMap(KubernetesClient kubernetesClient, ConfigMap configMap, String configMapName) {
MixedOperation<ConfigMap, ConfigMapList, DoneableConfigMap, Resource<ConfigMap, DoneableConfigMap>> mixedOperation = (MixedOperation<ConfigMap, ConfigMapList, DoneableConfigMap, Resource<ConfigMap, DoneableConfigMap>>) mock(
MixedOperation<ConfigMap, ConfigMapList, Resource<ConfigMap>> mixedOperation = (MixedOperation<ConfigMap, ConfigMapList, Resource<ConfigMap>>) mock(
MixedOperation.class);
when(kubernetesClient.configMaps()).thenReturn(mixedOperation);
Resource<ConfigMap, DoneableConfigMap> resource = (Resource<ConfigMap, DoneableConfigMap>) mock(Resource.class);
NonNamespaceOperation<ConfigMap, ConfigMapList, DoneableConfigMap, Resource<ConfigMap, DoneableConfigMap>> nsClient = (NonNamespaceOperation<ConfigMap, ConfigMapList, DoneableConfigMap, Resource<ConfigMap, DoneableConfigMap>>) mock(
Resource<ConfigMap> resource = (Resource<ConfigMap>) mock(Resource.class);
NonNamespaceOperation<ConfigMap, ConfigMapList, Resource<ConfigMap>> nsClient = (NonNamespaceOperation<ConfigMap, ConfigMapList, Resource<ConfigMap>>) mock(
NonNamespaceOperation.class);
when(mixedOperation.inNamespace("demo")).thenReturn(nsClient);
when(nsClient.withName(configMapName)).thenReturn(resource);
Expand All @@ -183,10 +181,10 @@ private void stubNamespacedConfigMap(KubernetesClient kubernetesClient, ConfigMa
}

private void stubConfigMap(KubernetesClient kubernetesClient, ConfigMap configMap, String configMapName) {
MixedOperation<ConfigMap, ConfigMapList, DoneableConfigMap, Resource<ConfigMap, DoneableConfigMap>> mixedOperation = (MixedOperation<ConfigMap, ConfigMapList, DoneableConfigMap, Resource<ConfigMap, DoneableConfigMap>>) mock(
MixedOperation<ConfigMap, ConfigMapList, Resource<ConfigMap>> mixedOperation = (MixedOperation<ConfigMap, ConfigMapList, Resource<ConfigMap>>) mock(
MixedOperation.class);
when(kubernetesClient.configMaps()).thenReturn(mixedOperation);
Resource<ConfigMap, DoneableConfigMap> resource = (Resource<ConfigMap, DoneableConfigMap>) mock(Resource.class);
Resource<ConfigMap> resource = (Resource<ConfigMap>) mock(Resource.class);
when(mixedOperation.withName(configMapName)).thenReturn(resource);
when(resource.get()).thenReturn(configMap);
Config kubernetesConfig = mock(Config.class);
Expand All @@ -196,10 +194,10 @@ private void stubConfigMap(KubernetesClient kubernetesClient, ConfigMap configMa
}

private void stubSecrets(KubernetesClient kubernetesClient, Secret secret, String secretName) {
MixedOperation<Secret, SecretList, DoneableSecret, Resource<Secret, DoneableSecret>> mixedOperation = (MixedOperation<Secret, SecretList, DoneableSecret, Resource<Secret, DoneableSecret>>) mock(
MixedOperation<Secret, SecretList, Resource<Secret>> mixedOperation = (MixedOperation<Secret, SecretList, Resource<Secret>>) mock(
MixedOperation.class);
when(kubernetesClient.secrets()).thenReturn(mixedOperation);
Resource<Secret, DoneableSecret> resource = (Resource<Secret, DoneableSecret>) mock(Resource.class);
Resource<Secret> resource = (Resource<Secret>) mock(Resource.class);
when(mixedOperation.withName(secretName)).thenReturn(resource);
when(resource.get()).thenReturn(secret);
Config kubernetesConfig = mock(Config.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ public Response updateFirst(@PathParam("namespace") String namespace) {
@Path("/{namespace}")
public Response createNew(@PathParam("namespace") String namespace) {
return Response
.ok(kubernetesClient.pods().inNamespace(namespace).createNew().withNewMetadata().withResourceVersion("12345")
.endMetadata().done())
.ok(kubernetesClient.pods().inNamespace(namespace)
.create(new PodBuilder().withNewMetadata().withResourceVersion("12345")
.endMetadata().build()))
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ void createRoute() {
.once();

NamespacedOpenShiftClient openShiftClient = mockServer.createOpenShiftClient();
openShiftClient.routes().createNew().withNewMetadata().withName("myroute").withNamespace("test").endMetadata().done();
openShiftClient.routes()
.create(new RouteBuilder().withNewMetadata().withName("myroute").withNamespace("test").endMetadata().build());
Route route = openShiftClient.routes().inNamespace("test").withName("myroute").get();
Assertions.assertNotNull(route);
}
Expand Down

0 comments on commit d028be8

Please sign in to comment.