Search in sources :

Example 6 with IServicePort

use of com.openshift.restclient.model.IServicePort in project jbosstools-openshift by jbosstools.

the class DeployImageWizardModel method setServicePortsFromPorts.

private void setServicePortsFromPorts(List<IPort> portSpecs) {
    this.imagePorts = new ArrayList<>(portSpecs.size());
    List<IServicePort> servicePorts = new ArrayList<>(portSpecs.size());
    for (IPort port : portSpecs) {
        servicePorts.add(new ServicePortAdapter(port));
        imagePorts.add(new ServicePortAdapter(port));
    }
    setServicePorts(servicePorts);
}
Also used : IPort(com.openshift.restclient.model.IPort) IServicePort(com.openshift.restclient.model.IServicePort) ArrayList(java.util.ArrayList)

Example 7 with IServicePort

use of com.openshift.restclient.model.IServicePort in project jbosstools-openshift by jbosstools.

the class DeployImageWizardModelTest method checkThatRemoveANonExistingServicePortIsNotEffective.

@Test
public void checkThatRemoveANonExistingServicePortIsNotEffective() {
    // assume Docker image is on local
    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(Collections.emptyList());
    when(dockerImageInfo.config().exposedPorts()).thenReturn(new HashSet<>(Arrays.asList("8080/tcp", "9990/tcp")));
    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();
    IServicePort port = new ServicePortAdapter();
    port.setName("9000-tcp");
    port.setProtocol("TCP");
    port.setPort(9000);
    port.setTargetPort(9000);
    model.removeServicePort(port);
    assertThat(model.getServicePorts()).hasSize(2);
    ServicePortAdapter first = new ServicePortAdapter(new PortSpecAdapter("8080-tcp", "TCP", 8080));
    first.setRoutePort(true);
    assertThat(model.getServicePorts()).isEqualTo(Arrays.asList(first, new ServicePortAdapter(new PortSpecAdapter("9990-tcp", "TCP", 9990))));
}
Also used : ServicePortAdapter(org.jboss.tools.openshift.internal.ui.wizard.deployimage.ServicePortAdapter) IServicePort(com.openshift.restclient.model.IServicePort) PortSpecAdapter(org.jboss.tools.openshift.internal.core.models.PortSpecAdapter) IDockerImageInfo(org.eclipse.linuxtools.docker.core.IDockerImageInfo) Test(org.junit.Test)

Aggregations

IServicePort (com.openshift.restclient.model.IServicePort)7 MultiValidator (org.eclipse.core.databinding.validation.MultiValidator)2 IStatus (org.eclipse.core.runtime.IStatus)2 Button (org.eclipse.swt.widgets.Button)2 Composite (org.eclipse.swt.widgets.Composite)2 Label (org.eclipse.swt.widgets.Label)2 IPort (com.openshift.restclient.model.IPort)1 IRoute (com.openshift.restclient.model.route.IRoute)1 ITargetPort (com.openshift.restclient.model.route.ITargetPort)1 ArrayList (java.util.ArrayList)1 ObservableListContentProvider (org.eclipse.jface.databinding.viewers.ObservableListContentProvider)1 ObservableMapLabelProvider (org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider)1 IDockerImageInfo (org.eclipse.linuxtools.docker.core.IDockerImageInfo)1 MouseEvent (org.eclipse.swt.events.MouseEvent)1 Text (org.eclipse.swt.widgets.Text)1 TableCellMouseAdapter (org.jboss.tools.openshift.internal.common.ui.TableCellMouseAdapter)1 IsNotNull2BooleanConverter (org.jboss.tools.openshift.internal.common.ui.databinding.IsNotNull2BooleanConverter)1 TrimmingStringConverter (org.jboss.tools.openshift.internal.common.ui.databinding.TrimmingStringConverter)1 PortSpecAdapter (org.jboss.tools.openshift.internal.core.models.PortSpecAdapter)1 PodPortValidator (org.jboss.tools.openshift.internal.ui.wizard.deployimage.PodPortValidator)1