use of org.eclipse.jkube.kit.build.api.assembly.AssemblyFiles in project jkube by eclipse.
the class WatchService method createCopyWatchTask.
private Runnable createCopyWatchTask(final ImageWatcher watcher, final JKubeConfiguration jKubeConfiguration) throws IOException {
final ImageConfiguration imageConfig = watcher.getImageConfiguration();
final AssemblyFiles files = archiveService.getAssemblyFiles(imageConfig, jKubeConfiguration);
return () -> {
List<AssemblyFileEntry> entries = files.getUpdatedEntriesAndRefresh();
if (!entries.isEmpty()) {
try {
log.info("%s: Assembly changed. Copying changed files to container...", imageConfig.getDescription());
File changedFilesArchive = archiveService.createChangedFilesArchive(entries, files.getAssemblyDirectory(), imageConfig.getName(), jKubeConfiguration);
copyFilesToContainer(changedFilesArchive, watcher);
callPostExec(watcher);
} catch (IOException | WatchException e) {
log.error("%s: Error when copying files to container %s: %s", imageConfig.getDescription(), watcher.getContainerId(), e.getMessage());
}
}
};
}
use of org.eclipse.jkube.kit.build.api.assembly.AssemblyFiles in project jkube by eclipse.
the class WatchService method createBuildWatchTask.
Runnable createBuildWatchTask(final ImageWatcher watcher, final JKubeConfiguration mojoParameters, final boolean doRestart, final JKubeConfiguration buildContext) throws IOException {
final ImageConfiguration imageConfig = watcher.getImageConfiguration();
final AssemblyFiles files = archiveService.getAssemblyFiles(imageConfig, mojoParameters);
if (files.isEmpty()) {
log.error("No assembly files for %s. Are you sure you invoked together with the `package` goal?", imageConfig.getDescription());
throw new IOException("No files to watch found for " + imageConfig);
}
return () -> {
List<AssemblyFileEntry> entries = files.getUpdatedEntriesAndRefresh();
if (entries != null && !entries.isEmpty()) {
try {
log.info("%s: Assembly changed. Rebuild ...", imageConfig.getDescription());
if (watcher.getWatchContext().getImageCustomizer() != null) {
log.info("%s: Customizing the image ...", imageConfig.getDescription());
watcher.getWatchContext().getImageCustomizer().execute(imageConfig);
}
buildService.buildImage(imageConfig, null, buildContext);
String name = imageConfig.getName();
watcher.setImageId(queryService.getImageId(name));
restartContainerAndCallPostGoal(watcher, doRestart);
} catch (Exception e) {
log.error("%s: Error when rebuilding - %s", imageConfig.getDescription(), e);
}
}
};
}
Aggregations