Search in sources :

Example 1 with VersionInfo

use of io.fabric8.kubernetes.client.VersionInfo in project jbosstools-openshift by jbosstools.

the class ClusterHelper method getClusterInfo.

public static ClusterInfo getClusterInfo(KubernetesClient client) throws KubernetesClientException {
    if (client instanceof OpenShiftClient || client.isAdaptable(OpenShiftClient.class)) {
        VersionInfo oClientVersionInfo;
        VersionInfo kClientVersionInfo;
        if (client instanceof OpenShiftClient) {
            oClientVersionInfo = ((OpenShiftClient) client).getVersion();
            kClientVersionInfo = new DefaultKubernetesClient(client.getConfiguration()).getVersion();
        } else {
            oClientVersionInfo = client.adapt(OpenShiftClient.class).getVersion();
            kClientVersionInfo = client.getVersion();
        }
        return new ClusterInfo(kClientVersionInfo != null ? kClientVersionInfo.getGitVersion() : "", true, oClientVersionInfo != null && oClientVersionInfo.getMajor() != null ? assemble(oClientVersionInfo.getMajor(), oClientVersionInfo.getMinor()) : "");
    }
    VersionInfo kClientVersionInfo = client.getVersion();
    return new ClusterInfo(kClientVersionInfo != null ? kClientVersionInfo.getGitVersion() : "", false, "");
}
Also used : VersionInfo(io.fabric8.kubernetes.client.VersionInfo) OpenShiftClient(io.fabric8.openshift.client.OpenShiftClient) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient)

Aggregations

DefaultKubernetesClient (io.fabric8.kubernetes.client.DefaultKubernetesClient)1 VersionInfo (io.fabric8.kubernetes.client.VersionInfo)1 OpenShiftClient (io.fabric8.openshift.client.OpenShiftClient)1