com.github.dockerjava.api.model.ResponseItem Java Examples

The following examples show how to use com.github.dockerjava.api.model.ResponseItem. 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: LogUtils.java    From docker-plugin with MIT License 6 votes vote down vote up
public static void printResponseItemToListener(TaskListener listener, ResponseItem item) {

        if (item != null && item.getStatus() != null) {
            if (item.getError() != null) {
                listener.error(item.getError());
            }

            final StringBuilder stringBuffer = new StringBuilder();

            if (item.getId() != null) {
                stringBuffer.append(item.getId()).append(": "); // Doesn't exist before "Digest"
            }

            stringBuffer.append(item.getStatus());

            if (item.getProgress() != null) {
                stringBuffer.append(" ").append(item.getProgress());
            }

            listener.getLogger().println(stringBuffer.toString());
        }
    }
 
Example #2
Source File: DockerArtifactHandler.java    From module-ballerina-docker with Apache License 2.0 5 votes vote down vote up
@Override
public void onNext(BuildResponseItem item) {
    // handling error
    if (item.isErrorIndicated()) {
        StringBuilder errString = new StringBuilder("[build][error]: ");
        ResponseItem.ErrorDetail errDetail = item.getErrorDetail();
        if (null != errDetail && null != errDetail.getCode()) {
            errString.append("(").append(errDetail.getCode()).append(") ");
        }

        if (null != errDetail && null != errDetail.getMessage()) {
            errString.append(errDetail.getMessage());
        }

        String errorMessage = errString.toString();
        printDebug(errorMessage);
        dockerBuildError.setErrorMsg("unable to build docker image: " + errorMessage);
    }

    String streamLog = item.getStream();
    if (null != streamLog && !"".equals(streamLog.replaceAll("\n", ""))) {
        printDebug("[build][stream] " + streamLog.replaceAll("\n", ""));
    }

    String statusLog = item.getStatus();
    if (null != statusLog && !"".equals(statusLog.replaceAll("\n", ""))) {
        printDebug("[build][status] " + statusLog.replaceAll("\n", ""));
    }

    String imageIdLog = item.getImageId();
    if (null != imageIdLog) {
        printDebug("[build][image-id]: " + imageIdLog);
    }

    super.onNext(item);
}
 
Example #3
Source File: DockerArtifactHandler.java    From module-ballerina-docker with Apache License 2.0 5 votes vote down vote up
@Override
public void onNext(PushResponseItem item) {
    // handling error
    if (item.isErrorIndicated()) {
        StringBuilder errString = new StringBuilder("[push][error]: ");

        ResponseItem.ErrorDetail errDetail = null;
        if (null != item.getErrorDetail()) {
            errDetail = item.getErrorDetail();
        }
        if (null != errDetail && null != errDetail.getCode()) {
            errString.append("(").append(errDetail.getCode()).append(") ");
        }

        if (null != errDetail && null != errDetail.getMessage()) {
            errString.append(errDetail.getMessage());
        }

        String errorMessage = errString.toString();
        printDebug(errorMessage);
        dockerPushError.setErrorMsg("unable to push docker image: " + errorMessage);
    }

    String streamLog = item.getStream();
    if (null != streamLog && !"".equals(streamLog.replaceAll("\n", ""))) {
        printDebug("[push][stream] " + streamLog.replaceAll("\n", ""));
    }

    String statusLog = item.getStatus();
    if (null != statusLog && !"".equals(statusLog.replaceAll("\n", ""))) {
        printDebug("[push][status] " + statusLog.replaceAll("\n", ""));
    }

    String idLog = item.getId();
    if (null != idLog) {
        printDebug("[push][ID]: " + idLog);
    }

    super.onNext(item);
}