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);
}
}
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);
}
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);
}
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);
}
Aggregations