Search in sources :

Example 11 with IPod

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

the class OpenShiftExplorerContentProvider method getProjectChildren.

protected Object[] getProjectChildren(IProjectWrapper project) {
    switch(project.getState()) {
        case LOADED:
            removeStub(project);
            Collection<IResourceWrapper<?, ?>> services = project.getResourcesOfKind(ResourceKind.SERVICE);
            Collection<IReplicationControllerWrapper> dcs = project.getResourcesOfType(IReplicationControllerWrapper.class);
            services.addAll(dcs);
            Collection<IResourceWrapper<?, ?>> pods = project.getResourcesOfKind(ResourceKind.POD).stream().filter(wrapper -> ResourceUtils.isRuntimePod((IPod) wrapper.getWrapped()) && !((IPod) wrapper.getWrapped()).isAnnotatedWith(OpenShiftAPIAnnotations.DEPLOYMENT_NAME)).collect(Collectors.toList());
            services.addAll(pods);
            return services.toArray();
        case LOAD_STOPPED:
            LoadingStub stub = removeStub(project);
            if (stub != null) {
                return stub.getChildren();
            }
        default:
            project.load(e -> {
                handleLoadingException(project, e);
            });
            return new Object[] { makeStub(project) };
    }
}
Also used : IReplicationControllerWrapper(org.jboss.tools.openshift.internal.ui.models.IReplicationControllerWrapper) Arrays(java.util.Arrays) ResourceUtils(org.jboss.tools.openshift.internal.core.util.ResourceUtils) HashMap(java.util.HashMap) IConnectionWrapper(org.jboss.tools.openshift.internal.ui.models.IConnectionWrapper) StructuredViewer(org.eclipse.jface.viewers.StructuredViewer) ArrayList(java.util.ArrayList) IResourceWrapper(org.jboss.tools.openshift.internal.ui.models.IResourceWrapper) IPod(com.openshift.restclient.model.IPod) Map(java.util.Map) ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) ConnectionsRegistry(org.jboss.tools.openshift.common.core.connection.ConnectionsRegistry) Viewer(org.eclipse.jface.viewers.Viewer) ResourceKind(com.openshift.restclient.ResourceKind) Collection(java.util.Collection) IBuild(com.openshift.restclient.model.IBuild) OpenshiftUIModel(org.jboss.tools.openshift.internal.ui.models.OpenshiftUIModel) IReplicationControllerWrapper(org.jboss.tools.openshift.internal.ui.models.IReplicationControllerWrapper) Collectors(java.util.stream.Collectors) LoadingStub(org.jboss.tools.openshift.internal.common.ui.explorer.BaseExplorerContentProvider.LoadingStub) IResourceContainer(org.jboss.tools.openshift.internal.ui.models.IResourceContainer) IServiceWrapper(org.jboss.tools.openshift.internal.ui.models.IServiceWrapper) Connection(org.jboss.tools.openshift.core.connection.Connection) List(java.util.List) OpenShiftAPIAnnotations(org.jboss.tools.openshift.core.OpenShiftAPIAnnotations) IRoute(com.openshift.restclient.model.route.IRoute) BaseExplorerContentProvider(org.jboss.tools.openshift.internal.common.ui.explorer.BaseExplorerContentProvider) IProjectWrapper(org.jboss.tools.openshift.internal.ui.models.IProjectWrapper) ConnectionsRegistrySingleton(org.jboss.tools.openshift.common.core.connection.ConnectionsRegistrySingleton) IElementListener(org.jboss.tools.openshift.internal.ui.models.IElementListener) IOpenshiftUIElement(org.jboss.tools.openshift.internal.ui.models.IOpenshiftUIElement) Control(org.eclipse.swt.widgets.Control) IResourceWrapper(org.jboss.tools.openshift.internal.ui.models.IResourceWrapper) LoadingStub(org.jboss.tools.openshift.internal.common.ui.explorer.BaseExplorerContentProvider.LoadingStub) IPod(com.openshift.restclient.model.IPod)

Example 12 with IPod

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

the class ServicePodsExist method test.

@Override
public boolean test() {
    IService service = connection.getResource(ResourceKind.SERVICE, projectName, serviceName);
    if (service == null) {
        return true;
    }
    if (!hasDesiredReplicas(service)) {
        return true;
    }
    List<IPod> pods = connection.getResources(ResourceKind.POD, projectName);
    return !ResourceUtils.getPodsFor(service, pods).isEmpty();
}
Also used : IService(com.openshift.restclient.model.IService) IPod(com.openshift.restclient.model.IPod)

Example 13 with IPod

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

the class OpenShiftExplorerLabelProviderTest method getStyledTextForAPodWithLongNames.

@Test
public void getStyledTextForAPodWithLongNames() {
    provider.setLabelLimit(10);
    IPod pod = givenAResource(IPod.class, ResourceKind.POD);
    String status = "Chilling";
    when(pod.getStatus()).thenReturn(status);
    String exp = "s...e P...g";
    assertEquals(exp, provider.getStyledText(pod).getString());
    // test description
    assertEquals("someName Pod Chilling", provider.getDescription(pod));
}
Also used : StyledString(org.eclipse.jface.viewers.StyledString) IPod(com.openshift.restclient.model.IPod) Test(org.junit.Test)

Example 14 with IPod

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

the class OpenShiftExplorerLabelProviderTest method getStyledTextForAPod.

@Test
public void getStyledTextForAPod() {
    IPod pod = givenAResource(IPod.class, ResourceKind.POD);
    assertEquals(String.format("%s Pod", pod.getName()), provider.getStyledText(pod).getString());
    String status = "Chilling";
    when(pod.getStatus()).thenReturn(status);
    String exp = String.format("%s Pod %s", pod.getName(), status);
    assertEquals(exp, provider.getStyledText(pod).getString());
}
Also used : StyledString(org.eclipse.jface.viewers.StyledString) IPod(com.openshift.restclient.model.IPod) Test(org.junit.Test)

Example 15 with IPod

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

the class OpenShiftExplorerLabelProviderTest method getStyledTextForAPodWithoutLabels.

@Test
public void getStyledTextForAPodWithoutLabels() {
    IPod pod = givenAResource(IPod.class, ResourceKind.POD);
    when(pod.getIP()).thenReturn("172.17.2.226");
    Map<String, String> labels = new HashMap<>();
    when(pod.getLabels()).thenReturn(labels);
    assertEquals(String.format("%s Pod", pod.getName()), provider.getStyledText(pod).getString());
}
Also used : HashMap(java.util.HashMap) StyledString(org.eclipse.jface.viewers.StyledString) IPod(com.openshift.restclient.model.IPod) Test(org.junit.Test)

Aggregations

IPod (com.openshift.restclient.model.IPod)27 Connection (org.jboss.tools.openshift.core.connection.Connection)11 Test (org.junit.Test)9 IResource (com.openshift.restclient.model.IResource)8 ResourceKind (com.openshift.restclient.ResourceKind)6 IPortForwardable (com.openshift.restclient.capability.resources.IPortForwardable)6 PortPair (com.openshift.restclient.capability.resources.IPortForwardable.PortPair)6 IReplicationController (com.openshift.restclient.model.IReplicationController)6 HashMap (java.util.HashMap)6 IConnection (org.jboss.tools.openshift.common.core.connection.IConnection)6 CapabilityVisitor (com.openshift.restclient.capability.CapabilityVisitor)5 Collection (java.util.Collection)5 List (java.util.List)5 Map (java.util.Map)5 ResourceUtils (org.jboss.tools.openshift.internal.core.util.ResourceUtils)5 IBuild (com.openshift.restclient.model.IBuild)4 IDeploymentConfig (com.openshift.restclient.model.IDeploymentConfig)4 IService (com.openshift.restclient.model.IService)4 CoreException (org.eclipse.core.runtime.CoreException)4 ISelection (org.eclipse.jface.viewers.ISelection)4