Search in sources :

Example 6 with CheServiceBuildContextImpl

use of org.eclipse.che.api.environment.server.model.CheServiceBuildContextImpl in project che by eclipse.

the class CheEnvironmentEngineTest method createCheServicesEnvByName.

private CheServicesEnvironmentImpl createCheServicesEnvByName(String name) {
    CheServicesEnvironmentImpl cheServicesEnvironment = new CheServicesEnvironmentImpl();
    Map<String, CheServiceImpl> services = new HashMap<>();
    services.put(name, new CheServiceImpl().withBuild(new CheServiceBuildContextImpl().withContext("image")));
    cheServicesEnvironment.setServices(services);
    return cheServicesEnvironment;
}
Also used : CheServiceBuildContextImpl(org.eclipse.che.api.environment.server.model.CheServiceBuildContextImpl) HashMap(java.util.HashMap) CheServiceImpl(org.eclipse.che.api.environment.server.model.CheServiceImpl) CheServicesEnvironmentImpl(org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl) Matchers.anyString(org.mockito.Matchers.anyString)

Example 7 with CheServiceBuildContextImpl

use of org.eclipse.che.api.environment.server.model.CheServiceBuildContextImpl in project che by eclipse.

the class CheEnvironmentEngineTest method createCheServicesEnv.

private CheServicesEnvironmentImpl createCheServicesEnv() {
    CheServicesEnvironmentImpl cheServicesEnvironment = new CheServicesEnvironmentImpl();
    Map<String, CheServiceImpl> services = new HashMap<>();
    services.put("dev-machine", new CheServiceImpl().withBuild(new CheServiceBuildContextImpl().withContext("image")));
    services.put("machine2", new CheServiceImpl().withBuild(new CheServiceBuildContextImpl().withContext("image")));
    cheServicesEnvironment.setServices(services);
    return cheServicesEnvironment;
}
Also used : CheServiceBuildContextImpl(org.eclipse.che.api.environment.server.model.CheServiceBuildContextImpl) HashMap(java.util.HashMap) CheServiceImpl(org.eclipse.che.api.environment.server.model.CheServiceImpl) CheServicesEnvironmentImpl(org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl) Matchers.anyString(org.mockito.Matchers.anyString)

Example 8 with CheServiceBuildContextImpl

use of org.eclipse.che.api.environment.server.model.CheServiceBuildContextImpl in project che by eclipse.

the class EnvironmentParserTest method getEntryForDockerfileEnv.

private static List<Object> getEntryForDockerfileEnv(Map<String, ServerConf2Impl> servers, List<String> expectedExpose, Map<String, String> expectedLabels) {
    EnvironmentImpl environmentConfig = createDockerfileEnvConfig();
    ExtendedMachineImpl extendedMachine = getMachine(environmentConfig);
    extendedMachine.setServers(servers);
    CheServicesEnvironmentImpl parsedCheEnv = new CheServicesEnvironmentImpl();
    CheServiceBuildContextImpl buildContext = new CheServiceBuildContextImpl().withDockerfileContent(DEFAULT_DOCKERFILE);
    parsedCheEnv.getServices().put(DEFAULT_MACHINE_NAME, new CheServiceImpl().withBuild(buildContext));
    return asList(environmentConfig, createExpectedEnvFromDockerfile(expectedExpose, expectedLabels), parsedCheEnv);
}
Also used : CheServiceBuildContextImpl(org.eclipse.che.api.environment.server.model.CheServiceBuildContextImpl) CheServiceImpl(org.eclipse.che.api.environment.server.model.CheServiceImpl) ExtendedMachineImpl(org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl) CheServicesEnvironmentImpl(org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl) EnvironmentImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl) CheServicesEnvironmentImpl(org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl)

Example 9 with CheServiceBuildContextImpl

use of org.eclipse.che.api.environment.server.model.CheServiceBuildContextImpl in project che by eclipse.

the class DockerfileEnvironmentParserTest method shouldBeAbleToParseDockerfileEnvironmentFromLocation.

@Test
public void shouldBeAbleToParseDockerfileEnvironmentFromLocation() throws Exception {
    // given
    String recipeLocation = "http://localhost:8080/recipe/url";
    EnvironmentImpl environment = createDockerfileEnvConfig(null, recipeLocation, DEFAULT_MACHINE_NAME);
    CheServicesEnvironmentImpl expected = new CheServicesEnvironmentImpl();
    expected.getServices().put(DEFAULT_MACHINE_NAME, new CheServiceImpl().withBuild(new CheServiceBuildContextImpl().withContext(recipeLocation)));
    // when
    CheServicesEnvironmentImpl cheServicesEnvironment = parser.parse(environment);
    // then
    Assert.assertEquals(cheServicesEnvironment, expected);
}
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) EnvironmentImpl(org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl) CheServicesEnvironmentImpl(org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl) Test(org.testng.annotations.Test)

Example 10 with CheServiceBuildContextImpl

use of org.eclipse.che.api.environment.server.model.CheServiceBuildContextImpl in project che by eclipse.

the class DockerfileEnvironmentParser method parse.

@Override
public CheServicesEnvironmentImpl parse(Environment environment) throws IllegalArgumentException, ServerException {
    EnvironmentRecipe recipe = environment.getRecipe();
    if (!"dockerfile".equals(recipe.getType())) {
        throw new IllegalArgumentException(format("Dockerfile environment parser doesn't support recipe type '%s'", recipe.getType()));
    }
    if (!"text/x-dockerfile".equals(recipe.getContentType())) {
        throw new IllegalArgumentException(format("Content type '%s' of recipe of environment is unsupported." + " Supported values are: text/x-dockerfile", recipe.getContentType()));
    }
    CheServicesEnvironmentImpl cheServiceEnv = new CheServicesEnvironmentImpl();
    CheServiceImpl service = new CheServiceImpl();
    cheServiceEnv.getServices().put(getMachineName(environment), service);
    if (recipe.getLocation() != null) {
        service.setBuild(new CheServiceBuildContextImpl().withContext(recipe.getLocation()));
    } else {
        service.setBuild(new CheServiceBuildContextImpl().withDockerfileContent(recipe.getContent()));
    }
    return cheServiceEnv;
}
Also used : CheServiceBuildContextImpl(org.eclipse.che.api.environment.server.model.CheServiceBuildContextImpl) CheServiceImpl(org.eclipse.che.api.environment.server.model.CheServiceImpl) EnvironmentRecipe(org.eclipse.che.api.core.model.workspace.EnvironmentRecipe) CheServicesEnvironmentImpl(org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl)

Aggregations

CheServiceBuildContextImpl (org.eclipse.che.api.environment.server.model.CheServiceBuildContextImpl)15 CheServiceImpl (org.eclipse.che.api.environment.server.model.CheServiceImpl)15 CheServicesEnvironmentImpl (org.eclipse.che.api.environment.server.model.CheServicesEnvironmentImpl)13 EnvironmentImpl (org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl)5 Test (org.testng.annotations.Test)5 HashMap (java.util.HashMap)4 Matchers.anyString (org.mockito.Matchers.anyString)4 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 ServerException (org.eclipse.che.api.core.ServerException)2 Environment (org.eclipse.che.api.core.model.workspace.Environment)2 LineConsumer (org.eclipse.che.api.core.util.LineConsumer)2 ExtendedMachineImpl (org.eclipse.che.api.workspace.server.model.impl.ExtendedMachineImpl)2 Joiner (com.google.common.base.Joiner)1 String.format (java.lang.String.format)1 Arrays.asList (java.util.Arrays.asList)1 Collections.emptyList (java.util.Collections.emptyList)1 Collections.emptyMap (java.util.Collections.emptyMap)1 Collections.singleton (java.util.Collections.singleton)1 Collections.singletonList (java.util.Collections.singletonList)1