Search in sources :

Example 1 with ComposeServiceImpl

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);
}
Also used : CheServiceBuildContextImpl(org.eclipse.che.api.environment.server.model.CheServiceBuildContextImpl) CheServiceImpl(org.eclipse.che.api.environment.server.model.CheServiceImpl) CheServicesEnvironmentImpl(org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl) ComposeServiceImpl(org.eclipse.che.plugin.docker.compose.ComposeServiceImpl) Map(java.util.Map)

Example 2 with ComposeServiceImpl

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);
}
Also used : ComposeEnvironment(org.eclipse.che.plugin.docker.compose.ComposeEnvironment) ComposeServiceImpl(org.eclipse.che.plugin.docker.compose.ComposeServiceImpl) Test(org.testng.annotations.Test)

Aggregations

ComposeServiceImpl (org.eclipse.che.plugin.docker.compose.ComposeServiceImpl)2 Map (java.util.Map)1 CheServiceBuildContextImpl (org.eclipse.che.api.environment.server.model.CheServiceBuildContextImpl)1 CheServiceImpl (org.eclipse.che.api.environment.server.model.CheServiceImpl)1 CheServicesEnvironmentImpl (org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl)1 ComposeEnvironment (org.eclipse.che.plugin.docker.compose.ComposeEnvironment)1 Test (org.testng.annotations.Test)1