use of org.eclipse.jkube.kit.build.service.docker.access.DockerAccessException in project jkube by eclipse.
the class DockerAccessWithHcClient method startContainer.
@Override
public void startContainer(String containerId) throws DockerAccessException {
try {
String url = urlBuilder.startContainer(containerId);
delegate.post(url, HTTP_NO_CONTENT, HTTP_OK);
} catch (IOException e) {
throw new DockerAccessException(e, "Unable to start container id [%s]", containerId);
}
}
use of org.eclipse.jkube.kit.build.service.docker.access.DockerAccessException in project jkube by eclipse.
the class DockerAccessWithHcClient method removeContainer.
@Override
public void removeContainer(String containerId, boolean removeVolumes) throws DockerAccessException {
try {
String url = urlBuilder.removeContainer(containerId, removeVolumes);
delegate.delete(url, HTTP_NO_CONTENT);
} catch (IOException e) {
throw new DockerAccessException(e, "Unable to remove container [%s]", containerId);
}
}
use of org.eclipse.jkube.kit.build.service.docker.access.DockerAccessException in project jkube by eclipse.
the class DockerAccessWithHcClient method pushImage.
@Override
public void pushImage(String image, AuthConfig authConfig, String registry, int retries) throws DockerAccessException {
ImageName name = new ImageName(image);
String pushUrl = urlBuilder.pushImage(name, registry);
TemporaryImageHandler temporaryImageHandler = tagTemporaryImage(name, registry);
DockerAccessException dae = null;
try {
doPushImage(pushUrl, createAuthHeader(authConfig), createPullOrPushResponseHandler(), HTTP_OK, retries);
} catch (IOException e) {
dae = new DockerAccessException(e, "Unable to push '%s'%s", image, (registry != null) ? " to registry '" + registry + "'" : "");
throw dae;
} finally {
temporaryImageHandler.handle(dae);
}
}
use of org.eclipse.jkube.kit.build.service.docker.access.DockerAccessException in project jkube by eclipse.
the class DockerAccessWithHcClient method createNetwork.
@Override
public String createNetwork(NetworkCreateConfig networkConfig) throws DockerAccessException {
String createJson = networkConfig.toJson();
log.debug("Network create config: " + createJson);
try {
String url = urlBuilder.createNetwork();
String response = delegate.post(url, createJson, new ApacheHttpClientDelegate.BodyResponseHandler(), HTTP_CREATED);
log.debug(response);
JsonObject json = JsonFactory.newJsonObject(response);
if (json.has("Warnings")) {
logWarnings(json);
}
// only need first 12 to id a container
return json.get("Id").getAsString().substring(0, 12);
} catch (IOException e) {
throw new DockerAccessException(e, "Unable to create network for [%s]", networkConfig.getName());
}
}
use of org.eclipse.jkube.kit.build.service.docker.access.DockerAccessException in project jkube by eclipse.
the class DockerAccessWithHcClient method removeImage.
@Override
public boolean removeImage(String image, boolean... forceOpt) throws DockerAccessException {
boolean force = forceOpt != null && forceOpt.length > 0 && forceOpt[0];
try {
String url = urlBuilder.deleteImage(image, force);
ApacheHttpClientDelegate.HttpBodyAndStatus response = delegate.delete(url, new ApacheHttpClientDelegate.BodyAndStatusResponseHandler(), HTTP_OK, HTTP_NOT_FOUND);
if (log.isDebugEnabled()) {
logRemoveResponse(JsonFactory.newJsonArray(response.getBody()));
}
return response.getStatusCode() == HTTP_OK;
} catch (IOException e) {
throw new DockerAccessException(e, "Unable to remove image [%s]", image);
}
}
Aggregations