Search in sources :

Example 21 with DockerAccessException

use of org.eclipse.jkube.kit.build.service.docker.access.DockerAccessException in project jkube by eclipse.

the class DockerAccessWithHcClient method removeNetwork.

@Override
public boolean removeNetwork(String networkId) throws DockerAccessException {
    try {
        String url = urlBuilder.removeNetwork(networkId);
        int status = delegate.delete(url, HTTP_OK, HTTP_NO_CONTENT, HTTP_NOT_FOUND);
        return status == HTTP_OK || status == HTTP_NO_CONTENT;
    } catch (IOException e) {
        throw new DockerAccessException(e, "Unable to remove network [%s]", networkId);
    }
}
Also used : DockerAccessException(org.eclipse.jkube.kit.build.service.docker.access.DockerAccessException) IOException(java.io.IOException)

Example 22 with DockerAccessException

use of org.eclipse.jkube.kit.build.service.docker.access.DockerAccessException in project jkube by eclipse.

the class DockerAccessWithHcClient method tag.

@Override
public void tag(String sourceImage, String targetImage, boolean force) throws DockerAccessException {
    ImageName source = new ImageName(sourceImage);
    ImageName target = new ImageName(targetImage);
    try {
        String url = urlBuilder.tagContainer(source, target, force);
        delegate.post(url, HTTP_CREATED);
    } catch (IOException e) {
        throw new DockerAccessException(e, "Unable to add tag [%s] to image [%s]", targetImage, sourceImage, e);
    }
}
Also used : ImageName(org.eclipse.jkube.kit.config.image.ImageName) DockerAccessException(org.eclipse.jkube.kit.build.service.docker.access.DockerAccessException) IOException(java.io.IOException)

Example 23 with DockerAccessException

use of org.eclipse.jkube.kit.build.service.docker.access.DockerAccessException in project jkube by eclipse.

the class DockerAccessWithHcClient method stopContainer.

@Override
public void stopContainer(String containerId, int killWait) throws DockerAccessException {
    try {
        String url = urlBuilder.stopContainer(containerId, killWait);
        delegate.post(url, HTTP_NO_CONTENT, HTTP_NOT_MODIFIED);
    } catch (IOException e) {
        throw new DockerAccessException(e, "Unable to stop container id [%s]", containerId);
    }
}
Also used : DockerAccessException(org.eclipse.jkube.kit.build.service.docker.access.DockerAccessException) IOException(java.io.IOException)

Example 24 with DockerAccessException

use of org.eclipse.jkube.kit.build.service.docker.access.DockerAccessException in project jkube by eclipse.

the class DockerAccessWithHcClient method getServerApiVersion.

/**
 * {@inheritDoc}
 */
@Override
public String getServerApiVersion() throws DockerAccessException {
    try {
        String url = urlBuilder.version();
        String response = delegate.get(url, 200);
        JsonObject info = JsonFactory.newJsonObject(response);
        return info.get("ApiVersion").getAsString();
    } catch (Exception e) {
        throw new DockerAccessException(e, "Cannot extract API version from server %s", urlBuilder.getBaseUrl());
    }
}
Also used : DockerAccessException(org.eclipse.jkube.kit.build.service.docker.access.DockerAccessException) JsonObject(com.google.gson.JsonObject) DockerAccessException(org.eclipse.jkube.kit.build.service.docker.access.DockerAccessException) HttpResponseException(org.apache.http.client.HttpResponseException) IOException(java.io.IOException)

Example 25 with DockerAccessException

use of org.eclipse.jkube.kit.build.service.docker.access.DockerAccessException in project jkube by eclipse.

the class DockerAccessWithHcClient method copyArchive.

@Override
public void copyArchive(String containerId, File archive, String targetPath) throws DockerAccessException {
    try {
        String url = urlBuilder.copyArchive(containerId, targetPath);
        delegate.put(url, archive, HTTP_OK);
    } catch (IOException e) {
        throw new DockerAccessException(e, "Unable to copy archive %s to container [%s] with path %s", archive.toPath(), containerId, targetPath);
    }
}
Also used : DockerAccessException(org.eclipse.jkube.kit.build.service.docker.access.DockerAccessException) IOException(java.io.IOException)

Aggregations

DockerAccessException (org.eclipse.jkube.kit.build.service.docker.access.DockerAccessException)28 IOException (java.io.IOException)21 JsonObject (com.google.gson.JsonObject)8 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)3 ImageName (org.eclipse.jkube.kit.config.image.ImageName)3 JsonArray (com.google.gson.JsonArray)2 File (java.io.File)2 HttpResponseException (org.apache.http.client.HttpResponseException)2 Container (org.eclipse.jkube.kit.build.api.model.Container)2 Map (java.util.Map)1 ContainerDetails (org.eclipse.jkube.kit.build.api.model.ContainerDetails)1 ContainersListElement (org.eclipse.jkube.kit.build.api.model.ContainersListElement)1 Network (org.eclipse.jkube.kit.build.api.model.Network)1 NetworksListElement (org.eclipse.jkube.kit.build.api.model.NetworksListElement)1 BuildOptions (org.eclipse.jkube.kit.build.service.docker.access.BuildOptions)1 CreateImageOptions (org.eclipse.jkube.kit.build.service.docker.access.CreateImageOptions)1 ExitCodeChecker (org.eclipse.jkube.kit.build.service.docker.wait.ExitCodeChecker)1 HealthCheckChecker (org.eclipse.jkube.kit.build.service.docker.wait.HealthCheckChecker)1 LogWaitChecker (org.eclipse.jkube.kit.build.service.docker.wait.LogWaitChecker)1