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;
}
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;
}
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);
}
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);
}
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;
}
Aggregations