Search in sources :

Example 6 with EnvironmentVariable

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);
}
Also used : Arrays(java.util.Arrays) StringUtils(org.apache.commons.lang.StringUtils) IDockerConnectionManagerListener(org.eclipse.linuxtools.docker.core.IDockerConnectionManagerListener) IDockerImage(org.eclipse.linuxtools.docker.core.IDockerImage) DockerImageUtils(org.jboss.tools.openshift.internal.core.docker.DockerImageUtils) IDockerImageMetadata(org.jboss.tools.openshift.internal.core.docker.IDockerImageMetadata) IProject(com.openshift.restclient.model.IProject) ArrayList(java.util.ArrayList) EnvironmentVariablesPageModel(org.jboss.tools.openshift.internal.ui.wizard.common.EnvironmentVariablesPageModel) CollectionUtils(org.apache.commons.collections.CollectionUtils) DockerConfigMetaData(org.jboss.tools.openshift.internal.core.docker.DockerConfigMetaData) Map(java.util.Map) IDockerImageInfo(org.eclipse.linuxtools.docker.core.IDockerImageInfo) ResourceLabelsPageModel(org.jboss.tools.openshift.internal.ui.wizard.common.ResourceLabelsPageModel) PropertyChangeEvent(java.beans.PropertyChangeEvent) LinkedHashSet(java.util.LinkedHashSet) DockerImageURI(com.openshift.restclient.images.DockerImageURI) PortSpecAdapter(org.jboss.tools.openshift.internal.core.models.PortSpecAdapter) ResourceKind(com.openshift.restclient.ResourceKind) Collection(java.util.Collection) DockerConnectionManager(org.eclipse.linuxtools.docker.core.DockerConnectionManager) Set(java.util.Set) Collectors(java.util.stream.Collectors) ObjectUtils(org.apache.commons.lang.ObjectUtils) Connection(org.jboss.tools.openshift.core.connection.Connection) IPort(com.openshift.restclient.model.IPort) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) List(java.util.List) ICommonAttributes(org.jboss.tools.openshift.core.ICommonAttributes) PropertyChangeListener(java.beans.PropertyChangeListener) IServicePort(com.openshift.restclient.model.IServicePort) ConnectionsRegistrySingleton(org.jboss.tools.openshift.common.core.connection.ConnectionsRegistrySingleton) Comparator(java.util.Comparator) Collections(java.util.Collections) EnvironmentVariable(org.jboss.tools.openshift.internal.ui.wizard.common.EnvironmentVariable) EnvironmentVariable(org.jboss.tools.openshift.internal.ui.wizard.common.EnvironmentVariable)

Example 7 with EnvironmentVariable

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", "")));
}
Also used : EnvironmentVariable(org.jboss.tools.openshift.internal.ui.wizard.common.EnvironmentVariable) IDockerImageInfo(org.eclipse.linuxtools.docker.core.IDockerImageInfo) Test(org.junit.Test)

Aggregations

EnvironmentVariable (org.jboss.tools.openshift.internal.ui.wizard.common.EnvironmentVariable)7 Test (org.junit.Test)5 IDockerImageInfo (org.eclipse.linuxtools.docker.core.IDockerImageInfo)4 DockerImageURI (com.openshift.restclient.images.DockerImageURI)3 PortSpecAdapter (org.jboss.tools.openshift.internal.core.models.PortSpecAdapter)3 IImageStreamImportCapability (com.openshift.restclient.capability.resources.IImageStreamImportCapability)2 IStatus (com.openshift.restclient.model.IStatus)2 IImageStreamImport (com.openshift.restclient.model.image.IImageStreamImport)2 List (java.util.List)2 Connection (org.jboss.tools.openshift.core.connection.Connection)2 ResourceKind (com.openshift.restclient.ResourceKind)1 IPort (com.openshift.restclient.model.IPort)1 IProject (com.openshift.restclient.model.IProject)1 IServicePort (com.openshift.restclient.model.IServicePort)1 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1