use of io.fabric8.maven.docker.access.DockerAccessException in project docker-maven-plugin by fabric8io.
the class BuildJsonResponseHandler method process.
@Override
public void process(JSONObject json) throws DockerAccessException {
if (json.has("error")) {
String msg = json.getString("error");
String detailMsg = "";
if (json.has("errorDetail")) {
JSONObject details = json.getJSONObject("errorDetail");
detailMsg = details.getString("message");
}
throw new DockerAccessException("%s %s", json.get("error"), (msg.equals(detailMsg) || "".equals(detailMsg) ? "" : "(" + detailMsg + ")"));
} else if (json.has("stream")) {
String message = json.getString("stream");
log.verbose("%s", message.trim());
} else if (json.has("status")) {
String status = json.getString("status").trim();
String id = json.has("id") ? json.getString("id") : null;
if (status.matches("^.*(Download|Pulling).*")) {
log.info(" %s%s", id != null ? id + " " : "", status);
}
}
}
use of io.fabric8.maven.docker.access.DockerAccessException in project fabric8-maven-plugin by fabric8io.
the class DockerImageWatcher method buildImage.
protected void buildImage(ImageConfiguration imageConfig) throws DockerAccessException, MojoExecutionException {
String imageName = imageConfig.getName();
// lets regenerate the label
try {
String imagePrefix = getImagePrefix(imageName);
imageName = imagePrefix + "%t";
ImageNameFormatter formatter = new ImageNameFormatter(getContext().getProject(), new Date());
imageName = formatter.format(imageName);
imageConfig.setName(imageName);
log.info("New image name: " + imageConfig.getName());
} catch (Exception e) {
log.error("Caught: " + e, e);
}
}
use of io.fabric8.maven.docker.access.DockerAccessException in project docker-maven-plugin by fabric8io.
the class ExitCodeCheckerTest method checkReturnsFalseIfContainerDoesNotExist.
@Test
public void checkReturnsFalseIfContainerDoesNotExist() throws Exception {
new Expectations() {
{
Exception e = new DockerAccessException("Cannot find container %s", CONTAINER_ID);
queryService.getMandatoryContainer(CONTAINER_ID);
result = e;
}
};
ExitCodeChecker checker = new ExitCodeChecker(0, queryService, CONTAINER_ID);
assertThat(checker.check()).isFalse();
}
use of io.fabric8.maven.docker.access.DockerAccessException in project docker-maven-plugin by fabric8io.
the class LogRequestor method parseResponse.
private void parseResponse(HttpResponse response) throws LogCallback.DoneException, IOException {
final StatusLine status = response.getStatusLine();
if (status.getStatusCode() != 200) {
exception = new DockerAccessException("Error while reading logs (" + status + ")");
throw new LogCallback.DoneException();
}
final InputStream is = response.getEntity().getContent();
try {
while (true) {
if (!readStreamFrame(is)) {
return;
}
}
} finally {
if ((is != null) && (is.available() > 0)) {
is.close();
}
}
}
use of io.fabric8.maven.docker.access.DockerAccessException in project docker-maven-plugin by fabric8io.
the class BuildService method autoPullBaseImage.
private void autoPullBaseImage(ImageConfiguration imageConfig, ImagePullManager imagePullManager, BuildContext buildContext) throws DockerAccessException, MojoExecutionException {
BuildImageConfiguration buildConfig = imageConfig.getBuildConfiguration();
if (buildConfig.getDockerArchive() != null) {
// No auto pull needed in archive mode
return;
}
String fromImage;
if (buildConfig.isDockerFileMode()) {
fromImage = extractBaseFromDockerfile(buildConfig, buildContext);
} else {
fromImage = extractBaseFromConfiguration(buildConfig);
}
if (fromImage != null && !DockerAssemblyManager.SCRATCH_IMAGE.equals(fromImage)) {
registryService.pullImageWithPolicy(fromImage, imagePullManager, buildContext.getRegistryConfig(), queryService.hasImage(fromImage));
}
}
Aggregations