io.fabric8.kubernetes.client.BaseClient Java Examples

The following examples show how to use io.fabric8.kubernetes.client.BaseClient. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OpenshiftAdapterSupport.java    From kubernetes-client with Apache License 2.0 6 votes vote down vote up
/**
 * Check if OpenShift API Groups are available
 * @param client   The client.
 * @return         True if the new <code>/apis/*.openshift.io/</code> APIs are found in the root paths.
 */
static boolean isOpenShiftAPIGroups(Client client) {
  URL masterUrl = client.getMasterUrl();

  OkHttpClient httpClient = ((BaseClient)client).getHttpClient();
  try {
    Request.Builder requestBuilder = new Request.Builder()
      .get()
      .url(URLUtils.join(masterUrl.toString(), APIS));
    Response response = httpClient.newCall(requestBuilder.build()).execute();
    APIGroupList apiGroupList = Serialization.unmarshal(response.body().string(), APIGroupList.class);

    for (APIGroup apiGroup : apiGroupList.getGroups()) {
      if (apiGroup.getName().endsWith("openshift.io")) {
        return true;
      }
    }
  } catch(Exception e) {
    KubernetesClientException.launderThrowable(e);
  }
  return false;
}
 
Example #2
Source File: KogitoKubeConfig.java    From kogito-runtimes with Apache License 2.0 4 votes vote down vote up
public OkHttpClient getHttpClient() {
    return ((BaseClient) this.kubernetesClient).getHttpClient();
}
 
Example #3
Source File: WithKubernetesClient.java    From dekorate with Apache License 2.0 4 votes vote down vote up
default void closeKubernetesClient(ExtensionContext context) {
  Object client = context.getStore(Dekorate_STORE).remove(KUBERNETES_CLIENT);
  if (client instanceof KubernetesClient) {
    ((BaseClient) client).close();
  }
}