use of org.jboss.tools.openshift.core.connection.Connection in project jbosstools-openshift by jbosstools.
the class ServerResourceViewModelWithReplicationControllerTest method shouldLoadResourcesWhenToldTo.
@Test
public void shouldLoadResourcesWhenToldTo() {
// given
Connection connection = ResourceMocks.createConnection("http://10.1.2.2:8443", "dev@paas.redhat.com");
ServerResourceViewModel model = new ServerResourceViewModel(connection);
model.loadResources();
// when
// then
verify(connection, atLeastOnce()).getResources(any());
}
use of org.jboss.tools.openshift.core.connection.Connection in project jbosstools-openshift by jbosstools.
the class ServerResourceViewModelWithServiceTest method shouldNotLoadResourcesBeforeBeingToldTo.
@Test
public void shouldNotLoadResourcesBeforeBeingToldTo() {
// given
Connection connection = ResourceMocks.createConnection("http://10.1.2.2:8443", "dev@paas.redhat.com");
new ServerResourceViewModel(connection);
// when
// then
verify(connection, never()).getResources(any());
verify(connection, never()).getResources(any(), any());
}
use of org.jboss.tools.openshift.core.connection.Connection 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 org.jboss.tools.openshift.core.connection.Connection in project jbosstools-openshift by jbosstools.
the class OpenShiftDebugMode method execute.
/**
* Sends the changes to the deployment config if required. Nothing is done if
* the deployment config already is in the state that the context is in. If the
* changes are sent the existing pods are killed and it waits until the new pods
* are running.
*
* @param context
* @param monitor
* @throws CoreException
*/
public OpenShiftDebugMode execute(IProgressMonitor monitor) throws CoreException {
Connection connection = OpenShiftServerUtils.getConnection(context.getServer());
IResource resource = OpenShiftServerUtils.getResource(context.getServer(), monitor);
IDeploymentConfig dc = getDeploymentConfig(resource, connection, monitor);
if (dc == null) {
throw new CoreException(OpenShiftCoreActivator.statusFactory().errorStatus(NLS.bind("Could not find deployment config for resource {0}. " + "Your build might be still running and pods not created yet or " + "there might be no labels on your pods pointing to the wanted deployment config.", resource != null ? resource.getName() : "")));
}
boolean dcUpdated = updateDc(dc, connection, monitor);
IPod pod = getPod(dcUpdated, dc, connection, monitor);
context.setPod(pod);
toggleRouteTimeout(resource, connection, context, monitor);
toggleDebugger(context, monitor);
return this;
}
use of org.jboss.tools.openshift.core.connection.Connection in project jbosstools-openshift by jbosstools.
the class RouteTimeout method getRoute.
private IRoute getRoute(IResource resource, Connection connection, IProgressMonitor monitor) {
SubMonitor routeMonitor = SubMonitor.convert(monitor);
routeMonitor.beginTask("Determine route to set the haproxy timeout for...", 2);
if (routeMonitor.isCanceled()) {
return null;
}
List<IService> services = connection.getResources(ResourceKind.SERVICE, resource.getNamespaceName());
Collection<IService> matchingServices = ResourceUtils.getServicesFor(resource, services);
routeMonitor.worked(1);
if (routeMonitor.isCanceled()) {
return null;
}
List<IRoute> routes = connection.getResources(ResourceKind.ROUTE, resource.getNamespaceName());
// TODO: support multiple matching routes, for now only get first
Optional<IRoute> matchingRoute = matchingServices.stream().flatMap(service -> ResourceUtils.getRoutesFor(service, routes).stream()).findFirst();
routeMonitor.worked(1);
routeMonitor.done();
return matchingRoute.orElse(null);
}
Aggregations