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);
}
}
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);
}
}
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);
}
}
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());
}
}
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);
}
}
Aggregations