use of org.eclipse.che.api.environment.server.model.CheServiceBuildContextImpl in project che by eclipse.
the class CheEnvironmentEngine method machineConfigToService.
private CheServiceImpl machineConfigToService(MachineConfig machineConfig) throws ServerException {
CheServiceImpl service = new CheServiceImpl();
service.setMemLimit(machineConfig.getLimits().getRam() * 1024L * 1024L);
service.setEnvironment(machineConfig.getEnvVariables());
if ("image".equals(machineConfig.getSource().getType())) {
service.setImage(machineConfig.getSource().getLocation());
} else {
if (machineConfig.getSource().getContent() != null) {
throw new ServerException("Additional machine creation from dockerfile content is not supported anymore. " + "Please use dockerfile location instead");
} else {
service.setBuild(new CheServiceBuildContextImpl(machineConfig.getSource().getLocation(), null, null, null));
}
}
List<? extends ServerConf> servers = machineConfig.getServers();
if (servers != null) {
List<String> expose = new ArrayList<>();
for (ServerConf server : servers) {
expose.add(server.getPort());
}
service.setExpose(expose);
}
return service;
}
use of org.eclipse.che.api.environment.server.model.CheServiceBuildContextImpl in project che by eclipse.
the class CheEnvironmentEngine method normalizeServiceSource.
private CheServiceImpl normalizeServiceSource(CheServiceImpl service, MachineSource machineSource) throws ServerException {
CheServiceImpl serviceWithNormalizedSource = service;
if (machineSource != null) {
serviceWithNormalizedSource = new CheServiceImpl(service);
if ("image".equals(machineSource.getType())) {
serviceWithNormalizedSource.setBuild(null);
serviceWithNormalizedSource.setImage(machineSource.getLocation());
} else {
// dockerfile
serviceWithNormalizedSource.setImage(null);
if (machineSource.getContent() != null) {
serviceWithNormalizedSource.setBuild(new CheServiceBuildContextImpl(null, null, machineSource.getContent(), null));
} else {
serviceWithNormalizedSource.setBuild(new CheServiceBuildContextImpl(machineSource.getLocation(), null, null, null));
}
}
}
return serviceWithNormalizedSource;
}
use of org.eclipse.che.api.environment.server.model.CheServiceBuildContextImpl in project che by eclipse.
the class CheEnvironmentValidatorTest method createServicesEnv.
private static CheServicesEnvironmentImpl createServicesEnv() {
CheServicesEnvironmentImpl cheServicesEnvironment = new CheServicesEnvironmentImpl();
Map<String, CheServiceImpl> services = new HashMap<>();
Map<String, String> buildArgs = new HashMap<String, String>() {
{
put("argkey", "argvalue");
}
};
cheServicesEnvironment.setServices(services);
services.put("dev-machine", createCheService("_dev", 1024L * 1024L * 1024L, singletonList("machine2"), singletonList("machine2"), singletonList("machine2")));
CheServiceImpl service = createCheService("_machine2", 100L, null, emptyList(), null);
service.setBuild(new CheServiceBuildContextImpl("context", "file", null, buildArgs));
services.put("machine2", service);
return cheServicesEnvironment;
}
use of org.eclipse.che.api.environment.server.model.CheServiceBuildContextImpl in project che by eclipse.
the class EnvironmentParserTest method createExpectedEnv.
private static CheServicesEnvironmentImpl createExpectedEnv(String image, String dockerfile, List<String> expectedExpose, Map<String, String> expectedLabels) {
CheServiceBuildContextImpl build = dockerfile != null ? new CheServiceBuildContextImpl(null, null, dockerfile, null) : null;
CheServicesEnvironmentImpl environment = new CheServicesEnvironmentImpl();
environment.getServices().put(DEFAULT_MACHINE_NAME, new CheServiceImpl().withImage(image).withLabels(expectedLabels).withBuild(build).withExpose(expectedExpose));
return environment;
}
use of org.eclipse.che.api.environment.server.model.CheServiceBuildContextImpl in project che by eclipse.
the class CheEnvironmentEngineTest method shouldNotSetDockerfileContentInsteadOfUrlIfUrlDoesNotPointToCheApiOnEnvironmentStart.
@Test
public void shouldNotSetDockerfileContentInsteadOfUrlIfUrlDoesNotPointToCheApiOnEnvironmentStart() throws Exception {
// given
EnvironmentImpl env = createEnv();
String machineName = "machineWithDockerfileNotFromApi";
String contextUrl = "http://another-server.com/recipe/12345";
//prepare CheServicesEnvironmentImpl which should return compose parser
CheServicesEnvironmentImpl cheServicesEnvironment = createCheServicesEnvByName(machineName);
cheServicesEnvironment.getServices().get(machineName).withBuild(new CheServiceBuildContextImpl().withContext(contextUrl));
// when
startEnv(env, cheServicesEnvironment);
// then
ArgumentCaptor<CheServiceImpl> captor = ArgumentCaptor.forClass(CheServiceImpl.class);
verify(machineProvider).startService(anyString(), anyString(), anyString(), eq(machineName), eq(false), anyString(), captor.capture(), any(LineConsumer.class));
CheServiceImpl actualService = captor.getValue();
assertNull(actualService.getBuild().getDockerfilePath());
assertNull(actualService.getBuild().getDockerfileContent());
assertEquals(actualService.getBuild().getContext(), contextUrl);
}
Aggregations