use of io.fabric8.maven.docker.config.ArchiveCompression in project docker-maven-plugin by fabric8io.
the class SaveMojo method executeInternal.
@Override
protected void executeInternal(ServiceHub serviceHub) throws DockerAccessException, MojoExecutionException {
List<ImageConfiguration> images = getResolvedImages();
if (skipSaveFor(images)) {
return;
}
ImageConfiguration image = getImageToSave(images);
String imageName = image.getName();
String fileName = getFileName(imageName);
ensureSaveDir(fileName);
log.info("Saving image %s to %s", imageName, fileName);
if (!serviceHub.getQueryService().hasImage(imageName)) {
throw new MojoExecutionException("No image " + imageName + " exists");
}
long time = System.currentTimeMillis();
ArchiveCompression compression = ArchiveCompression.fromFileName(fileName);
serviceHub.getDockerAccess().saveImage(imageName, fileName, compression);
log.info("%s: Saved image to %s in %s", imageName, fileName, EnvUtil.formatDurationTill(time));
String classifier = getClassifier(image);
if (classifier != null) {
projectHelper.attachArtifact(project, compression.getFileSuffix(), classifier, new File(fileName));
}
}
use of io.fabric8.maven.docker.config.ArchiveCompression in project docker-maven-plugin by fabric8io.
the class ArchiveCompressionTest method fromFileName.
@Test
public void fromFileName() throws Exception {
ArchiveCompression c = ArchiveCompression.fromFileName("test.tar");
assertEquals("tar", c.getFileSuffix());
c = ArchiveCompression.fromFileName("test.tar.bzip2");
assertEquals("tar.bz", c.getFileSuffix());
c = ArchiveCompression.fromFileName("test.tar.bz2");
assertEquals("tar.bz", c.getFileSuffix());
c = ArchiveCompression.fromFileName("test.tar.gz");
assertEquals("tar.gz", c.getFileSuffix());
c = ArchiveCompression.fromFileName("test.tgz");
assertEquals("tar.gz", c.getFileSuffix());
}
use of io.fabric8.maven.docker.config.ArchiveCompression in project docker-maven-plugin by fabric8io.
the class DockerAccessWithHcClient method saveImage.
@Override
public void saveImage(String image, String filename, ArchiveCompression compression) throws DockerAccessException {
ImageName name = new ImageName(image);
String url = urlBuilder.getImage(name);
try {
delegate.get(url, getImageResponseHandler(filename, compression), HTTP_OK);
} catch (IOException e) {
throw new DockerAccessException(e, "Unable to save '%s' to '%s'", image, filename);
}
}
Aggregations