use of io.fabric8.maven.docker.access.hc.ApacheHttpClientDelegate.HttpBodyAndStatus in project docker-maven-plugin by fabric8io.
the class DockerAccessWithHcClient method getImageId.
@Override
public String getImageId(String name) throws DockerAccessException {
HttpBodyAndStatus response = inspectImage(name);
if (response.getStatusCode() == HTTP_NOT_FOUND) {
return null;
}
JSONObject imageDetails = new JSONObject(response.getBody());
return imageDetails.getString("Id").substring(0, 12);
}
use of io.fabric8.maven.docker.access.hc.ApacheHttpClientDelegate.HttpBodyAndStatus in project docker-maven-plugin by fabric8io.
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);
HttpBodyAndStatus response = delegate.delete(url, new BodyAndStatusResponseHandler(), HTTP_OK, HTTP_NOT_FOUND);
if (log.isDebugEnabled()) {
logRemoveResponse(new JSONArray(response.getBody()));
}
return response.getStatusCode() == HTTP_OK;
} catch (IOException e) {
throw new DockerAccessException(e, "Unable to remove image [%s]", image);
}
}
Aggregations