use of com.openshift.restclient.model.IDeploymentConfig in project jbosstools-openshift by jbosstools.
the class ServerResourceViewModelWithDeploymentConfigTest 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));
IDeploymentConfig deploymentConfig = ResourceMocks.createResource(IDeploymentConfig.class, ResourceKind.DEPLOYMENT_CONFIG);
when(project.getResources(ResourceKind.DEPLOYMENT_CONFIG)).thenReturn(Collections.singletonList(deploymentConfig));
// when
model.loadResources(connection);
// then
List<ObservableTreeItem> newResourceItems = model.getResourceItems();
assertThat(newResourceItems).isNotEqualTo(resourceItems);
}
use of com.openshift.restclient.model.IDeploymentConfig in project jbosstools-openshift by jbosstools.
the class ResourceMocks method createDeploymentConfig.
public static IDeploymentConfig createDeploymentConfig(String name, IProject project, List<IEnvironmentVariable> envVariables, List<IContainer> containers, Connection connection) {
IDeploymentConfig dc = createDeploymentConfig(name, project, envVariables, containers);
mockGetResources(Arrays.asList(dc), ResourceKind.DEPLOYMENT_CONFIG, project, connection);
return dc;
}
use of com.openshift.restclient.model.IDeploymentConfig 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 com.openshift.restclient.model.IDeploymentConfig in project jbosstools-openshift by jbosstools.
the class ScaleDeploymentHandler method getDeploymentConfig.
private IDeploymentConfig getDeploymentConfig(IPod pod, IResourceWrapper<?, ?> wrapper) {
IDeploymentConfig dc = null;
if (!ResourceUtils.isBuildPod(pod)) {
IServiceWrapper service = ResourceWrapperUtils.getServiceWrapperFor(wrapper, serviceWrapper -> ResourceUtils.areRelated(pod, (IService) serviceWrapper.getWrapped()));
dc = getDeploymentConfig(service);
}
return dc;
}
use of com.openshift.restclient.model.IDeploymentConfig in project jbosstools-openshift by jbosstools.
the class ScaleDeploymentHandler method getDeploymentConfig.
private IDeploymentConfig getDeploymentConfig(IReplicationController rc, IResourceWrapper<?, ?> wrapper) {
IDeploymentConfig dc = null;
IServiceWrapper service = ResourceWrapperUtils.getServiceWrapperFor(wrapper, serviceWrapper -> ResourceUtils.areRelated(rc, (IService) serviceWrapper.getWrapped()));
if (service != null) {
dc = ResourceUtils.getDeploymentConfigFor(rc, ResourceWrapperUtils.getResources(service.getResourcesOfKind(ResourceKind.DEPLOYMENT_CONFIG)));
}
return dc;
}
Aggregations