use of org.jboss.tools.openshift.internal.ui.wizard.common.EnvironmentVariable in project jbosstools-openshift by jbosstools.
the class DeployImageWizardModel method initEnvVariables.
private void initEnvVariables() {
List<EnvironmentVariable> envVars = Collections.emptyList();
if (imageMeta != null && !CollectionUtils.isEmpty(imageMeta.env())) {
envVars = imageMeta.env().stream().filter(env -> env != null && env.indexOf('=') != -1).map(env -> env.split("=")).map(splittedEnv -> new EnvironmentVariable(splittedEnv[0], splittedEnv.length > 1 ? splittedEnv[1] : StringUtils.EMPTY)).collect(Collectors.toList());
}
setEnvironmentVariables(envVars);
}
use of org.jboss.tools.openshift.internal.ui.wizard.common.EnvironmentVariable in project jbosstools-openshift by jbosstools.
the class DeployImageWizardModelTest method shouldInitializeContainerInfoWithEmtyEnvironmentVariable.
@Test
public void shouldInitializeContainerInfoWithEmtyEnvironmentVariable() {
final IDockerImageInfo dockerImageInfo = Mockito.mock(IDockerImageInfo.class, Mockito.RETURNS_DEEP_STUBS);
when(dockerConnection.hasImage(WILDFLY_IMAGE, LATEST_TAG)).thenReturn(true);
when(dockerConnection.getImageInfo(WILDFLY_IMAGE_URI)).thenReturn(dockerImageInfo);
when(dockerImageInfo.config().env()).thenReturn(Arrays.asList("V1=value1", "V2="));
when(dockerImageInfo.config().exposedPorts()).thenReturn(Collections.emptySet());
when(dockerImageInfo.config().volumes()).thenReturn(Collections.emptySet());
when(dockerImageInfo.containerConfig()).thenReturn(null);
mockSingleImage(dockerConnection, WILDFLY_IMAGE, LATEST_TAG);
// when
model.setImageName(WILDFLY_IMAGE_URI);
final boolean result = model.initializeContainerInfo();
// then
assertThat(result).isTrue();
assertThat(model.getEnvironmentVariables()).hasSize(2);
assertThat(model.getEnvironmentVariables()).isEqualTo(Arrays.asList(new EnvironmentVariable("V1", "value1"), new EnvironmentVariable("V2", "")));
}
Aggregations