Search in sources :

Example 6 with IPort

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

the class OpenShiftDebugMode method updateContainerDebugPort.

private void updateContainerDebugPort(IDeploymentConfig dc, DebugContext context) {
    Collection<IContainer> containers = dc.getContainers();
    if (CollectionUtils.isEmpty(containers)) {
        return;
    }
    // TODO: support multiple containers
    IContainer firstContainer = containers.iterator().next();
    IPort currentContainerPort = getCurrentContainerPort(firstContainer.getPorts());
    boolean modified = false;
    Set<IPort> ports = new HashSet<>(firstContainer.getPorts());
    if (context.isDebugEnabled()) {
        modified = addReplaceDebugPort(context.getDebugPort(), currentContainerPort, ports);
    } else {
        modified = removeDebugPort(currentContainerPort, ports);
    }
    if (modified) {
        firstContainer.setPorts(ports);
    }
}
Also used : IPort(com.openshift.restclient.model.IPort) IContainer(com.openshift.restclient.model.IContainer) HashSet(java.util.HashSet)

Example 7 with IPort

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

the class PortForwardingUtilsTest method shouldGetForwardablePortsOnStartedStopped.

@Test
public void shouldGetForwardablePortsOnStartedStopped() {
    // given
    final IPod pod = Mockito.mock(IPod.class);
    final IPort port = Mockito.mock(IPort.class);
    final IPortForwardable portForwardable = Mockito.mock(IPortForwardable.class);
    Mockito.when(pod.getContainerPorts()).thenReturn(toSet(port));
    // when
    final Set<PortPair> forwardablePorts = PortForwardingUtils.getForwardablePorts(pod);
    // then
    assertThat(forwardablePorts).isNotNull().hasSize(1);
}
Also used : IPort(com.openshift.restclient.model.IPort) IPortForwardable(com.openshift.restclient.capability.resources.IPortForwardable) PortPair(com.openshift.restclient.capability.resources.IPortForwardable.PortPair) IPod(com.openshift.restclient.model.IPod) Test(org.junit.Test)

Example 8 with IPort

use of com.openshift.restclient.model.IPort 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 9 with IPort

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

the class PortForwardingWizardModelTest method setUp.

@Before
public void setUp() throws Exception {
    when(port.getName()).thenReturn("http");
    when(port.getContainerPort()).thenReturn(3436);
    when(port.getProtocol()).thenReturn("TCP");
    when(pod.getName()).thenReturn("apodname");
    Set<IPort> ports = new HashSet<>();
    ports.add(port);
    when(pod.getNamespaceName()).thenReturn("anamespace");
    when(pod.getContainerPorts()).thenReturn(ports);
    this.model = new PortForwardingWizardModel(pod);
}
Also used : IPort(com.openshift.restclient.model.IPort) PortForwardingWizardModel(org.jboss.tools.openshift.internal.ui.portforwading.PortForwardingWizardModel) HashSet(java.util.HashSet) Before(org.junit.Before)

Aggregations

IPort (com.openshift.restclient.model.IPort)9 Test (org.junit.Test)5 IContainer (com.openshift.restclient.model.IContainer)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 PortSpecAdapter (org.jboss.tools.openshift.internal.core.models.PortSpecAdapter)3 HashSet (java.util.HashSet)2 IPortForwardable (com.openshift.restclient.capability.resources.IPortForwardable)1 PortPair (com.openshift.restclient.capability.resources.IPortForwardable.PortPair)1 IPod (com.openshift.restclient.model.IPod)1 IServicePort (com.openshift.restclient.model.IServicePort)1 ArrayList (java.util.ArrayList)1 PortForwardingWizardModel (org.jboss.tools.openshift.internal.ui.portforwading.PortForwardingWizardModel)1 Before (org.junit.Before)1