use of com.openshift.restclient.model.IReplicationController in project jbosstools-openshift by jbosstools.
the class ServerResourceViewModelWithReplicationControllerTest method shouldReturnNewServiceItemsIfLoadResourcesWithConnection.
@Test
public void shouldReturnNewServiceItemsIfLoadResourcesWithConnection() {
// given
List<ObservableTreeItem> resourceItems = new ArrayList<>(model.getResourceItems());
Connection connection = ResourceMocks.createConnection("http://localhost:8080", "dev@42.org");
IProject project = ResourceMocks.createResource(IProject.class, ResourceKind.PROJECT);
when(connection.getResources(ResourceKind.PROJECT)).thenReturn(Collections.singletonList(project));
IReplicationController replicationController = ResourceMocks.createResource(IReplicationController.class, ResourceKind.REPLICATION_CONTROLLER);
when(project.getResources(ResourceKind.REPLICATION_CONTROLLER)).thenReturn(Collections.singletonList(replicationController));
// when
model.loadResources(connection);
// then
List<ObservableTreeItem> newResourceItems = model.getResourceItems();
assertThat(newResourceItems).isNotEqualTo(resourceItems);
}
use of com.openshift.restclient.model.IReplicationController in project jbosstools-openshift by jbosstools.
the class NewPodDetectorJob method getOldPods.
private Collection<String> getOldPods(IReplicationController rc) {
Connection connection = ConnectionsRegistryUtil.getConnectionFor(rc);
List<IPod> allPods = connection.getResources(ResourceKind.POD, rc.getNamespaceName());
return ResourceUtils.getPodsFor(rc, allPods).stream().filter(pod -> ResourceUtils.isRuntimePod(pod)).map(p -> p.getName()).collect(Collectors.toList());
}
use of com.openshift.restclient.model.IReplicationController in project jbosstools-openshift by jbosstools.
the class ServerAdapterHandler method getOpenShiftServer.
/**
* Finds the OpenShift server corresponding to the selection or prompts the
* user to create one.
*
* @param resource
* the selected OpenShift {@link IResource}
*
* @return the matching OpenShift {@link IServer} or <code>null</code> if
* none was found or user cancelled the creation operation.
*/
private IServer getOpenShiftServer(final IResource resource) {
if (resource == null) {
return null;
}
IResource source = null;
IRoute route = null;
if (resource instanceof IService) {
source = (IService) resource;
} else if (resource instanceof IRoute) {
route = (IRoute) resource;
final IRoute localRoute = route;
source = (IService) route.getProject().getResources(ResourceKind.SERVICE).stream().filter(s -> ResourceUtils.areRelated(localRoute, (IService) s)).findFirst().orElseGet(() -> null);
} else if (resource instanceof IReplicationController) {
source = resource;
} else if (resource instanceof IPod) {
final Collection<IService> services = ResourceUtils.getServicesFor((IPod) resource, resource.getProject().getResources(ResourceKind.SERVICE));
if (!services.isEmpty()) {
source = services.iterator().next();
} else {
source = ResourceUtils.getDeploymentConfigOrReplicationControllerFor((IPod) resource);
}
}
if (source != null) {
final Connection connection = ConnectionsRegistryUtil.safeGetConnectionFor(source);
return openOrCreateServerAdapter(source, route, connection);
}
return null;
}
use of com.openshift.restclient.model.IReplicationController in project jbosstools-openshift by jbosstools.
the class EditResourceLimitsHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IResource resource = UIUtils.getFirstElement(UIUtils.getCurrentSelection(event), IResource.class);
RetrieveDCOrRCJob job = new RetrieveDCOrRCJob(resource);
new JobChainBuilder(job).runWhenSuccessfullyDone(new UIJob("Launching Edit Resource Limits Wizard...") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
IReplicationController dcOrRc = job.getDeplConfigOrReplController();
if (dcOrRc == null) {
return Status.CANCEL_STATUS;
}
editResources(HandlerUtil.getActiveShell(event), dcOrRc, dcOrRc.getName());
return Status.OK_STATUS;
}
}).schedule();
return null;
}
use of com.openshift.restclient.model.IReplicationController in project jbosstools-openshift by jbosstools.
the class ManageEnvironmentVariablesWizard method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IReplicationController rc = findReplicationController(event);
if (rc != null) {
ManageEnvironmentVariablesWizard wizard = new ManageEnvironmentVariablesWizard(rc);
WizardUtils.openWizardDialog(wizard, HandlerUtil.getActiveShell(event));
}
return null;
}
Aggregations