From 3380ae547dc98e1aaae5c27375f31dabdd6d03d3 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Fri, 15 Nov 2024 11:19:23 +0100 Subject: [PATCH] fix: removed SupportTestingClient interface Signed-off-by: Marc Nuri --- CHANGELOG.md | 3 +- doc/MIGRATION-v7.md | 9 ++++ .../client/DefaultChaosMeshClient.java | 7 +-- .../istio/client/DefaultIstioClient.java | 8 +--- .../knative/client/DefaultKnativeClient.java | 8 +--- .../DefaultOpenClusterManagementClient.java | 8 +--- .../tekton/client/DefaultTektonClient.java | 8 +--- .../DefaultVerticalPodAutoscalerClient.java | 8 +--- .../volcano/client/DefaultVolcanoClient.java | 8 +--- .../client/DefaultVolumeSnapshotClient.java | 8 +--- .../io/fabric8/kubernetes/client/Client.java | 2 +- .../extension/SupportTestingClient.java | 45 ------------------- .../kubernetes/client/impl/BaseClient.java | 8 +--- .../client/mock/KubernetesMockServerTest.java | 4 +- .../NamespacedOpenShiftClientAdapter.java | 5 --- .../openshift/client/OpenShiftClient.java | 5 +-- .../client/impl/OpenShiftClientImpl.java | 25 ----------- .../impl/OpenShiftExtensionAdapterTest.java | 41 ----------------- 18 files changed, 25 insertions(+), 185 deletions(-) delete mode 100644 kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extension/SupportTestingClient.java delete mode 100644 openshift-client/src/test/java/io/fabric8/openshift/client/impl/OpenShiftExtensionAdapterTest.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 0eec9a6d1e9..6c7d23c5a7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,10 +28,11 @@ #### _**Note**_: Breaking changes * Check detailed migration documentation for breaking changes in [7.0.0](./doc/MIGRATION-v7.md) +* Fix #4659: Removed `SupportTestingClient` interface * Fix #5264: `Config.errorMessages` has been removed. Please use Kubernetes status messages directly. +* Fix #5351: Removed deprecated `io.fabric8:openshift-server-mock` artifact * Fix #6081: Moved Java baseline from 8 (1.8) to 11 * Fix #6138: Removed unused `io:fabric8:kubernetes-model` artifact -* Fix #5351: Removed deprecated `io.fabric8:openshift-server-mock` artifact * Fix #6156: Removed deprecated extension `io:fabric8:service-catalog` * Fix #6158: Removed deprecated methods from `io.fabric8.kubernetes.client.utils.IOHelpers` * Fix #6361: Renamed SettableBeanPropertyDelegate to SettableBeanPropertyDelegating diff --git a/doc/MIGRATION-v7.md b/doc/MIGRATION-v7.md index ec589b3ece9..90c47bf0b98 100644 --- a/doc/MIGRATION-v7.md +++ b/doc/MIGRATION-v7.md @@ -24,6 +24,7 @@ - [Deprecations and Removals](#deprecations-and-removals) - [Apache Felix SCR Annotations removed](#apache-felix-scr-annotations) - [OpenShift Server Mock removed](#openshift-server-mock-removed) + - [SupportTestingClient removed](#supporttestingclient-removed) - [Service Catalog API (extension) removed](#service-catalog-extension) @@ -272,6 +273,14 @@ The usage of the `@EnableOpenShiftMockClient` annotation should be replaced with The use of the `OpenShiftMockServer` class should be replaced with the `KubernetesMockServer` class. +### SupportTestingClient removed + +The deprecated interface `SupportTestingClient` has been removed from the project. + +The method `client.isSupported` is no longer available. +You can replace it with the `Client.hasApiGroup` method or one of the `Client.supports` alternative methods. +For OpenShift, you can also leverage the `OpenShiftClient.supportsOpenShiftAPIGroup` method. + ### Service Catalog API (extension) removed The Service Catalog API extension has been removed. diff --git a/extensions/chaosmesh/client/src/main/java/io/fabric8/chaosmesh/client/DefaultChaosMeshClient.java b/extensions/chaosmesh/client/src/main/java/io/fabric8/chaosmesh/client/DefaultChaosMeshClient.java index f0b5ae614ae..5ba58e26f64 100644 --- a/extensions/chaosmesh/client/src/main/java/io/fabric8/chaosmesh/client/DefaultChaosMeshClient.java +++ b/extensions/chaosmesh/client/src/main/java/io/fabric8/chaosmesh/client/DefaultChaosMeshClient.java @@ -47,10 +47,9 @@ import io.fabric8.kubernetes.client.dsl.MixedOperation; import io.fabric8.kubernetes.client.dsl.Resource; import io.fabric8.kubernetes.client.extension.ExtensionRootClientAdapter; -import io.fabric8.kubernetes.client.extension.SupportTestingClient; public class DefaultChaosMeshClient extends ExtensionRootClientAdapter - implements NamespacedChaosMeshClient, SupportTestingClient { + implements NamespacedChaosMeshClient { public DefaultChaosMeshClient() { super(); @@ -134,8 +133,4 @@ public MixedOperation> awsChaos() { return resources(AWSChaos.class, AWSChaosList.class); } - @Override - public boolean isSupported() { - return hasApiGroup("chaos-mesh.org", false); - } } diff --git a/extensions/istio/client/src/main/java/io/fabric8/istio/client/DefaultIstioClient.java b/extensions/istio/client/src/main/java/io/fabric8/istio/client/DefaultIstioClient.java index ce374f15ee6..e9d8b3f984d 100644 --- a/extensions/istio/client/src/main/java/io/fabric8/istio/client/DefaultIstioClient.java +++ b/extensions/istio/client/src/main/java/io/fabric8/istio/client/DefaultIstioClient.java @@ -21,10 +21,9 @@ import io.fabric8.kubernetes.client.WithRequestCallable; import io.fabric8.kubernetes.client.dsl.FunctionCallable; import io.fabric8.kubernetes.client.extension.ExtensionRootClientAdapter; -import io.fabric8.kubernetes.client.extension.SupportTestingClient; public class DefaultIstioClient extends ExtensionRootClientAdapter - implements NamespacedIstioClient, SupportTestingClient { + implements NamespacedIstioClient { public DefaultIstioClient() { super(); @@ -57,9 +56,4 @@ public V1alpha3APIGroupDSL v1alpha3() { public V1beta1APIGroupDSL v1beta1() { return adapt(V1beta1APIGroupClient.class); } - - @Override - public boolean isSupported() { - return hasApiGroup("istio.io", false); - } } diff --git a/extensions/knative/client/src/main/java/io/fabric8/knative/client/DefaultKnativeClient.java b/extensions/knative/client/src/main/java/io/fabric8/knative/client/DefaultKnativeClient.java index cd2431729ee..2eec1be9265 100644 --- a/extensions/knative/client/src/main/java/io/fabric8/knative/client/DefaultKnativeClient.java +++ b/extensions/knative/client/src/main/java/io/fabric8/knative/client/DefaultKnativeClient.java @@ -77,10 +77,9 @@ import io.fabric8.kubernetes.client.dsl.MixedOperation; import io.fabric8.kubernetes.client.dsl.Resource; import io.fabric8.kubernetes.client.extension.ExtensionRootClientAdapter; -import io.fabric8.kubernetes.client.extension.SupportTestingClient; public class DefaultKnativeClient extends ExtensionRootClientAdapter - implements NamespacedKnativeClient, SupportTestingClient { + implements NamespacedKnativeClient { public DefaultKnativeClient() { super(); @@ -238,9 +237,4 @@ public MixedOperation> kafka public MixedOperation> kafkaBindings() { return resources(KafkaBinding.class, KafkaBindingList.class); } - - @Override - public boolean isSupported() { - return hasApiGroup("knative.dev", false); - } } diff --git a/extensions/open-cluster-management/client/src/main/java/io/fabric8/openclustermanagement/client/DefaultOpenClusterManagementClient.java b/extensions/open-cluster-management/client/src/main/java/io/fabric8/openclustermanagement/client/DefaultOpenClusterManagementClient.java index f21d69db279..3a3f0323bbc 100644 --- a/extensions/open-cluster-management/client/src/main/java/io/fabric8/openclustermanagement/client/DefaultOpenClusterManagementClient.java +++ b/extensions/open-cluster-management/client/src/main/java/io/fabric8/openclustermanagement/client/DefaultOpenClusterManagementClient.java @@ -21,7 +21,6 @@ import io.fabric8.kubernetes.client.WithRequestCallable; import io.fabric8.kubernetes.client.dsl.FunctionCallable; import io.fabric8.kubernetes.client.extension.ExtensionRootClientAdapter; -import io.fabric8.kubernetes.client.extension.SupportTestingClient; import io.fabric8.openclustermanagement.client.dsl.OpenClusterManagementAgentAPIGroupDSL; import io.fabric8.openclustermanagement.client.dsl.OpenClusterManagementAppsAPIGroupDSL; import io.fabric8.openclustermanagement.client.dsl.OpenClusterManagementClustersAPIGroupDSL; @@ -31,7 +30,7 @@ import io.fabric8.openclustermanagement.client.dsl.OpenClusterManagementSearchAPIGroupDSL; public class DefaultOpenClusterManagementClient extends ExtensionRootClientAdapter - implements NamespacedOpenClusterManagementClient, SupportTestingClient { + implements NamespacedOpenClusterManagementClient { public DefaultOpenClusterManagementClient() { super(); @@ -94,9 +93,4 @@ public OpenClusterManagementPolicyAPIGroupDSL policy() { public OpenClusterManagementSearchAPIGroupDSL search() { return adapt(OpenClusterManagementSearchAPIGroupClient.class); } - - @Override - public boolean isSupported() { - return hasApiGroup("open-cluster-management.io", false); - } } diff --git a/extensions/tekton/client/src/main/java/io/fabric8/tekton/client/DefaultTektonClient.java b/extensions/tekton/client/src/main/java/io/fabric8/tekton/client/DefaultTektonClient.java index cc0a2143501..ab6f8735290 100644 --- a/extensions/tekton/client/src/main/java/io/fabric8/tekton/client/DefaultTektonClient.java +++ b/extensions/tekton/client/src/main/java/io/fabric8/tekton/client/DefaultTektonClient.java @@ -21,13 +21,12 @@ import io.fabric8.kubernetes.client.WithRequestCallable; import io.fabric8.kubernetes.client.dsl.FunctionCallable; import io.fabric8.kubernetes.client.extension.ExtensionRootClientAdapter; -import io.fabric8.kubernetes.client.extension.SupportTestingClient; import io.fabric8.tekton.client.dsl.V1APIGroupDSL; import io.fabric8.tekton.client.dsl.V1alpha1APIGroupDSL; import io.fabric8.tekton.client.dsl.V1beta1APIGroupDSL; public class DefaultTektonClient extends ExtensionRootClientAdapter - implements NamespacedTektonClient, SupportTestingClient { + implements NamespacedTektonClient { public DefaultTektonClient() { super(); @@ -66,9 +65,4 @@ public V1alpha1APIGroupDSL v1alpha1() { return adapt(V1alpha1APIGroupClient.class); } - @Override - public boolean isSupported() { - return hasApiGroup("tekton.dev", false); - } - } diff --git a/extensions/verticalpodautoscaler/client/src/main/java/io/fabric8/verticalpodautoscaler/client/DefaultVerticalPodAutoscalerClient.java b/extensions/verticalpodautoscaler/client/src/main/java/io/fabric8/verticalpodautoscaler/client/DefaultVerticalPodAutoscalerClient.java index 7a9ef1f2bab..a2f1ee7b89a 100644 --- a/extensions/verticalpodautoscaler/client/src/main/java/io/fabric8/verticalpodautoscaler/client/DefaultVerticalPodAutoscalerClient.java +++ b/extensions/verticalpodautoscaler/client/src/main/java/io/fabric8/verticalpodautoscaler/client/DefaultVerticalPodAutoscalerClient.java @@ -21,11 +21,10 @@ import io.fabric8.kubernetes.client.WithRequestCallable; import io.fabric8.kubernetes.client.dsl.FunctionCallable; import io.fabric8.kubernetes.client.extension.ExtensionRootClientAdapter; -import io.fabric8.kubernetes.client.extension.SupportTestingClient; import io.fabric8.verticalpodautoscaler.client.dsl.V1APIGroupDSL; public class DefaultVerticalPodAutoscalerClient extends ExtensionRootClientAdapter - implements NamespacedVerticalPodAutoscalerClient, SupportTestingClient { + implements NamespacedVerticalPodAutoscalerClient { public DefaultVerticalPodAutoscalerClient() { super(); @@ -54,9 +53,4 @@ public V1APIGroupDSL v1() { return adapt(V1APIGroupClient.class); } - @Override - public boolean isSupported() { - return getClient().hasApiGroup(VerticalPodAutoscalerExtensionAdapter.API_GROUP, false); - } - } diff --git a/extensions/volcano/client/src/main/java/io/fabric8/volcano/client/DefaultVolcanoClient.java b/extensions/volcano/client/src/main/java/io/fabric8/volcano/client/DefaultVolcanoClient.java index 593a2a942e8..ebf4b43f626 100644 --- a/extensions/volcano/client/src/main/java/io/fabric8/volcano/client/DefaultVolcanoClient.java +++ b/extensions/volcano/client/src/main/java/io/fabric8/volcano/client/DefaultVolcanoClient.java @@ -23,7 +23,6 @@ import io.fabric8.kubernetes.client.dsl.MixedOperation; import io.fabric8.kubernetes.client.dsl.Resource; import io.fabric8.kubernetes.client.extension.ExtensionRootClientAdapter; -import io.fabric8.kubernetes.client.extension.SupportTestingClient; import io.fabric8.volcano.api.model.scheduling.v1beta1.PodGroup; import io.fabric8.volcano.api.model.scheduling.v1beta1.PodGroupList; import io.fabric8.volcano.api.model.scheduling.v1beta1.Queue; @@ -31,7 +30,7 @@ import io.fabric8.volcano.client.dsl.V1beta1APIGroupDSL; public class DefaultVolcanoClient extends ExtensionRootClientAdapter - implements NamespacedVolcanoClient, SupportTestingClient { + implements NamespacedVolcanoClient { public DefaultVolcanoClient() { super(); @@ -72,9 +71,4 @@ public V1beta1APIGroupDSL v1beta1() { // User can specify client.v1beta1().podGroups() to use v1beta1 API return adapt(V1beta1APIGroupClient.class); } - - @Override - public boolean isSupported() { - return getClient().hasApiGroup(VolcanoExtensionAdapter.API_GROUP, false); - } } diff --git a/extensions/volumesnapshot/client/src/main/java/io/fabric8/volumesnapshot/client/DefaultVolumeSnapshotClient.java b/extensions/volumesnapshot/client/src/main/java/io/fabric8/volumesnapshot/client/DefaultVolumeSnapshotClient.java index 0918480bd25..f3e825555f8 100644 --- a/extensions/volumesnapshot/client/src/main/java/io/fabric8/volumesnapshot/client/DefaultVolumeSnapshotClient.java +++ b/extensions/volumesnapshot/client/src/main/java/io/fabric8/volumesnapshot/client/DefaultVolumeSnapshotClient.java @@ -23,7 +23,6 @@ import io.fabric8.kubernetes.client.dsl.MixedOperation; import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation; import io.fabric8.kubernetes.client.extension.ExtensionRootClientAdapter; -import io.fabric8.kubernetes.client.extension.SupportTestingClient; import io.fabric8.volumesnapshot.api.model.VolumeSnapshot; import io.fabric8.volumesnapshot.api.model.VolumeSnapshotClass; import io.fabric8.volumesnapshot.api.model.VolumeSnapshotClassList; @@ -32,7 +31,7 @@ import io.fabric8.volumesnapshot.api.model.VolumeSnapshotList; public class DefaultVolumeSnapshotClient extends ExtensionRootClientAdapter - implements NamespacedVolumeSnapshotClient, SupportTestingClient { + implements NamespacedVolumeSnapshotClient { public DefaultVolumeSnapshotClient() { super(); @@ -70,9 +69,4 @@ public MixedOperation withRequestConfig(RequestConfig requestConfig) { return new WithRequestCallable<>(this, requestConfig); } - - @Override - public boolean isSupported() { - return getClient().hasApiGroup(VolumeSnapshotExtensionAdapter.API_GROUP, false); - } } diff --git a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/Client.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/Client.java index fef95d5e022..dab9a4fc0b7 100644 --- a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/Client.java +++ b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/Client.java @@ -33,7 +33,7 @@ public interface Client extends Closeable { /** - * Checks if the client can be adapted to an other client type and if that target client is supported. + * Checks if the client can be adapted to another client type and if that target client is supported. * * @param type The target client class. * @param The target client type. diff --git a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extension/SupportTestingClient.java b/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extension/SupportTestingClient.java deleted file mode 100644 index d66a74626ae..00000000000 --- a/kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/extension/SupportTestingClient.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2015 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package io.fabric8.kubernetes.client.extension; - -import io.fabric8.kubernetes.client.Client; - -/** - * Marks the client as being able to test for its own support. - *

- * Moving forward only clients with special support needs, such as - * the openshift client should implement this interface. For those classes, - * this interface can be part of the public contract. - * - * @deprecated will be removed in future versions - */ -@Deprecated -public interface SupportTestingClient extends Client { - - /** - * Tests if the client is supported. - *
- * Implementations will use - * {@link Client#hasApiGroup(String, boolean)} to be compatible with mock support - * - * @return true if supported - * - * @deprecated use {@link Client#supports(Class)} or {@link Client#supports(String, String)} instead - */ - @Deprecated - boolean isSupported(); - -} diff --git a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/impl/BaseClient.java b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/impl/BaseClient.java index 45b0da8550e..fa29f1016ff 100644 --- a/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/impl/BaseClient.java +++ b/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/impl/BaseClient.java @@ -36,7 +36,6 @@ import io.fabric8.kubernetes.client.dsl.internal.OperationContext; import io.fabric8.kubernetes.client.dsl.internal.OperationSupport; import io.fabric8.kubernetes.client.extension.ExtensionAdapter; -import io.fabric8.kubernetes.client.extension.SupportTestingClient; import io.fabric8.kubernetes.client.http.HttpClient; import io.fabric8.kubernetes.client.utils.ApiVersionUtil; import io.fabric8.kubernetes.client.utils.KubernetesSerialization; @@ -219,12 +218,7 @@ public boolean hasApiGroup(String apiGroup, boolean exact) { @Override public Boolean isAdaptable(Class type) { - // if type is an instanceof SupportTestingClient, then it's a proper - // test, otherwise it could be legacy support on an extension client - C toTest = adapt(type); - if (toTest instanceof SupportTestingClient) { - return ((SupportTestingClient) toTest).isSupported(); - } + adapt(type); return true; } diff --git a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/KubernetesMockServerTest.java b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/KubernetesMockServerTest.java index caf91df33f4..aaef96666af 100644 --- a/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/KubernetesMockServerTest.java +++ b/kubernetes-tests/src/test/java/io/fabric8/kubernetes/client/mock/KubernetesMockServerTest.java @@ -63,11 +63,11 @@ void testReset() { void testOpenShiftSupport() { server.setUnsupported("openshift.io"); assertFalse(client.isAdaptable(OpenShiftClient.class)); - assertFalse(client.adapt(OpenShiftClient.class).isSupported()); assertFalse(client.supports(Route.class)); assertTrue(client.supports(Pod.class)); server.reset(); - assertTrue(client.adapt(OpenShiftClient.class).isSupported()); + assertTrue(client.isAdaptable(OpenShiftClient.class)); + assertTrue(client.supports(Route.class)); } @Version("v1") diff --git a/openshift-client-api/src/main/java/io/fabric8/openshift/client/NamespacedOpenShiftClientAdapter.java b/openshift-client-api/src/main/java/io/fabric8/openshift/client/NamespacedOpenShiftClientAdapter.java index d679c499a04..60ef524c573 100644 --- a/openshift-client-api/src/main/java/io/fabric8/openshift/client/NamespacedOpenShiftClientAdapter.java +++ b/openshift-client-api/src/main/java/io/fabric8/openshift/client/NamespacedOpenShiftClientAdapter.java @@ -512,11 +512,6 @@ public NonNamespaceOperation