Search in sources :

Example 16 with IDeploymentConfig

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);
}
Also used : ArrayList(java.util.ArrayList) Connection(org.jboss.tools.openshift.core.connection.Connection) IConnection(org.jboss.tools.openshift.common.core.connection.IConnection) IDeploymentConfig(com.openshift.restclient.model.IDeploymentConfig) ObservableTreeItem(org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem) IProject(com.openshift.restclient.model.IProject) Test(org.junit.Test)

Example 17 with IDeploymentConfig

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;
}
Also used : IDeploymentConfig(com.openshift.restclient.model.IDeploymentConfig)

Example 18 with IDeploymentConfig

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;
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) OpenShiftCoreException(org.jboss.tools.openshift.common.core.OpenShiftCoreException) Connection(org.jboss.tools.openshift.core.connection.Connection) IDeploymentConfig(com.openshift.restclient.model.IDeploymentConfig) IResource(com.openshift.restclient.model.IResource) IPod(com.openshift.restclient.model.IPod)

Example 19 with IDeploymentConfig

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;
}
Also used : IServiceWrapper(org.jboss.tools.openshift.internal.ui.models.IServiceWrapper) IDeploymentConfig(com.openshift.restclient.model.IDeploymentConfig) IService(com.openshift.restclient.model.IService)

Example 20 with IDeploymentConfig

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;
}
Also used : IServiceWrapper(org.jboss.tools.openshift.internal.ui.models.IServiceWrapper) IDeploymentConfig(com.openshift.restclient.model.IDeploymentConfig) IService(com.openshift.restclient.model.IService)

Aggregations

IDeploymentConfig (com.openshift.restclient.model.IDeploymentConfig)24 Test (org.junit.Test)11 Connection (org.jboss.tools.openshift.core.connection.Connection)9 IResource (com.openshift.restclient.model.IResource)8 IService (com.openshift.restclient.model.IService)7 IDeploymentImageChangeTrigger (com.openshift.restclient.model.deploy.IDeploymentImageChangeTrigger)7 DockerImageURI (com.openshift.restclient.images.DockerImageURI)6 IProject (com.openshift.restclient.model.IProject)5 Collection (java.util.Collection)4 ResourceKind (com.openshift.restclient.ResourceKind)3 IImageStream (com.openshift.restclient.model.IImageStream)3 IReplicationController (com.openshift.restclient.model.IReplicationController)3 ArrayList (java.util.ArrayList)3 Collections (java.util.Collections)3 HashMap (java.util.HashMap)3 List (java.util.List)3 IServiceWrapper (org.jboss.tools.openshift.internal.ui.models.IServiceWrapper)3 IClient (com.openshift.restclient.IClient)2 IResourceFactory (com.openshift.restclient.IResourceFactory)2 IPod (com.openshift.restclient.model.IPod)2