use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.
the class DockerComposeConfigHandler method resolve.
@Override
@SuppressWarnings("unchecked")
public List<ImageConfiguration> resolve(ImageConfiguration unresolvedConfig, JavaProject project) {
List<ImageConfiguration> resolved = new ArrayList<>();
DockerComposeConfiguration handlerConfig = new DockerComposeConfiguration(unresolvedConfig.getExternalConfig());
File composeFile = resolveComposeFileAbsolutely(handlerConfig.getBasedir(), handlerConfig.getComposeFile(), (project != null && project.getBaseDirectory() != null) ? project.getBaseDirectory().getAbsolutePath() : null);
for (Object composeO : getComposeConfigurations(composeFile)) {
Map<String, Object> compose = (Map<String, Object>) composeO;
validateVersion(compose, composeFile);
Map<String, Object> services = (Map<String, Object>) compose.get("services");
for (Map.Entry<String, Object> entry : services.entrySet()) {
String serviceName = entry.getKey();
Map<String, Object> serviceDefinition = (Map<String, Object>) entry.getValue();
DockerComposeServiceWrapper mapper = new DockerComposeServiceWrapper(serviceName, composeFile, serviceDefinition, unresolvedConfig, resolveAbsolutely(handlerConfig.getBasedir(), (project != null && project.getBaseDirectory() != null) ? project.getBaseDirectory().getAbsolutePath() : null));
resolved.add(buildImageConfiguration(mapper, composeFile.getParentFile(), unresolvedConfig, handlerConfig));
}
}
return resolved;
}
use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.
the class ImageConfigurationTest method initAndValidateWithBuildAndRun.
@Test
public void initAndValidateWithBuildAndRun(@Mocked ConfigHelper.NameFormatter nameFormatter, @Mocked BuildConfiguration buildConfiguration, @Mocked RunImageConfiguration runImageConfiguration) {
// Given
final ImageConfiguration imageConfiguration = ImageConfiguration.builder().build(buildConfiguration).run(runImageConfiguration).build();
// @formatter:off
new Expectations() {
{
buildConfiguration.initAndValidate();
result = "1.337";
runImageConfiguration.initAndValidate();
result = "13.37";
}
};
// @formatter:on
// When
final String result = ConfigHelper.initAndValidate(nameFormatter, imageConfiguration);
// Then
assertThat(result, is("13.37"));
}
use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.
the class WatchServiceTest method testRestartContainerAndCallPostGoalRestartEnabled.
@Test
public void testRestartContainerAndCallPostGoalRestartEnabled() throws Exception {
// Given
AtomicBoolean restarted = new AtomicBoolean(false);
WatchContext watchContext = WatchContext.builder().watchMode(WatchMode.both).containerRestarter(// Override Restart task to set this value to true
i -> restarted.set(true)).build();
WatchService.ImageWatcher imageWatcher = new WatchService.ImageWatcher(imageConfiguration, watchContext, "test-img", "efe1234");
WatchService watchService = new WatchService(archiveService, buildService, queryService, runService, logger);
// When
watchService.restartContainerAndCallPostGoal(imageWatcher, true);
// Then
assertTrue(restarted.get());
}
use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.
the class StartOrderResolver method resolveImageDependencies.
private void resolveImageDependencies(List<ImageConfiguration> resolved) throws DockerAccessException, ResolveSteadyStateException {
boolean changed = false;
Iterator<ImageConfiguration> iterator = secondPass.iterator();
while (iterator.hasNext()) {
ImageConfiguration config = iterator.next();
if (hasRequiredDependencies(config)) {
updateProcessedImages(config);
resolved.add(config);
changed = true;
iterator.remove();
}
}
if (!changed) {
throw new ResolveSteadyStateException();
}
}
use of org.eclipse.jkube.kit.config.image.ImageConfiguration in project jkube by eclipse.
the class ImageEnricherTest method givenResourceConfigWithEnvVar.
private void givenResourceConfigWithEnvVar(String name, String value) {
// @formatter:off
new Expectations() {
{
Configuration configuration = Configuration.builder().resource(ResourceConfig.builder().env(Collections.singletonMap(name, value)).build()).image(imageConfiguration).build();
context.getConfiguration();
result = configuration;
}
};
// @formatter:on
}
Aggregations