Search in sources :

Example 1 with VersionInfo

use of io.kubernetes.client.models.VersionInfo in project java by kubernetes-client.

the class VersionApi method getCodeAsync.

/**
 *  (asynchronously)
 * get the code version
 * @param callback The callback to be executed when the API call finishes
 * @return The request call
 * @throws ApiException If fail to process the API call, e.g. serializing the request body object
 */
public com.squareup.okhttp.Call getCodeAsync(final ApiCallback<VersionInfo> callback) throws ApiException {
    ProgressResponseBody.ProgressListener progressListener = null;
    ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
    if (callback != null) {
        progressListener = new ProgressResponseBody.ProgressListener() {

            @Override
            public void update(long bytesRead, long contentLength, boolean done) {
                callback.onDownloadProgress(bytesRead, contentLength, done);
            }
        };
        progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {

            @Override
            public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
                callback.onUploadProgress(bytesWritten, contentLength, done);
            }
        };
    }
    com.squareup.okhttp.Call call = getCodeValidateBeforeCall(progressListener, progressRequestListener);
    Type localVarReturnType = new TypeToken<VersionInfo>() {
    }.getType();
    apiClient.executeAsync(call, localVarReturnType, callback);
    return call;
}
Also used : ProgressResponseBody(io.kubernetes.client.ProgressResponseBody) VersionInfo(io.kubernetes.client.models.VersionInfo) Type(java.lang.reflect.Type) ProgressRequestBody(io.kubernetes.client.ProgressRequestBody)

Example 2 with VersionInfo

use of io.kubernetes.client.models.VersionInfo in project weblogic-kubernetes-operator by oracle.

the class HealthCheckHelper method performK8sVersionCheck.

/**
 * Verify the k8s version.
 *
 * @return Major and minor version information
 * @throws ApiException exception for k8s API
 */
public KubernetesVersion performK8sVersionCheck() throws ApiException {
    // k8s version must be 1.7.5 or greater
    LOGGER.info(MessageKeys.VERIFY_K8S_MIN_VERSION);
    boolean k8sMinVersion = true;
    VersionInfo info = null;
    int major = 0;
    int minor = 0;
    try {
        CallBuilderFactory factory = ContainerResolver.getInstance().getContainer().getSPI(CallBuilderFactory.class);
        info = factory.create().readVersionCode();
        String gitVersion = info.getGitVersion();
        major = Integer.parseInt(info.getMajor());
        if (major < 1) {
            k8sMinVersion = false;
        } else if (major == 1) {
            // The Minor version can be also 8+
            String minor_string = info.getMinor();
            // If not it will remove the last part of the string in order to have just a number
            while (!minor_string.chars().allMatch(Character::isDigit)) {
                minor_string = minor_string.substring(0, minor_string.length() - 1);
            }
            minor = Integer.parseInt(minor_string);
            if (minor < 7) {
                k8sMinVersion = false;
            } else if (minor == 7) {
                // git version is of the form v1.7.5
                // Check the 3rd part of the version.
                String[] splitVersion = gitVersion.split("\\.");
                // issue-36: gitVersion can be not just "v1.7.9" but also values like "v1.7.9+coreos.0"
                splitVersion = splitVersion[2].split("\\+");
                if (Integer.parseInt(splitVersion[0]) < 5) {
                    k8sMinVersion = false;
                }
            }
        }
        // Minimum k8s version not satisfied.
        if (!k8sMinVersion) {
            logHealthCheckEvent(MessageKeys.K8S_MIN_VERSION_CHECK_FAILED, MINIMUM_K8S_VERSION, gitVersion);
        } else {
            LOGGER.info(MessageKeys.K8S_VERSION_CHECK, gitVersion);
        }
    } catch (ApiException ae) {
        LOGGER.warning(MessageKeys.K8S_VERSION_CHECK_FAILURE, ae);
    }
    return new KubernetesVersion(major, minor);
}
Also used : VersionInfo(io.kubernetes.client.models.VersionInfo) ApiException(io.kubernetes.client.ApiException)

Example 3 with VersionInfo

use of io.kubernetes.client.models.VersionInfo in project weblogic-kubernetes-operator by oracle.

the class SecretHelperTest method setUp.

@Before
public void setUp() throws Exception {
    CallBuilderFactory factory = new CallBuilderFactory(null);
    // Determine if 1.8 since some bugs with kubernetes-client / java and secrets
    VersionInfo verInfo = factory.create().readVersionCode();
    if ("1".equals(verInfo.getMajor()) && "8".equals(verInfo.getMinor())) {
        isVersion18 = true;
    }
    createNamespace(UNIT_NAMESPACE);
    createSecret(SECRET_NAME, UNIT_NAMESPACE);
    createInvalidSecret(INVALID_SECRET_NAME, UNIT_NAMESPACE);
    createSecret(SECRET_NAME, "default");
    defaultSecretHelper = new SecretHelper("default");
    unitSecretHelper = new SecretHelper(UNIT_NAMESPACE);
}
Also used : VersionInfo(io.kubernetes.client.models.VersionInfo) SecretHelper(oracle.kubernetes.operator.helpers.SecretHelper) CallBuilderFactory(oracle.kubernetes.operator.helpers.CallBuilderFactory) Before(org.junit.Before)

Example 4 with VersionInfo

use of io.kubernetes.client.models.VersionInfo in project java by kubernetes-client.

the class VersionApi method getCodeWithHttpInfo.

/**
 * get the code version
 * @return ApiResponse&lt;VersionInfo&gt;
 * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
 */
public ApiResponse<VersionInfo> getCodeWithHttpInfo() throws ApiException {
    com.squareup.okhttp.Call call = getCodeValidateBeforeCall(null, null);
    Type localVarReturnType = new TypeToken<VersionInfo>() {
    }.getType();
    return apiClient.execute(call, localVarReturnType);
}
Also used : VersionInfo(io.kubernetes.client.models.VersionInfo) Type(java.lang.reflect.Type)

Aggregations

VersionInfo (io.kubernetes.client.models.VersionInfo)4 Type (java.lang.reflect.Type)2 ApiException (io.kubernetes.client.ApiException)1 ProgressRequestBody (io.kubernetes.client.ProgressRequestBody)1 ProgressResponseBody (io.kubernetes.client.ProgressResponseBody)1 CallBuilderFactory (oracle.kubernetes.operator.helpers.CallBuilderFactory)1 SecretHelper (oracle.kubernetes.operator.helpers.SecretHelper)1 Before (org.junit.Before)1