use of io.fabric8.maven.docker.config.CopyConfiguration in project docker-maven-plugin by fabric8io.
the class PropertyConfigHandler method extractCopyConfig.
private CopyConfiguration extractCopyConfig(ImageConfiguration fromConfig, ValueProvider valueProvider) {
final CopyConfiguration config = fromConfig.getCopyConfiguration();
final List<Properties> entriesProperties = config == null ? null : config.getEntriesAsListOfProperties();
return new CopyConfiguration.Builder().entriesAsListOfProperties(valueProvider.getPropertiesList(COPY_ENTRIES, entriesProperties)).build();
}
use of io.fabric8.maven.docker.config.CopyConfiguration in project docker-maven-plugin by fabric8io.
the class CopyMojo method copy.
private void copy(DockerAccess dockerAccess, ArchiveService archiveService, String containerId, String imageName, CopyConfiguration copyConfiguration) throws IOException, MojoExecutionException {
List<CopyConfiguration.Entry> copyEntries = copyConfiguration.getEntries();
for (CopyConfiguration.Entry copyEntry : copyEntries) {
String containerPath = copyEntry.getContainerPath();
if (containerPath == null) {
log.error("containerPath of copy goal entry for %s image is not specified", imageName);
throw new IllegalArgumentException("containerPath should be specified");
}
File hostDirectory = getHostDirectory(copyEntry.getHostDirectory());
log.info("Copying %s from %s container into %s host directory", containerPath, containerId, hostDirectory.getAbsolutePath());
Files.createDirectories(hostDirectory.toPath());
try (FileRemover fileRemover = new FileRemover(log)) {
File archiveFile = Files.createTempFile(TEMP_ARCHIVE_FILE_PREFIX, TEMP_ARCHIVE_FILE_SUFFIX).toFile();
fileRemover.setFile(archiveFile);
log.debug("Created %s temporary file for docker copy archive", archiveFile);
log.debug("Copying %s from %s container into %s host file", containerPath, containerId, archiveFile);
dockerAccess.copyArchiveFromContainer(containerId, containerPath, archiveFile);
log.debug("Extracting %s archive into %s directory", archiveFile, hostDirectory);
archiveService.extractDockerCopyArchive(archiveFile, hostDirectory);
}
}
}
Aggregations