use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.
the class ConfigHelperTest method initImageConfiguration_withSimpleDockerFileModeEnabledAndImageConfigurationWithNoBuild_shouldModifyExistingImageConfiguration.
@Test
public void initImageConfiguration_withSimpleDockerFileModeEnabledAndImageConfigurationWithNoBuild_shouldModifyExistingImageConfiguration() {
ImageConfiguration dummyImageConfiguration = ImageConfiguration.builder().name("imageconfiguration-no-build:latest").build();
List<ImageConfiguration> images = new ArrayList<>();
images.add(dummyImageConfiguration);
File dockerFile = new File(getClass().getResource("/dummy-javaproject/Dockerfile").getFile());
when(imageConfigResolver.resolve(dummyImageConfiguration, javaProject)).thenReturn(images);
when(jKubeConfiguration.getBasedir()).thenReturn(dockerFile.getParentFile());
when(javaProject.getProperties()).thenReturn(new Properties());
// When
List<ImageConfiguration> resolvedImages = ConfigHelper.initImageConfiguration("1.12", new Date(), images, imageConfigResolver, logger, null, configs -> configs, jKubeConfiguration);
// Then
assertThat(resolvedImages).isNotNull().hasSize(1).element(0).hasFieldOrPropertyWithValue("name", "imageconfiguration-no-build:latest").hasFieldOrPropertyWithValue("build.dockerFile", dockerFile).hasFieldOrPropertyWithValue("build.ports", Collections.singletonList("8080"));
}
use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.
the class WatchServiceTest method testCopyFilesToContainer.
@Test
public void testCopyFilesToContainer() throws Exception {
// Given
AtomicBoolean fileCopied = new AtomicBoolean(false);
WatchContext watchContext = WatchContext.builder().watchMode(WatchMode.copy).containerCopyTask(f -> fileCopied.compareAndSet(false, true)).build();
File fileToCopy = Files.createTempFile("test-changed-files", "tar").toFile();
WatchService.ImageWatcher imageWatcher = new WatchService.ImageWatcher(imageConfiguration, watchContext, "test-img", "efe1234");
WatchService watchService = new WatchService(archiveService, buildService, queryService, runService, logger);
// When
watchService.copyFilesToContainer(fileToCopy, imageWatcher);
// Then
assertTrue(fileCopied.get());
}
use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.
the class WatchServiceTest method testCallPostExec.
@Test
public void testCallPostExec() throws Exception {
// Given
AtomicBoolean postExecCommandExecuted = new AtomicBoolean(false);
WatchContext watchContext = WatchContext.builder().watchMode(WatchMode.copy).containerCommandExecutor(imageWatcher -> {
postExecCommandExecuted.set(true);
return "Some Output";
}).build();
WatchService.ImageWatcher imageWatcher = new WatchService.ImageWatcher(imageConfiguration, watchContext, "test-img", "efe1234");
WatchService watchService = new WatchService(archiveService, buildService, queryService, runService, logger);
// When
watchService.callPostExec(imageWatcher);
// Then
assertTrue(postExecCommandExecuted.get());
}
use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.
the class StartOrderResolver method resolve.
// Check images for volume / link dependencies and return it in the right order.
// Only return images which should be run
// Images references via volumes but with no run configuration are started once to create
// an appropriate container which can be linked into the image
private List<ImageConfiguration> resolve(List<ImageConfiguration> images) {
List<ImageConfiguration> resolved = new ArrayList<>();
// First pass: Pick all data images and all without dependencies
for (ImageConfiguration config : images) {
List<String> volumesOrLinks = extractDependentImagesFor(config);
if (volumesOrLinks == null) {
// A data image only or no dependency. Add it to the list of data image which can be always
// created first.
updateProcessedImages(config);
resolved.add(config);
} else {
secondPass.add(config);
}
}
// Next passes: Those with dependencies are checked whether they already have been visited.
return secondPass.isEmpty() ? resolved : resolveRemaining(resolved);
}
use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.
the class StartOrderResolver method remainingImagesDescription.
private String remainingImagesDescription() {
StringBuilder ret = new StringBuilder();
ret.append("Unresolved images:\n");
for (ImageConfiguration config : secondPass) {
ret.append("* ").append(config.getAlias()).append(" depends on ").append(String.join(",", config.getDependencies().toArray(new String[0]))).append("\n");
}
return ret.toString();
}
Aggregations