use of org.eclipse.che.plugin.docker.compose.ComposeServiceImpl in project che by eclipse.
the class ComposeEnvironmentParser method asCheEnvironment.
private CheServicesEnvironmentImpl asCheEnvironment(ComposeEnvironment composeEnvironment) {
Map<String, CheServiceImpl> services = Maps.newHashMapWithExpectedSize(composeEnvironment.getServices().size());
for (Map.Entry<String, ComposeServiceImpl> composeServiceEntry : composeEnvironment.getServices().entrySet()) {
ComposeServiceImpl service = composeServiceEntry.getValue();
CheServiceImpl cheService = new CheServiceImpl().withCommand(service.getCommand()).withContainerName(service.getContainerName()).withDependsOn(service.getDependsOn()).withEntrypoint(service.getEntrypoint()).withEnvironment(service.getEnvironment()).withExpose(service.getExpose()).withImage(service.getImage()).withLabels(service.getLabels()).withLinks(service.getLinks()).withMemLimit(service.getMemLimit()).withNetworks(service.getNetworks()).withPorts(service.getPorts()).withVolumes(service.getVolumes()).withVolumesFrom(service.getVolumesFrom());
if (service.getBuild() != null) {
cheService.setBuild(new CheServiceBuildContextImpl().withContext(service.getBuild().getContext()).withDockerfilePath(service.getBuild().getDockerfile()).withArgs(service.getBuild().getArgs()));
}
services.put(composeServiceEntry.getKey(), cheService);
}
return new CheServicesEnvironmentImpl(services);
}
use of org.eclipse.che.plugin.docker.compose.ComposeServiceImpl in project che by eclipse.
the class CommandDeserializerTest method composeServiceCommandShouldBeParsedSuccessfully.
@Test(dataProvider = "validCommand")
public void composeServiceCommandShouldBeParsedSuccessfully(String command, List<String> commandWords, int commandNumberOfWords) throws Exception {
String content = format(RECIPE_WITHOUT_COMMAND_VALUE, command);
ComposeEnvironment composeEnvironment = composeEnvironmentParser.parse(content, "application/x-yaml");
assertEquals(composeEnvironment.getServices().size(), 1);
ComposeServiceImpl service = composeEnvironment.getServices().get("machine1");
assertEquals(service.getImage(), "codenvy/mysql");
assertEquals(service.getMemLimit().longValue(), 2147483648L);
Map<String, String> environment = service.getEnvironment();
assertEquals(environment.size(), 2);
assertEquals(environment.get("MYSQL_USER"), "petclinic");
assertEquals(environment.get("MYSQL_PASSWORD"), "password");
assertTrue(service.getExpose().containsAll(asList("4403", "5502")));
assertTrue(service.getCommand().containsAll(commandWords));
assertEquals(service.getCommand().size(), commandNumberOfWords);
}
Aggregations