Search in sources :

Example 1 with BuildImageCmd

use of com.github.dockerjava.api.command.BuildImageCmd in project camel by apache.

the class AsyncDockerProducer method executeBuildImageRequest.

/**
     * Produces a build image request
     *
     * @param client
     * @param message
     * @return
     * @throws DockerException
     */
private BuildImageCmd executeBuildImageRequest(DockerClient client, Message message) throws DockerException {
    LOGGER.debug("Executing Docker Build Image Request");
    Object body = message.getBody();
    BuildImageCmd buildImageCmd;
    if (body != null && body instanceof InputStream) {
        buildImageCmd = client.buildImageCmd((InputStream) body);
    } else if (body != null && body instanceof File) {
        buildImageCmd = client.buildImageCmd((File) body);
    } else {
        throw new DockerException("Unable to location source Image");
    }
    Boolean noCache = DockerHelper.getProperty(DockerConstants.DOCKER_NO_CACHE, configuration, message, Boolean.class);
    if (noCache != null) {
        buildImageCmd.withNoCache(noCache);
    }
    Boolean quiet = DockerHelper.getProperty(DockerConstants.DOCKER_QUIET, configuration, message, Boolean.class);
    if (quiet != null) {
        buildImageCmd.withQuiet(quiet);
    }
    Boolean remove = DockerHelper.getProperty(DockerConstants.DOCKER_REMOVE, configuration, message, Boolean.class);
    if (remove != null) {
        buildImageCmd.withRemove(remove);
    }
    String tag = DockerHelper.getProperty(DockerConstants.DOCKER_TAG, configuration, message, String.class);
    if (tag != null) {
        buildImageCmd.withTag(tag);
    }
    return buildImageCmd;
}
Also used : DockerException(org.apache.camel.component.docker.exception.DockerException) InputStream(java.io.InputStream) BuildImageCmd(com.github.dockerjava.api.command.BuildImageCmd) File(java.io.File)

Aggregations

BuildImageCmd (com.github.dockerjava.api.command.BuildImageCmd)1 File (java.io.File)1 InputStream (java.io.InputStream)1 DockerException (org.apache.camel.component.docker.exception.DockerException)1