@Override public <C> Boolean isAdaptable(Class<C> type) { return delegate.isAdaptable(type); }
@Override public <C> Boolean isAdaptable(Class<C> type) { return delegate.isAdaptable(type); }
public static boolean isOpenShift(KubernetesClient client) { return client.isAdaptable(OpenShiftClient.class); }
@Test public void testAdaptToHttpClient() { KubernetesClient client = new DefaultKubernetesClient(); Assert.assertTrue(client.isAdaptable(OkHttpClient.class)); Assert.assertNotNull(client.adapt(OkHttpClient.class)); } }
public WorkaroundRbacOperator(Vertx vertx, KubernetesClient client, String group, String apiVersion, String plural) { this.vertx = vertx; baseUrl = client.getMasterUrl().toString(); if (client.isAdaptable(OkHttpClient.class)) { this.client = client.adapt(OkHttpClient.class); } else { throw new RuntimeException("Could not adapt the client to OkHttpClient"); } this.group = group; this.apiVersion = apiVersion; this.plural = plural; }
static Future<Boolean> isOnOpenShift(Vertx vertx, KubernetesClient client) { if (client.isAdaptable(OkHttpClient.class)) { OkHttpClient ok = client.adapt(OkHttpClient.class); Future<Boolean> fut = Future.future(); vertx.executeBlocking(request -> { try (Response resp = ok.newCall(new Request.Builder().get().url(client.getMasterUrl().toString() + "oapi").build()).execute()) { if (resp.code() == 200) { log.debug("{} returned {}. We are on OpenShift.", resp.request().url(), resp.code()); // We should be on OpenShift based on the /oapi result. We can now safely try isAdaptable() to be 100% sure. Boolean isOpenShift = Boolean.TRUE.equals(client.isAdaptable(OpenShiftClient.class)); request.complete(isOpenShift); } else { log.debug("{} returned {}. We are not on OpenShift.", resp.request().url(), resp.code()); request.complete(Boolean.FALSE); } } catch (IOException e) { log.error("OpenShift detection failed", e); request.fail(e); } }, fut.completer()); return fut; } else { log.error("Cannot adapt KubernetesClient to OkHttpClient"); return Future.failedFuture("Cannot adapt KubernetesClient to OkHttpClient"); } }
/** * Returns true if this cluster is a traditional OpenShift cluster with the <code>/oapi</code> REST API * or supports the new <code>/apis/image.openshift.io</code> API Group */ public boolean isOpenShiftImageStream(Logger log) { if (isOpenShift(log)) { OpenShiftClient openShiftClient = null; if (this.client == null) { openShiftClient = createOpenShiftClient(); } else if (this.client instanceof OpenShiftClient) { openShiftClient = (OpenShiftClient) this.client; } else if (this.client.isAdaptable(OpenShiftClient.class)) { openShiftClient = client.adapt(OpenShiftClient.class); } else { return false; } return openShiftClient.supportsOpenShiftAPIGroup(OpenShiftAPIGroups.IMAGE); } return false; }
private List<HasMetadata> loadImageStreams() throws IOException, InterruptedException { if (kubernetes.isAdaptable(OpenShiftClient.class)) { FilePath child = workspace.child("target"); if (child.exists() && child.isDirectory()) { List<FilePath> paths = child.list(); if (paths != null) { for (FilePath path : paths) { String name = path.getName(); if (path.exists() && !path.isDirectory() && name.endsWith("-is.yml")) { try (InputStream is = path.read()) { listener.getLogger().println("Loading OpenShift ImageStreams file: " + name); KubernetesResource dto = KubernetesHelper.loadYaml(is, KubernetesResource.class); return KubernetesHelper.toItemList(dto); } } } } } } return Collections.emptyList(); }
private List<HasMetadata> loadImageStreams() throws IOException, InterruptedException { if (kubernetes.isAdaptable(OpenShiftClient.class)) { FilePath child = workspace.child("target"); if (child.exists() && child.isDirectory()) { List<FilePath> paths = child.list(); if (paths != null) { for (FilePath path : paths) { String name = path.getName(); if (path.exists() && !path.isDirectory() && name.endsWith("-is.yml")) { try (InputStream is = path.read()) { listener.getLogger().println("Loading OpenShift ImageStreams file: " + name); KubernetesResource dto = KubernetesHelper.loadYaml(is, KubernetesResource.class); return KubernetesHelper.toItemList(dto); } } } } } } return Collections.emptyList(); }
if (client.isAdaptable(OpenShiftClient.class)){ addClient(client.adapt(OpenShiftClient.class).buildConfigs().watch(new WatcherSupport<BuildConfig>() { @Override
boolean isOpenshift = client.isAdaptable(OpenShiftClient.class); String namespace = session.getNamespace(); String routeDomain = null;
return; if (client.isAdaptable(OpenShiftClient.class)){ OpenShiftClient oClient = client.adapt(OpenShiftClient.class); List<DeploymentConfig> deploymentConfigs = oClient.deploymentConfigs().inNamespace(session.getNamespace()).list().getItems();