Skip to content

Commit

Permalink
fix fabric8io#4014: refactoring to remove the openshift client jar
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Dec 22, 2022
1 parent 98f17e4 commit b7fa898
Show file tree
Hide file tree
Showing 27 changed files with 527 additions and 607 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -16,6 +16,7 @@
* Fix #4574: fromServer has been deprecated - it no longer needs to be called. All get() operations will fetch the resource(s) from the api server. If you need the context item that was passed in from a resource, load, or resourceList methods, use the item or items method.
* Fix #4633: client.run().withRunConfig was deprecated. Use withNewRunConfig instead.
* Fix #4663: Config.maxConcurrentRequests and Config.maxConcurrentRequestsPerHost will no longer be used. Instead they will default to unlimited for all clients. Due to the ability of the fabric8 client to start long running requests (either websocket or regular http) and how this is treated by the underlying clients you can easily exhaust these values and enter a state where the client is unresponsive without any additional information on what is occurring.
* Fix #4014: Support for Openshift 3.9 and 3.10 have been dropped because the RoleBinding logic no longer supports setting both the subjects and groups and the usernames and groupnames. You may still use a newer client against legacy versions if you take responsibility for setting the usernames and groupnames fields on your own.

### 6.3.1 (2022-12-15)

Expand Down
Expand Up @@ -24,6 +24,7 @@
import io.fabric8.kubernetes.api.model.KubernetesResourceList;
import io.fabric8.kubernetes.api.model.RootPaths;
import io.fabric8.kubernetes.client.dsl.MixedOperation;
import io.fabric8.kubernetes.client.dsl.NamespacedInOutCreateable;
import io.fabric8.kubernetes.client.dsl.Resource;
import io.fabric8.kubernetes.client.http.HttpClient;

Expand Down Expand Up @@ -142,6 +143,19 @@ public interface Client extends Closeable {
<T extends HasMetadata, L extends KubernetesResourceList<T>, R extends Resource<T>> MixedOperation<T, L, R> resources(
Class<T> resourceType, Class<L> listClass, Class<R> resourceClass);

/**
* Typed API for managing create only resources.
*
* @param <I>
* @param <O>
* @param inType
* @param outType
* @return
*/
<I extends KubernetesResource, O extends KubernetesResource> NamespacedInOutCreateable<I, O> createOnlyResources(
Class<I> inType,
Class<O> outType);

/**
* Typed API for managing resources. Any properly annotated POJO can be utilized as a resource.
*
Expand Down
Expand Up @@ -17,6 +17,9 @@
package io.fabric8.kubernetes.client;

import io.fabric8.kubernetes.api.model.Service;
import io.fabric8.kubernetes.api.model.ServicePort;

import java.util.Objects;

public interface ServiceToURLProvider {
enum ServiceToUrlImplPriority {
Expand All @@ -40,4 +43,17 @@ public int getValue() {
int getPriority();

String getURL(Service service, String portName, String namespace, KubernetesClient client);

static ServicePort getServicePortByName(Service service, String portName) {
if (portName.isEmpty()) {
return service.getSpec().getPorts().iterator().next();
}

for (ServicePort servicePort : service.getSpec().getPorts()) {
if (Objects.equals(servicePort.getName(), portName)) {
return servicePort;
}
}
return null;
}
}
Expand Up @@ -16,5 +16,5 @@

package io.fabric8.kubernetes.client.dsl;

public interface NamespacedInOutCreateable<I, O> extends Namespaceable<InOutCreateable<I, O>> {
public interface NamespacedInOutCreateable<I, O> extends Namespaceable<InOutCreateable<I, O>>, InOutCreateable<I, O> {
}
Expand Up @@ -28,6 +28,7 @@
import io.fabric8.kubernetes.client.NamespacedKubernetesClient;
import io.fabric8.kubernetes.client.RequestConfig;
import io.fabric8.kubernetes.client.dsl.MixedOperation;
import io.fabric8.kubernetes.client.dsl.NamespacedInOutCreateable;
import io.fabric8.kubernetes.client.dsl.Resource;
import io.fabric8.kubernetes.client.http.HttpClient;

Expand Down Expand Up @@ -129,6 +130,12 @@ public <T extends HasMetadata, L extends KubernetesResourceList<T>, R extends Re
return client.resources(resourceType, listClass, resourceClass);
}

@Override
public <I extends KubernetesResource, O extends KubernetesResource> NamespacedInOutCreateable<I, O> createOnlyResources(
Class<I> inType, Class<O> outType) {
return client.createOnlyResources(inType, outType);
}

public C inAnyNamespace() {
C result = newInstance();
result.init(client.adapt(NamespacedKubernetesClient.class).inAnyNamespace());
Expand Down

0 comments on commit b7fa898

Please sign in to comment.