Skip to content

Commit

Permalink
fix: removed SupportTestingClient interface
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Nuri <marc@marcnuri.com>
  • Loading branch information
manusa committed Nov 15, 2024
1 parent ed25431 commit 3380ae5
Show file tree
Hide file tree
Showing 18 changed files with 25 additions and 185 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions doc/MIGRATION-v7.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down Expand Up @@ -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 <a href="#supporttestingclient-removed" id="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 <a href="#service-catalog-extension" id="service-catalog-extension"/>

The Service Catalog API extension has been removed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<DefaultChaosMeshClient>
implements NamespacedChaosMeshClient, SupportTestingClient {
implements NamespacedChaosMeshClient {

public DefaultChaosMeshClient() {
super();
Expand Down Expand Up @@ -134,8 +133,4 @@ public MixedOperation<AWSChaos, AWSChaosList, Resource<AWSChaos>> awsChaos() {
return resources(AWSChaos.class, AWSChaosList.class);
}

@Override
public boolean isSupported() {
return hasApiGroup("chaos-mesh.org", false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<DefaultIstioClient>
implements NamespacedIstioClient, SupportTestingClient {
implements NamespacedIstioClient {

public DefaultIstioClient() {
super();
Expand Down Expand Up @@ -57,9 +56,4 @@ public V1alpha3APIGroupDSL v1alpha3() {
public V1beta1APIGroupDSL v1beta1() {
return adapt(V1beta1APIGroupClient.class);
}

@Override
public boolean isSupported() {
return hasApiGroup("istio.io", false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<DefaultKnativeClient>
implements NamespacedKnativeClient, SupportTestingClient {
implements NamespacedKnativeClient {

public DefaultKnativeClient() {
super();
Expand Down Expand Up @@ -238,9 +237,4 @@ public MixedOperation<KafkaSource, KafkaSourceList, Resource<KafkaSource>> kafka
public MixedOperation<KafkaBinding, KafkaBindingList, Resource<KafkaBinding>> kafkaBindings() {
return resources(KafkaBinding.class, KafkaBindingList.class);
}

@Override
public boolean isSupported() {
return hasApiGroup("knative.dev", false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -31,7 +30,7 @@
import io.fabric8.openclustermanagement.client.dsl.OpenClusterManagementSearchAPIGroupDSL;

public class DefaultOpenClusterManagementClient extends ExtensionRootClientAdapter<DefaultOpenClusterManagementClient>
implements NamespacedOpenClusterManagementClient, SupportTestingClient {
implements NamespacedOpenClusterManagementClient {

public DefaultOpenClusterManagementClient() {
super();
Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<DefaultTektonClient>
implements NamespacedTektonClient, SupportTestingClient {
implements NamespacedTektonClient {

public DefaultTektonClient() {
super();
Expand Down Expand Up @@ -66,9 +65,4 @@ public V1alpha1APIGroupDSL v1alpha1() {
return adapt(V1alpha1APIGroupClient.class);
}

@Override
public boolean isSupported() {
return hasApiGroup("tekton.dev", false);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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<DefaultVerticalPodAutoscalerClient>
implements NamespacedVerticalPodAutoscalerClient, SupportTestingClient {
implements NamespacedVerticalPodAutoscalerClient {

public DefaultVerticalPodAutoscalerClient() {
super();
Expand Down Expand Up @@ -54,9 +53,4 @@ public V1APIGroupDSL v1() {
return adapt(V1APIGroupClient.class);
}

@Override
public boolean isSupported() {
return getClient().hasApiGroup(VerticalPodAutoscalerExtensionAdapter.API_GROUP, false);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,14 @@
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;
import io.fabric8.volcano.api.model.scheduling.v1beta1.QueueList;
import io.fabric8.volcano.client.dsl.V1beta1APIGroupDSL;

public class DefaultVolcanoClient extends ExtensionRootClientAdapter<DefaultVolcanoClient>
implements NamespacedVolcanoClient, SupportTestingClient {
implements NamespacedVolcanoClient {

public DefaultVolcanoClient() {
super();
Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -32,7 +31,7 @@
import io.fabric8.volumesnapshot.api.model.VolumeSnapshotList;

public class DefaultVolumeSnapshotClient extends ExtensionRootClientAdapter<DefaultVolumeSnapshotClient>
implements NamespacedVolumeSnapshotClient, SupportTestingClient {
implements NamespacedVolumeSnapshotClient {

public DefaultVolumeSnapshotClient() {
super();
Expand Down Expand Up @@ -70,9 +69,4 @@ public MixedOperation<VolumeSnapshot, VolumeSnapshotList, VolumeSnapshotResource
public FunctionCallable<NamespacedVolumeSnapshotClient> withRequestConfig(RequestConfig requestConfig) {
return new WithRequestCallable<>(this, requestConfig);
}

@Override
public boolean isSupported() {
return getClient().hasApiGroup(VolumeSnapshotExtensionAdapter.API_GROUP, false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 <C> The target client type.
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -219,12 +218,7 @@ public boolean hasApiGroup(String apiGroup, boolean exact) {

@Override
public <C extends Client> Boolean isAdaptable(Class<C> 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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,11 +512,6 @@ public NonNamespaceOperation<UserOAuthAccessToken, UserOAuthAccessTokenList, Res
return getClient().userOAuthAccessTokens();
}

@Override
public boolean isSupported() {
return getClient().isSupported();
}

@Override
public NamespacedOpenShiftClientAdapter newInstance() {
// subclasses need not further refine this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import io.fabric8.kubernetes.client.dsl.Resource;
import io.fabric8.kubernetes.client.dsl.SchedulingAPIGroupDSL;
import io.fabric8.kubernetes.client.dsl.StorageAPIGroupDSL;
import io.fabric8.kubernetes.client.extension.SupportTestingClient;
import io.fabric8.openshift.api.model.BrokerTemplateInstance;
import io.fabric8.openshift.api.model.BrokerTemplateInstanceList;
import io.fabric8.openshift.api.model.Build;
Expand Down Expand Up @@ -147,9 +146,9 @@

import java.net.URL;

public interface OpenShiftClient extends KubernetesClient, SupportTestingClient {
public interface OpenShiftClient extends KubernetesClient {

public static final String BASE_API_GROUP = "openshift.io";
String BASE_API_GROUP = "openshift.io";

/**
* Get Url of the cluster
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@
import io.fabric8.openshift.client.internal.OpenShiftOAuthInterceptor;

import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.text.ParseException;
import java.util.List;
Expand Down Expand Up @@ -696,28 +695,4 @@ public NamespacedOpenShiftClient inAnyNamespace() {
return super.inAnyNamespace().adapt(NamespacedOpenShiftClient.class);
}

/**
* Checks if a custom URL for OpenShift has been used.
*
* @param config The openshift configuration.
* @return True if both master and openshift url have the same root.
*/
static boolean hasCustomOpenShiftUrl(OpenShiftConfig config) {
try {
URI masterUri = new URI(config.getMasterUrl()).resolve("/");
URI openshfitUri = new URI(config.getOpenShiftUrl()).resolve("/");
return !masterUri.equals(openshfitUri);
} catch (Exception e) {
throw KubernetesClientException.launderThrowable(e);
}
}

@Override
public boolean isSupported() {
OpenShiftConfig oConfig = getConfiguration();
return hasCustomOpenShiftUrl(oConfig)
|| oConfig.isDisableApiGroupCheck()
|| hasApiGroup(BASE_API_GROUP, false);
}

}
Loading

0 comments on commit 3380ae5

Please sign in to comment.